/* ── LJA Design System — aplicado a Secretaria IA ────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Italiana&family=Karla:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

/* ── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  /* Paleta — bronce/oro mate (acento, uso puntual) */
  --gold:        #8B6F5C;  /* bronze-400 — matte gold, acento */
  --gold-light:  #C9B3A0;  /* bronze-200 */
  --gold-dark:   #6B5443;  /* bronze-500 — aged bronze */
  --gold-pale:   #F2ECE4;  /* sand — fondo tintado */
  --gold-glow:   rgba(166,124,70,0.14);

  /* Sage — verde salvia, color primario de marca */
  --sage:        #647549;
  --sage-light:  #99A87E;
  --sage-dark:   #505E3A;
  --sage-pale:   #EEF0E7;

  /* Fondos */
  --black:       #2A241D;  /* ink — casi negro, cálido, uso muy puntual */
  --sidebar-bg:  #F2ECE4;  /* sidebar clara — sand/canvas */
  --page-bg:     #FBF8F3;  /* blanco cálido */
  --card-bg:     #FFFFFF;

  /* Texto */
  --text:        #3A332A;  /* bark */
  --text-2:      #4E4335;  /* umber */
  --text-muted:  #8A7860;  /* earth mid */
  --text-light:  #CBB99C;  /* dune */

  /* Bordes */
  --border:      #E1D3BC;  /* arena */
  --border-2:    #EDE4D3;  /* beige */
  --border-dark: rgba(42,36,29,0.08);

  /* Sidebar */
  --sidebar-w:   260px;
  --sidebar-txt: #6B5B47;

  /* Señales (nunca azul clínico ni rojo puro) */
  --green:  #647549;  /* sage — éxito / ingresos */
  --red:    #9A4A3D;  /* terracota oscuro — crítico / gastos */
  --blue:   #8A7860;  /* neutro cálido — informativo */
  --amber:  #8B6F5C;  /* bronce — advertencia */

  /* Layout */
  --radius:    18px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(58,51,42,.06);
  --shadow-sm: 0 2px 8px rgba(58,51,42,.07);
  --shadow-md: 0 8px 24px rgba(58,51,42,.09);
  --shadow-lg: 0 16px 48px rgba(58,51,42,.12);
  --transition: all 0.28s cubic-bezier(.4,0,.2,1);

  /* Tipografía */
  --font-display: 'Italiana', 'Times New Roman', serif;
  --font-body:    'Karla', -apple-system, 'Helvetica Neue', sans-serif;
}

/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 0.9rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  margin: 0;
}

a { color: inherit; text-decoration: none; }
p { margin: 0; }

/* ── Iconos Lucide ──────────────────────────────────────────────────────── */
.lucide {
  width: 1em;
  height: 1em;
  stroke-width: 1.6;
  vertical-align: -0.15em;
  flex-shrink: 0;
}

/* ── Sidebar (clara, cálida) ──────────────────────────────────────────────  */
.sidebar {
  background: var(--sidebar-bg);
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-2);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(42,36,29,.45);
  backdrop-filter: blur(4px);
  z-index: 199;
}
.sidebar-overlay.show { display: block; }

/* Logo */
.sidebar .logo {
  padding: 1.8rem 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border-2);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar .logo img {
  height: 36px; width: 36px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  display: block;
}
.sidebar .logo-text {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.25;
}
.sidebar .logo-text span {
  display: block;
  color: var(--sidebar-txt);
  font-size: 0.66rem;
  font-weight: 500;
  font-family: var(--font-body);
  margin-top: 3px;
  letter-spacing: 0.4px;
}

/* Nav */
.sidebar nav {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar nav::-webkit-scrollbar { display: none; }

.sidebar .nav-section {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 1rem 0.75rem 0.4rem;
  font-family: var(--font-body);
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1px;
  color: var(--sidebar-txt);
  font-size: 0.86rem;
  font-weight: 400;
  transition: var(--transition);
  position: relative;
  text-decoration: none;
}
.sidebar .nav-link .lucide {
  opacity: 0.7;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.sidebar .nav-link:hover {
  background: var(--card-bg);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.sidebar .nav-link:hover .lucide { opacity: 1; }
.sidebar .nav-link.active {
  background: var(--card-bg);
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-xs);
}
.sidebar .nav-link.active .lucide { opacity: 1; color: var(--gold-dark); }
.sidebar .nav-link.danger { color: #9A4A3D; }
.sidebar .nav-link.danger:hover { background: rgba(154,74,61,.08); color: #9A4A3D; }

/* Sidebar footer */
.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-2);
  flex-shrink: 0;
}
.sidebar-footer .sf-label {
  font-size: 0.6rem;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-light);
}
.sidebar-footer .sf-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.74rem;
  color: var(--text-muted);
}
.sf-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--sage);
  box-shadow: 0 0 6px rgba(100,117,73,.5);
}

