@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;600;700&family=Inter:wght@300;400;500;600&display=swap');

/* ─── Design Tokens ────────────────────────────────────── */

:root {
  --cream:       #F7F5F0;
  --cream-dark:  #EDE9E0;
  --navy:        #0F1E2D;
  --navy-mid:    #1A3248;
  --navy-light:  #2A4A65;
  --gold:        #C9A84C;
  --gold-light:  #E8C87A;
  --gold-pale:   #FDF6E3;
  --text-dark:   #1A1A2E;
  --text-body:   #3D4B58;
  --text-muted:  #8A96A3;
  --border:      #DDD8CE;
  --border-dark: #C5BFB2;
  --success:     #2E7D52;
  --error-bg:    #FDF2F2;
  --error-text:  #B91C1C;
  --error-border:#F5C6C6;
  --shadow-sm:   0 1px 3px rgba(15,30,45,0.08);
  --shadow-md:   0 4px 16px rgba(15,30,45,0.10);
  --shadow-lg:   0 12px 40px rgba(15,30,45,0.13);
  --radius:      6px;
  --radius-lg:   12px;
  --page-padding: 40px;
}

* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
  touch-action: manipulation; 
}

/* Prevent auto-zoom on mobile inputs */

input, select, textarea {
  font-size: 16px !important;
}

html { 
  scroll-behavior: smooth; 
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--cream);
  color: var(--text-dark);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  width: 100%;
  position: relative;
  touch-action: pan-y;
}

/* ─── Layout ───────────────────────────────────────────── */

.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Top Nav ──────────────────────────────────────────── */

.top-nav {
  background: var(--navy);
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
}

@media (max-width: 768px) {
  .top-nav {
    padding: 0 15px;
  }
  .nav-brand-name {
    font-size: 16px;
  }
  .nav-badge, .version-tag {
    display: none;
  }
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 15px;
}

.mobile-burger {
  display: none;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 5px;
}

.version-tag {
  color: rgba(255,255,255,0.5);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
}

.settings-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.settings-btn.active {
  background: var(--gold);
  color: var(--navy);
}

.nav-logo-icon {
  width: 32px;
  height: 32px;
  color: var(--gold);
}

.nav-brand-name {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.5px;
}

.nav-brand-name span { color: var(--gold); }

/* Sidebar Navigation */

.hub-layout {
  display: flex;
  min-height: calc(100vh - 64px);
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 30, 45, 0.4);
  backdrop-filter: blur(8px);
  z-index: 1100;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.hub-sidebar {
  width: 280px;
  background: var(--navy-mid);
  border-right: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  color: #fff;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 1024px) {
  .mobile-burger {
    display: flex !important;
  }
  .hub-sidebar {
    display: none !important;
  }
}

/* Bottom Navigation (Mobile Only) */

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 65px;
  background: rgba(15, 30, 45, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 3000;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 1024px) {
  .mobile-bottom-nav {
    display: flex;
  }
  .main-content {
    padding-bottom: 80px !important;
  }
  .app-footer {
    display: none;
  }
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
  gap: 4px;
  transition: all 0.2s;
  flex: 1;
  padding: 8px 0;
}

.bottom-nav-item svg {
  transition: transform 0.2s;
}

.bottom-nav-item.active {
  color: var(--gold);
}

.bottom-nav-item.active svg {
  transform: translateY(-2px);
  color: var(--gold);
}

.nav-menu {
  padding: 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}

.nav-item.active {
  background: var(--gold);
  color: var(--navy);
}

.nav-item.active svg {
  color: var(--navy);
}

/* Main Content Area */

.main-content {
  flex: 1;
  padding: 40px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 900px) {
  .hub-layout {
    flex-direction: column;
  }
  .hub-sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }
  .nav-menu {
    flex-direction: row;
    overflow-x: auto;
    padding: 10px;
  }
  .nav-item {
    white-space: nowrap;
    padding: 10px 15px;
  }
  .main-content {
    padding: 20px;
  }
}

