/* ==========================================================================
   SISTEMA CLÍNICO · PSIC. JESICA ESQUIVEL · ACOMPAÑAMIENTO PSICOLÓGICO
   Paleta extraída directamente de su identidad visual oficial
   ========================================================================== */

:root {
  --bg-cream: #F6ECE2;
  --bg-card: #FCF8F4;
  --bg-sand: #EFE0D1;
  --bg-sand-soft: #F8F2EC;

  --primary: #964B2B;
  --primary-hover: #7D3C20;
  --primary-soft: #F5E4DC;

  --sage: #71786D;
  --sage-dark: #585E55;
  --sage-soft: #E5E8E3;

  --peach: #DFAD81;
  --peach-soft: #F9EFE5;

  --mauve: #9D7B8E;
  --mauve-soft: #F1E9EE;

  --text-main: #3B3632;
  --text-muted: #6F665E;
  --border-warm: #E3D3C3;

  --success: #4E7A5B;
  --success-bg: #E5F0E8;
  --warning: #B87D32;
  --warning-bg: #FBF1E1;
  --orange: #C4622D;
  --orange-bg: #FCE9DF;
  --danger: #A93B3B;
  --danger-bg: #F9E3E3;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-soft: 0 6px 24px rgba(102, 68, 46, 0.07);
  --shadow-hover: 0 10px 30px rgba(102, 68, 46, 0.13);
}

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

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-cream);
  color: var(--text-main);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(circle at 0% 0%, rgba(113, 120, 109, 0.10) 0%, transparent 28%),
    radial-gradient(circle at 100% 100%, rgba(157, 123, 142, 0.12) 0%, transparent 28%);
}

h1, h2, h3, .serif-title {
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--primary);
  letter-spacing: 0.01em;
}

/* ==========================================================================
   LAYOUT PRINCIPAL (SIDEBAR + MAIN + MOBILE NAV)
   ========================================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  background: var(--bg-card);
  border-right: 1px solid var(--border-warm);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: 4px 0 20px rgba(102, 68, 46, 0.04);
}

.brand-box {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border-warm);
  text-align: center;
  background: var(--bg-cream);
}

.brand-logo-img {
  width: 100%;
  max-width: 235px;
  height: auto;
  border-radius: 10px;
  display: block;
  margin: 0 auto 6px;
}

.brand-subtitle-pill {
  display: inline-block;
  background: var(--sage);
  color: #fff;
  font-size: 0.72rem;
  padding: 3px 12px;
  border-radius: 99px;
  letter-spacing: 0.04em;
}

.nav-menu {
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: var(--text-main);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.94rem;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: all 0.18s ease;
}

.nav-item:hover {
  background: var(--bg-sand-soft);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(150, 75, 43, 0.25);
}

.nav-item .nav-icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-warm);
  background: var(--bg-sand-soft);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.main-area {
  flex: 1;
  margin-left: 280px;
  padding: 28px 34px 90px;
  max-width: 1420px;
}

/* ==========================================================================
   HEADER DE PÁGINA Y BOTONES
   ========================================================================== */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-sage {
  background: var(--sage);
  color: #fff;
}
.btn-sage:hover {
  background: var(--sage-dark);
}

.btn-mauve {
  background: var(--mauve);
  color: #fff;
}
.btn-mauve:hover {
  opacity: 0.92;
}

.btn-outline {
  background: var(--bg-card);
  color: var(--primary);
  border-color: var(--border-warm);
}
.btn-outline:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.btn-whatsapp {
  background: #2E7D4F;
  color: #fff;
}
.btn-whatsapp:hover {
  background: #23633E;
}