/* ── Topbar móvil ───────────────────────────────────────────────────────── */
.topbar-mobile {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--sidebar-bg);
  z-index: 198;
  align-items: center;
  padding: 0 1.1rem;
  gap: 12px;
  border-bottom: 1px solid var(--border-2);
}
.topbar-mobile .logo-text { color: var(--text); font-family: var(--font-display); font-size: 1.05rem; }
.btn-menu {
  background: none; border: none;
  color: var(--sidebar-txt); font-size: 1.4rem;
  cursor: pointer; padding: 4px 6px;
  transition: color 0.15s;
}
.btn-menu:hover { color: var(--gold-dark); }

/* ── Main content ───────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  padding: 2.5rem 2.8rem;
  min-height: 100vh;
}

/* ── Page header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.2vw, 40px);
  font-weight: 400;
  color: var(--text);
  letter-spacing: 0.01em;
  margin: 0;
  line-height: 1.12;
}
.page-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
  font-weight: 300;
  letter-spacing: 0.2px;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--border-2) !important;
  padding: 1rem 1.4rem;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted) !important;
  border-radius: 0 !important;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-header .lucide { color: var(--gold-dark); opacity: 0.85; }
.card-body { padding: 1.4rem; }

/* ── Stat cards — Dashboard (sin franja de color, quieto) ────────────────── */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem 1.8rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.stat-icon {
  position: absolute;
  top: 1.4rem; right: 1.4rem;
  font-size: 1.4rem;
  opacity: 0.18;
  color: var(--gold-dark);
}
.stat-gold  .stat-icon,
.stat-warm  .stat-icon { color: var(--gold-dark); }
.stat-green .stat-icon { color: var(--sage); }
.stat-blue  .stat-icon { color: var(--text-muted); }
.stat-num {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--text);
  line-height: 1;
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--text-muted);
}

/* ── Buttons — pill, tono sage por defecto ───────────────────────────────── */
.btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.85rem;
  border-radius: var(--radius-pill);
  transition: var(--transition);
  letter-spacing: 0.1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary {
  background: var(--sage);
  border-color: var(--sage);
  color: #FBF8F3;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--sage-dark);
  border-color: var(--sage-dark);
  color: #FBF8F3;
  box-shadow: 0 4px 14px rgba(100,117,73,.3);
}
.btn-outline-primary {
  border-color: var(--border);
  color: var(--text-2);
  background: white;
}
.btn-outline-primary:hover {
  background: var(--sage-pale);
  border-color: var(--sage);
  color: var(--sage-dark);
}
.btn-outline-secondary {
  border-color: var(--border);
  color: var(--text-muted);
  background: white;
}
.btn-outline-secondary:hover {
  background: var(--page-bg);
  border-color: var(--border-2);
  color: var(--text);
}
.btn-sm {
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
}
.btn-lg {
  padding: 0.75rem 1.6rem;
  font-size: 0.9rem;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}
.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.88rem;
  padding: 0.6rem 0.9rem;
  background: #FDFCFA;
  color: var(--text);
  transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(166,124,70,.16);
  background: white;
  outline: none;
}
.form-text { font-size: 0.72rem; color: var(--text-muted); }

/* ── Modals ─────────────────────────────────────────────────────────────── */
.modal-content {
  border: none;
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  background: var(--sidebar-bg) !important;
  border-bottom: 1px solid var(--border-2) !important;
  border-radius: 22px 22px 0 0 !important;
  padding: 1.5rem 1.8rem !important;
}
.modal-header .modal-title {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.modal-header .btn-close { opacity: .55; }
.modal-body { padding: 1.6rem 1.8rem; }
.modal-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.8rem;
}

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table {
  font-size: 0.86rem;
  margin-bottom: 0;
}
.table thead th {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--text-muted);
  background: var(--gold-pale);
  border-bottom: 1px solid var(--border);
  padding: 0.8rem 1.2rem;
  white-space: nowrap;
}
.table tbody td {
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border-2);
  vertical-align: middle;
  color: var(--text);
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background: #FDFBF6; }

/* ── Badges (tono sage/bronce, nunca semáforo clínico) ───────────────────── */
.badge {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.68rem;
  padding: 0.32em 0.75em;
  border-radius: var(--radius-pill);
  letter-spacing: 0.3px;
}
.badge-pendiente  { background: var(--gold-pale); color: var(--gold-dark); }
.badge-completada { background: var(--sage-pale); color: var(--sage-dark); }
.badge-cancelada  { background: var(--border-2); color: var(--text-muted); }
.badge-pagada     { background: var(--sage-pale); color: var(--sage-dark); }

/* ── WhatsApp badge ─────────────────────────────────────────────────────── */
.wa-badge {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  background: var(--sage);
  color: #FBF8F3;
  border-radius: var(--radius-pill);
  padding: 0.42rem 1rem;
  font-size: 0.76rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  letter-spacing: 0.1px;
}
.wa-badge:hover { transform: translateY(-1px); }