/* ─── Cards ─── */

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.card-header {
  padding: 16px 24px;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title {
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--navy-mid);
}

.card-body {
  padding: 24px;
}

/* Labels & Inputs */

label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

input, select, textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  background: var(--cream);
  transition: all 0.2s;
}

input:focus {
  border-color: var(--gold);
  background: #fff;
  outline: none;
}

/* Buttons */

.btn-primary {
  background: var(--gold);
  color: var(--navy);
  border: none;
  padding: 14px 28px;
  border-radius: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-primary:hover {
  background: var(--gold-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--gold);
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--gold-pale);
}

/* Animations */

.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Records Responsive ─── */

/* Mobile Menu Fixes */

.menu-open .hub-sidebar {
  transform: translateX(0);
  display: flex !important;
  position: fixed;
  top: 70px;
  left: 0;
  width: 280px;
  height: calc(100vh - 70px);
  z-index: 1000;
  background: var(--navy);
  box-shadow: 10px 0 30px rgba(0,0,0,0.5);
  animation: slideInLeft 0.3s ease;
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: #fff;
    border-top: 1px solid #eee;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 1000;
  }
  
  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #64748b;
    font-size: 10px;
    font-weight: 600;
  }
  
  .bottom-nav-item.active {
    color: var(--gold);
  }
}

.record-card-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.record-main-info {
  display: flex;
  gap: 15px;
  align-items: center;
  flex: 1;
}

.record-icon-wrapper {
  background: var(--navy);
  color: var(--gold);
  padding: 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.record-text-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.record-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.record-client-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--navy);
}

.record-reference {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--cream);
  padding: 2px 8px;
  border-radius: 4px;
}

/* --- Surveyor 1:1 Clone Styles --- */