.btn-danger-soft {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   TARJETAS, ESTADÍSTICAS Y GRIDS
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  gap: 15px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.terracotta { background: var(--primary-soft); color: var(--primary); }
.stat-icon.sage { background: var(--sage-soft); color: var(--sage-dark); }
.stat-icon.peach { background: var(--peach-soft); color: #A6652E; }
.stat-icon.mauve { background: var(--mauve-soft); color: var(--mauve); }

.stat-value {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.15;
}

.stat-label {
  font-size: 0.83rem;
  color: var(--text-muted);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-warm);
  flex-wrap: wrap;
  gap: 10px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

/* ==========================================================================
   BADGES Y ETIQUETAS CLÍNICAS (TCC / ACT)
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.76rem;
  font-weight: 600;
}

.badge-tcc { background: var(--peach-soft); color: #8F4A1C; border: 1px solid var(--peach); }
.badge-act { background: var(--mauve-soft); color: #6B495C; border: 1px solid var(--mauve); }
.badge-sage { background: var(--sage-soft); color: var(--sage-dark); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }

.chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.tech-chip {
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 0.8rem;
  border: 1px solid var(--border-warm);
  background: var(--bg-cream);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.tech-chip:hover {
  border-color: var(--primary);
}

.tech-chip.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tech-chip.act-chip.selected {
  background: var(--mauve);
  border-color: var(--mauve);
}

/* ==========================================================================
   LISTAS DE PACIENTES Y SESIONES
   ========================================================================== */

.patient-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.patient-card {
  background: var(--bg-card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
}

.patient-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
}

.patient-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
  font-family: Georgia, serif;
}

.session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  background: var(--bg-sand-soft);
  border: 1px solid var(--border-warm);
  margin-bottom: 10px;
  gap: 12px;
  flex-wrap: wrap;
}

.session-time-pill {
  background: var(--primary);
  color: #fff;
  padding: 5px 10px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 68px;
  text-align: center;
}

/* ==========================================================================
   PESTAÑAS INTERNAS DEL EXPEDIENTE CLÍNICO
   ========================================================================== */

.tabs-bar {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border-warm);
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab-btn {
  padding: 10px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--primary-soft);
  border-radius: 10px 10px 0 0;
}

/* ==========================================================================
   MAPA DE CONCEPTUALIZACIÓN TCC (ABC) Y CONTEXTUAL (ACT)
   ========================================================================== */

.abc-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
  margin-top: 10px;
}

.abc-box {
  background: var(--bg-cream);
  border: 1px solid var(--border-warm);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 14px;
}

.abc-box.act-style {
  border-top-color: var(--mauve);
  background: #FAF6F8;
}

.abc-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  margin-right: 6px;
}

/* ==========================================================================
   FORMULARIOS Y CAMPOS DE ENTRADA
   ========================================================================== */

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-main);
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(150, 75, 43, 0.12);
}

textarea.form-control {
  min-height: 92px;
  resize: vertical;
}

/* ==========================================================================
   CAPTURA DE FOTO DE HOJA EN PAPEL Y DICTADO POR VOZ
   ========================================================================== */

.paper-capture-zone {
  border: 2px dashed var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
  margin-bottom: 16px;
}

.note-photo-preview {
  max-width: 100%;
  max-height: 360px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-warm);
  margin-top: 10px;
  cursor: zoom-in;
  box-shadow: var(--shadow-soft);
}

.voice-recording-active {
  animation: pulse-record 1.2s infinite;
  background: var(--danger) !important;
  color: #fff !important;
}

@keyframes pulse-record {
  0% { box-shadow: 0 0 0 0 rgba(169, 59, 59, 0.6); }
  70% { box-shadow: 0 0 0 12px rgba(169, 59, 59, 0); }
  100% { box-shadow: 0 0 0 0 rgba(169, 59, 59, 0); }
}

/* ==========================================================================
   MODALES Y GRÁFICAS DE PSICOMETRÍA
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(45, 35, 28, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 18px;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
}

.chart-box {
  background: #fff;
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 12px;
}

/* ==========================================================================
   NAVEGACIÓN MÓVIL (PARA CELULAR EN EL CONSULTORIO)
   ========================================================================== */

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-warm);
  z-index: 200;
  padding: 6px 8px;
  justify-content: space-around;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.mobile-nav-btn.active {
  color: var(--primary);
  background: var(--primary-soft);
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  .main-area {
    margin-left: 0;
    padding: 18px 16px 90px;
  }
  .mobile-bottom-nav {
    display: flex;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   FORMATO DE IMPRESIÓN OFICIAL (MEMBRETE DE JESICA ESQUIVEL)
   ========================================================================== */

.print-only-header {
  display: none;
}

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .sidebar, .mobile-bottom-nav, .no-print, .btn, .tabs-bar {
    display: none !important;
  }
  .main-area {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }
  .print-only-header {
    display: block !important;
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #964B2B;
    padding-bottom: 12px;
  }
  .print-only-header img {
    max-width: 480px;
    height: auto;
  }
  .card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    break-inside: avoid;
  }
}
