/* ============================================================
   ChiroClinic – Hoja de estilos principal
   Paleta: Azul marino profundo + blanco claro + acento teal
   Tipografía: DM Sans + DM Serif Display
   ============================================================ */

:root {
  --navy:       #0f1f3d;
  --navy-light: #1a3260;
  --teal:       #0ea5e9;
  --teal-dark:  #0284c7;
  --teal-soft:  #e0f2fe;
  --green:      #16a34a;
  --green-soft: #dcfce7;
  --red:        #dc2626;
  --red-soft:   #fee2e2;
  --amber:      #d97706;
  --amber-soft: #fef3c7;
  --gray-50:    #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-400:   #94a3b8;
  --gray-500:   #64748b;
  --gray-700:   #334155;
  --gray-900:   #0f172a;
  --sidebar-w:  260px;
  --topbar-h:   64px;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow:     0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:  0 10px 40px rgba(0,0,0,.12);
  --transition: .18s ease;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  font-size: .9375rem;
  color: var(--gray-900);
  background: var(--gray-50);
  margin: 0;
}

h1,h2,h3,h4,h5,h6 { font-family: 'DM Sans', sans-serif; font-weight: 600; }

a { color: var(--teal-dark); text-decoration: none; }
a:hover { color: var(--navy); }

/* ── Layout app ───────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition), width var(--transition);
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-icon {
  width: 40px; height: 40px;
  background: var(--teal);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.brand-name {
  display: block;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -.3px;
  line-height: 1.2;
}

.brand-sub {
  display: block;
  color: rgba(255,255,255,.45);
  font-size: .72rem;
  letter-spacing: .3px;
}

/* Menú */
.sidebar-menu {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.menu-label {
  color: rgba(255,255,255,.35);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  padding: 0 10px 6px;
  margin-top: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  font-size: .88rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  white-space: nowrap;
}

.menu-item i { width: 18px; text-align: center; font-size: .95rem; flex-shrink: 0; }

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

.menu-item.active {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 4px 12px rgba(14,165,233,.35);
}

/* Footer sidebar */
.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }

.user-avatar { color: rgba(255,255,255,.5); font-size: 1.6rem; flex-shrink: 0; }

.user-name {
  display: block;
  color: #fff;
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  display: block;
  color: rgba(255,255,255,.4);
  font-size: .72rem;
}

.btn-logout {
  background: rgba(255,255,255,.08);
  border: none;
  color: rgba(255,255,255,.6);
  width: 34px; height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.btn-logout:hover { background: var(--red); color: #fff; }

/* ── Main wrapper ─────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  box-shadow: var(--shadow-sm);
}

.btn-toggle-sidebar {
  background: none; border: none;
  color: var(--gray-500);
  font-size: 1.05rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: color var(--transition);
  display: none;
}

.btn-toggle-sidebar:hover { color: var(--navy); }

.topbar-title {
  font-size: .97rem;
  font-weight: 600;
  color: var(--gray-700);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── Alerts toast ─────────────────────────────────────────── */
.alert-container {
  position: fixed;
  top: 76px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.alert-toast {
  border-radius: var(--radius-sm);
  font-size: .875rem;
  box-shadow: var(--shadow-lg);
  border: none;
  padding: 14px 18px;
}

/* ── Page content ─────────────────────────────────────────── */
.page-content { padding: 28px; flex: 1; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: #fff;
}

.card-header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 16px 22px;
  border-radius: var(--radius) var(--radius) 0 0 !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header .card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}

.card-body { padding: 22px; }

/* ── Stat cards (Dashboard) ───────────────────────────────── */
.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

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

.stat-icon.blue   { background: var(--teal-soft);   color: var(--teal-dark); }
.stat-icon.green  { background: var(--green-soft);  color: var(--green); }
.stat-icon.amber  { background: var(--amber-soft);  color: var(--amber); }
.stat-icon.navy   { background: #e8edf6;            color: var(--navy); }

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}

.stat-label {
  font-size: .8rem;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ── Tables ───────────────────────────────────────────────── */
.table-clean {
  font-size: .88rem;
  margin: 0;
}

.table-clean thead th {
  background: var(--gray-50);
  color: var(--gray-500);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--gray-200);
  padding: 11px 16px;
  white-space: nowrap;
}

.table-clean tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  color: var(--gray-700);
}

.table-clean tbody tr:last-child td { border-bottom: none; }

.table-clean tbody tr:hover td { background: var(--gray-50); }

/* ── Badges de estado ─────────────────────────────────────── */
.badge-estado {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-estado.pendiente { background: var(--amber-soft); color: var(--amber); }
.badge-estado.completada { background: var(--green-soft); color: var(--green); }
.badge-estado.cancelada { background: var(--red-soft);  color: var(--red); }
.badge-estado.activo    { background: var(--green-soft); color: var(--green); }
.badge-estado.inactivo  { background: var(--gray-100);   color: var(--gray-500); }

/* ── Botones ──────────────────────────────────────────────── */
.btn {
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.btn-primary { background: var(--teal); border-color: var(--teal); }
.btn-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }

.btn-navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-light); border-color: var(--navy-light); color: #fff; }

.btn-atender {
  background: var(--teal);
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

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

/* ── Formularios ──────────────────────────────────────────── */
.form-label { font-weight: 500; font-size: .875rem; color: var(--gray-700); margin-bottom: 5px; }

.form-control, .form-select {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: .5rem .85rem;
  font-size: .9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: 'DM Sans', sans-serif;
}

.form-control:focus, .form-select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14,165,233,.12);
  outline: none;
}