.surveyor-view-clone {
  animation: fadeIn 0.4s ease;
  padding-bottom: 80px;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.view-title {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  color: var(--navy);
}

.view-title span {
  color: var(--gold);
}

.card-pro {
  background: white;
  border: 1px solid #e0e4ea;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.card-pro.dark {
  background: #1a1a2e;
  color: white;
}

.card-title-pro {
  font-weight: 800;
  font-size: 0.75rem;
  color: #1a1a2e;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid #e2b96f;
  padding-bottom: 8px;
}

.card-title-pro.gold {
  color: #e2b96f;
}

.shape-selector-pro {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.shape-btn-pro {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 15px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
  color: #64748b;
  width: 100%;
}

.shape-btn-pro.active {
  border-color: #e2b96f;
  background: #fffcf0;
  color: #1a1a2e;
}

.shape-btn-pro.active svg {
  color: #c9a050;
}

.measures-grid-pro {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.measure-item label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.measure-item input {
  width: 100%;
  padding: 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-weight: 800;
  font-size: 1.1rem;
  color: #1a1a2e;
  background: #f9fafb;
}

.measure-item.highlight input {
  background: #fdfaf3;
  border-color: #e2b96f;
  color: #c9a050;
}

.photo-grid-pro {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.photo-box {
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  border: 1px solid #e2e8f0;
}

.photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.del-photo {
  position: absolute;
  top: 5px;
  right: 5px;
  background: #ef4444;
  color: white;
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-photo-box {
  aspect-ratio: 1;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 800;
}

.add-photo-box:hover {
  border-color: #e2b96f;
  color: #c9a050;
  background: #fffcf0;
}

.editor-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.9);
  padding: 10px 0;
  backdrop-filter: blur(10px);
  z-index: 100;
}

.btn-save {
  background: #e2b96f;
  color: #1a1a2e;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(226, 185, 111, 0.3);
  border: none;
}

.btn-pdf {
  background: #1a1a2e;
  color: #e2b96f;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid #e2b96f;
}

.project-card-clone {
  background: white;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid #e0e4ea;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
}

.project-card-clone:hover {
  transform: translateX(5px);
  border-color: #e2b96f;
}

.badge-gold {
  background: #fffcf0;
  color: #c9a050;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 800;
  border: 1px solid rgba(226, 185, 111, 0.2);
}

.floating-action {
  position: fixed;
  bottom: 80px;
  left: 0;
  right: 0;
  padding: 0 20px;
  z-index: 500;
}

.btn-cta {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  background: #1a1a2e;
  color: white;
  padding: 18px;
  border-radius: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  border: 2px solid #e2b96f;
}

.checklist-pro {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.check-item input {
  width: 20px;
  height: 20px;
  accent-color: #e2b96f;
}

.check-item span {
  font-size: 0.9rem;
  font-weight: 600;
}

.record-details-row {
  display: flex;
  gap: 15px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.record-detail-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.record-actions-info {
  display: flex;
  align-items: center;
  gap: 25px;
}

.record-price-summary {
  text-align: right;
}

.price-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.price-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy);
}

.record-buttons {
  display: flex;
  gap: 8px;
}

.record-btn {
  padding: 8px 15px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.record-btn.delete-btn {
  color: var(--error-text);
  border-color: rgba(185, 28, 28, 0.2);
}

.record-btn.delete-btn:hover {
  background: var(--error-bg);
}

@media (max-width: 768px) {
  .record-card-body {
    flex-direction: column;
    align-items: stretch;
  }
  .record-actions-info {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
  }
  .record-price-summary {
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .record-buttons {
    width: 100%;
  }
  .record-btn {
    flex: 1;
    justify-content: center;
  }
  .btn-text-mobile {
    display: inline;
  }
}

/* ─── Animations ────────────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.5; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.5; }
}

.fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}

/* ── Excel CRM Table ── */

.excel-table th {
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
}

.excel-input {
  width: 100%;
  padding: 8px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  color: var(--navy);
  border-radius: 4px;
  transition: all 0.2s;
}

.excel-input:focus {
  background: #fff;
  border-color: var(--gold);
  outline: none;
  box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.1);
}

.excel-table tr:hover .excel-input {
  background: rgba(255,255,255,0.5);
  border-color: var(--border);
}

/* ─── UX Adjustments: Mobile First & Tablet ──────────────── */

/* Optimización para Tablet (iPad, etc.) */

@media (min-width: 769px) and (max-width: 1200px) {
  .hub-layout {
    padding: 20px;
  }
  .main-content {
    padding: 20px;
  }
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Optimización para Móvil */

@media (max-width: 768px) {
  :root {
    --page-padding: 15px;
  }

  .main-content {
    padding: 15px;
    padding-bottom: 100px; /* Espacio para el bottom nav */
  }

  .page-title {
    font-size: 24px;
    margin-bottom: 20px;
  }

  /* Tabla Excel en Móvil */
  .excel-table-container {
    margin: 0 -15px; /* Sacar de los márgenes para ganar espacio */
    border-radius: 0;
    position: relative;
  }
  
  .excel-table-container::after {
    content: '← Desliza para ver más →';
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 700;
    opacity: 0.6;
  }

  /* Botones más táctiles */
  .btn-primary, .btn-secondary {
    min-height: 48px;
    font-size: 14px;
  }

  .record-card-body {
    flex-direction: column;
    align-items: flex-start;
  }

  .record-actions-info {
    width: 100%;
    border-top: 1px solid var(--border);
    padding-top: 15px;
    margin-top: 10px;
    justify-content: space-between;
  }

  /* Login en Móvil */
  .login-overlay .card {
    padding: 25px;
    margin: 10px;
  }
}

/* Efectos de toque para dispositivos móviles */

@media (hover: none) {
  .nav-item:active, .bottom-nav-item:active {
    background: rgba(201, 168, 76, 0.2);
    transform: scale(0.98);
  }
  
  .btn-primary:active {
    transform: scale(0.96);
    background: var(--gold-dark);
  }
}

/* Scrollbars limpios para las tablas */

::-webkit-scrollbar {
  height: 4px;
  width: 4px;
}

::-webkit-scrollbar-track {
  background: var(--cream);
}

::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: 10px;
}