/* ── Grabadora ──────────────────────────────────────────────────────────── */
.grabadora-box {
  background: var(--gold-pale);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.btn-grabar {
  width: 52px; height: 52px;
  background: var(--gold);
  border: none;
  border-radius: 50%;
  color: #FBF8F3;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  box-shadow: 0 4px 14px rgba(166,124,70,.35);
  flex-shrink: 0;
  cursor: pointer;
}
.btn-grabar:hover { background: var(--gold-dark); transform: scale(1.05); }
.btn-grabar.grabando { background: #9A4A3D; animation: pulsoRojo 1.6s ease-in-out infinite; }
@keyframes pulsoRojo {
  0%,100% { box-shadow: 0 0 0 0 rgba(154,74,61,.35); }
  50%      { box-shadow: 0 0 0 14px rgba(154,74,61,0); }
}
.onda-bar {
  display: inline-block; width: 3px;
  background: var(--gold); border-radius: 2px;
  height: 8px; margin: 0 2px; vertical-align: middle;
  animation: onda 1.2s ease-in-out infinite;
}
@keyframes onda {
  0%,100% { height: 8px; }
  50%     { height: 24px; }
}

/* ── Consulta card (sin franja de color — tarjeta lisa) ──────────────────── */
.consulta-card {
  background: var(--gold-pale);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  margin-bottom: 0.75rem;
}

/* ── Foto thumbs ────────────────────────────────────────────────────────── */
.foto-thumb {
  width: 110px; height: 110px;
  object-fit: cover;
  border-radius: 14px;
  cursor: pointer;
  transition: var(--transition);
  border: 1.5px solid var(--border);
}
.foto-thumb:hover {
  transform: scale(1.04);
  box-shadow: var(--shadow-md);
  border-color: var(--gold);
}

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-bg {
  background: radial-gradient(ellipse at 20% 80%, var(--gold-pale) 0%, var(--sidebar-bg) 100%);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: white;
  border-radius: var(--radius);
  padding: 2.8rem;
  width: 100%; max-width: 370px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state .lucide {
  width: 2rem; height: 2rem;
  color: var(--gold);
  opacity: 0.5;
  display: block;
  margin: 0 auto 0.75rem;
}
.empty-state p { font-size: 0.87rem; margin: 0; }
.empty-state strong { color: var(--text-2); font-weight: 600; }

/* ── Segmented filter (pills) ───────────────────────────────────────────── */
.seg-filter {
  display: inline-flex;
  gap: 4px;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
}
.seg-filter a {
  padding: 0.35rem 0.95rem;
  border-radius: var(--radius-pill);
  font-size: 0.79rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
  white-space: nowrap;
}
.seg-filter a:hover { color: var(--text); }
.seg-filter a.active {
  background: var(--gold);
  color: #FBF8F3;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(166,124,70,.35);
}
.seg-filter a .seg-count {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-left: 4px;
}

/* ── Ghost icon buttons (acciones de fila) ──────────────────────────────── */
.btn-ghost-icon {
  background: none;
  border: none;
  color: var(--text-light);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.btn-ghost-icon:hover { background: var(--gold-pale); color: var(--gold-dark); }
.btn-ghost-icon.danger:hover { background: #F5E9E6; color: #9A4A3D; }

/* ── Dividers ───────────────────────────────────────────────────────────── */
.nav-divider {
  height: 1px;
  background: var(--border-2);
  margin: 0.5rem 0.75rem;
}

/* ── List group ─────────────────────────────────────────────────────────── */
.list-group-item {
  border-color: var(--border-2) !important;
  padding: 0.85rem 1.4rem;
}
.list-group-item:last-child { border-bottom: none !important; }

/* ── Alert ──────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  border-width: 0;
}
.alert-info { background: var(--gold-pale); color: var(--gold-dark); }
.alert-danger { background: #F5E9E6; color: #9A4A3D; }
.alert-success { background: var(--sage-pale); color: var(--sage-dark); }
.alert-warning { background: var(--gold-pale); color: var(--gold-dark); }

/* ── Utilities ──────────────────────────────────────────────────────────── */
.text-gold      { color: var(--gold-dark) !important; }
.text-gold-dark { color: var(--gold-dark) !important; }
.text-muted     { color: var(--text-muted) !important; }
.fw-display     { font-family: var(--font-display) !important; }
.bg-gold-pale   { background: var(--gold-pale) !important; }
.border-gold    { border-color: var(--gold) !important; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar-mobile { display: flex; }
  .main-content { margin-left: 0; padding: 1.2rem; padding-top: 68px; }
  .page-title { font-size: 1.6rem; }
  .stat-num { font-size: 2.1rem; }
  .table thead { display: none; }
  .table tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 0.75rem;
    padding: 0.75rem 1rem;
    background: white;
    box-shadow: var(--shadow-xs);
  }
  .table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: none;
    padding: 0.3rem 0;
    font-size: 0.84rem;
  }
  .table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-right: 8px;
    flex-shrink: 0;
  }
  .wa-badge { bottom: 0.75rem; right: 0.75rem; font-size: 0.72rem; }
  .grabadora-box { flex-direction: column !important; align-items: flex-start !important; gap: 1rem !important; }
  .modal-content { border-radius: 18px; }
  .modal-body { padding: 1.2rem; }
}