.form-section {
  padding: 22px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 20px;
  background: #fff;
}

.form-section-title {
  font-size: .8rem;
  font-weight: 700;
  color: var(--teal-dark);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

/* ── Perfil paciente ──────────────────────────────────────── */
.patient-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  border-radius: var(--radius);
  padding: 28px 30px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

.patient-avatar {
  width: 64px; height: 64px;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  color: rgba(255,255,255,.8);
  flex-shrink: 0;
}

.patient-name { font-size: 1.35rem; font-weight: 700; }
.patient-meta { color: rgba(255,255,255,.65); font-size: .88rem; margin-top: 4px; }

.patient-badge {
  margin-left: auto;
  background: rgba(255,255,255,.12);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}

/* ── Cita card (dashboard) ────────────────────────────────── */
.cita-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--gray-100);
}

.cita-row:last-child { border-bottom: none; }

.cita-time {
  width: 56px;
  text-align: center;
  flex-shrink: 0;
}

.cita-time .hora { font-size: 1.05rem; font-weight: 700; color: var(--navy); }
.cita-time .ampm { font-size: .7rem; color: var(--gray-400); }

.cita-indicator {
  width: 3px; height: 44px;
  border-radius: 3px;
  flex-shrink: 0;
}

.cita-indicator.pendiente  { background: var(--amber); }
.cita-indicator.completada { background: var(--green); }
.cita-indicator.cancelada  { background: var(--red); }

.cita-info { flex: 1; min-width: 0; }
.cita-paciente { font-weight: 600; font-size: .92rem; color: var(--gray-900); }
.cita-motivo   { font-size: .8rem; color: var(--gray-500); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Próxima cita (dashboard) ─────────────────────────────── */
.proxima-card {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  border-radius: var(--radius);
  padding: 22px;
  color: #fff;
}

.proxima-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; opacity: .75; }
.proxima-hora  { font-size: 1.8rem; font-weight: 700; margin: 4px 0; }
.proxima-pac   { opacity: .85; font-size: .9rem; }

/* ── Tratamientos check ───────────────────────────────────── */
.tratamiento-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
}

.tratamiento-check:hover { border-color: var(--teal); background: var(--teal-soft); }
.tratamiento-check.selected { border-color: var(--teal); background: var(--teal-soft); }

.tratamiento-check input { margin-top: 2px; accent-color: var(--teal); }

.trat-nombre  { font-weight: 600; font-size: .88rem; }
.trat-desc    { font-size: .78rem; color: var(--gray-500); }
.trat-precio  { font-size: .82rem; color: var(--teal-dark); font-weight: 600; margin-left: auto; white-space: nowrap; }

/* ── Historial timeline ───────────────────────────────────── */
.timeline { position: relative; padding-left: 28px; }

.timeline::before {
  content: '';
  position: absolute;
  left: 9px; top: 0; bottom: 0;
  width: 2px;
  background: var(--gray-200);
}

.timeline-item { position: relative; margin-bottom: 24px; }

.timeline-dot {
  position: absolute;
  left: -23px; top: 3px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--teal);
}

.timeline-date { font-size: .75rem; color: var(--gray-400); font-weight: 600; margin-bottom: 6px; }

.timeline-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.timeline-card:hover { border-color: var(--gray-300); box-shadow: var(--shadow); }

/* ── Auth layout ──────────────────────────────────────────── */
.auth-layout {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 60%, #1e4080 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: #fff;
  border-radius: 18px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo .logo-icon {
  width: 56px; height: 56px;
  background: var(--teal);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  color: #fff;
  margin: 0 auto 12px;
}

.auth-logo h1 { font-size: 1.35rem; font-weight: 700; color: var(--navy); margin: 0; }
.auth-logo p  { font-size: .85rem; color: var(--gray-400); margin: 4px 0 0; }

/* ── FullCalendar overrides ───────────────────────────────── */
.fc { font-family: 'DM Sans', sans-serif; }
.fc .fc-toolbar-title { font-size: 1.1rem !important; font-weight: 700; }
.fc .fc-button-primary { background: var(--navy) !important; border-color: var(--navy) !important; border-radius: 7px !important; }
.fc .fc-button-primary:hover { background: var(--teal) !important; border-color: var(--teal) !important; }
.fc .fc-event { border-radius: 5px !important; border: none !important; font-size: .8rem !important; }
.fc .fc-daygrid-day:hover .fc-daygrid-day-number { color: var(--teal); }

/* ── Búsqueda ─────────────────────────────────────────────── */
.search-bar {
  position: relative;
}

.search-bar input {
  padding-left: 38px;
}

.search-bar i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: .9rem;
  pointer-events: none;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}

.empty-state i { font-size: 2.5rem; margin-bottom: 14px; display: block; }
.empty-state p { font-size: .9rem; }

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .btn-toggle-sidebar { display: flex; }
  .page-content { padding: 18px; }
  .topbar { padding: 0 18px; }
}

@media (max-width: 576px) {
  .topbar-actions .btn { display: none; }
  .patient-header { flex-wrap: wrap; }
  .patient-badge { margin-left: 0; }
}

/* ── Utilidades ───────────────────────────────────────────── */
.text-navy  { color: var(--navy) !important; }
.text-teal  { color: var(--teal) !important; }
.bg-teal-soft { background: var(--teal-soft) !important; }
.fw-600 { font-weight: 600 !important; }
.rounded-lg { border-radius: var(--radius) !important; }
