/* ============================================================
   DOCTOR PIES — Sistema de Gestión Integral
   main.css
   ============================================================ */

/* ─── Variables ─────────────────────────────────────────── */
:root {
  --primary:      #1B3A6B;
  --primary-mid:  #2E5FA3;
  --accent:       #00B4D8;
  --gold:         #F59E0B;
  --success:      #0D9488;
  --danger:       #EF4444;
  --warning:      #F59E0B;
  --purple:       #8B5CF6;

  --bg:           #F0F4FA;
  --surface:      #FFFFFF;
  --surface-2:    #F8FAFC;
  --border:       #E2E8F0;
  --border-dark:  #CBD5E1;

  --text-primary: #1A1A2E;
  --text-secondary:#64748B;
  --text-muted:   #94A3B8;

  --sidebar-w:    256px;
  --topbar-h:     60px;

  --radius:       10px;
  --radius-lg:    16px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
  --shadow-md:    0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:    0 8px 24px rgba(0,0,0,.12);

  --transition:   0.2s ease;
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--text-primary); background: var(--bg); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }

/* ─── LOGIN PAGE ──────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0F2342 0%, #1B3A6B 50%, #2E5FA3 100%); }

.login-container {
  display: flex;
  width: 900px;
  max-width: 95vw;
  min-height: 560px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

/* Branding panel */
.login-brand {
  flex: 1;
  background: rgba(255,255,255,.05);
  backdrop-filter: blur(10px);
  border-right: 1px solid rgba(255,255,255,.12);
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
}
.brand-content { display: flex; flex-direction: column; gap: 16px; }
.brand-logo { width: 64px; height: 64px; }
.login-brand h1 { font-size: 28px; font-weight: 700; color: #fff; }
.brand-tagline { font-size: 13px; color: rgba(255,255,255,.6); margin-top: -8px; }
.brand-features { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.feature-item { display: flex; align-items: center; gap: 10px; font-size: 13px; color: rgba(255,255,255,.8); }
.feat-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.brand-footer { font-size: 11px; color: rgba(255,255,255,.4); }

/* Form panel */
.login-form-panel {
  width: 380px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
}
.login-form-wrapper { width: 100%; }
.login-form-wrapper h2 { font-size: 22px; font-weight: 700; color: var(--primary); }
.login-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 4px; margin-bottom: 28px; }

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.form-group input {
  height: 42px; padding: 0 12px;
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-2);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus { outline: none; border-color: var(--primary-mid); box-shadow: 0 0 0 3px rgba(46,95,163,.15); }
.field-error { font-size: 11px; color: var(--danger); min-height: 14px; }

.input-password { position: relative; }
.input-password input { width: 100%; padding-right: 42px; }
.toggle-pass { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); padding: 4px; }
.toggle-pass:hover { color: var(--primary); }
.toggle-pass svg { width: 18px; height: 18px; }

.btn-login {
  width: 100%; height: 44px;
  background: var(--primary);
  color: #fff; font-size: 15px; font-weight: 600;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 8px;
  transition: background var(--transition), transform var(--transition);
}
.btn-login:hover { background: var(--primary-mid); }
.btn-login:active { transform: scale(.98); }
.btn-login:disabled { opacity: .6; cursor: not-allowed; }

.login-help { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 20px; }

/* ─── ALERTS ──────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.alert-error { background: #FEF2F2; border: 1px solid #FECACA; color: #B91C1C; }
.alert-success { background: #F0FDF4; border: 1px solid #BBF7D0; color: #15803D; }

/* ─── SPINNER ─────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── APP LAYOUT ──────────────────────────────────────────── */
.app-page { display: flex; min-height: 100vh; }

/* ─── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  /* Altura fija a la pantalla: el menú hace scroll y el bloque de usuario
     (cerrar sesión) queda siempre visible abajo */
  height: 100vh;
  height: 100dvh;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .sidebar-sede,
.sidebar.collapsed .user-info { display: none; }
.sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; }
.sidebar-title { font-size: 15px; font-weight: 700; color: #fff; white-space: nowrap; }
.sidebar-toggle { color: rgba(255,255,255,.5); padding: 4px; border-radius: 6px; transition: color var(--transition); }
.sidebar-toggle:hover { color: #fff; background: rgba(255,255,255,.1); }

.sidebar-sede {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  font-size: 11px; color: rgba(255,255,255,.6);
  background: rgba(0,0,0,.15);
  white-space: nowrap; overflow: hidden;
}
.sede-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

.sidebar-header, .sidebar-sede, .sidebar-bottom { flex-shrink: 0; }
.sidebar-nav {
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.25) transparent;
  padding: 8px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.4); }

.nav-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: .08em;
  color: rgba(255,255,255,.4);
  padding: 12px 16px 4px;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 16px;
  color: rgba(255,255,255,.7);
  font-size: 13px; font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.15); color: #fff; border-left: 3px solid var(--accent); }
.nav-item svg { flex-shrink: 0; }

.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.1);
  background: rgba(0,0,0,.12);
}
.user-card { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: rgba(255,255,255,.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-logout { color: rgba(255,255,255,.5); padding: 6px; border-radius: 6px; transition: color var(--transition); }
.btn-logout:hover { color: var(--danger); background: rgba(239,68,68,.15); }

/* ─── MAIN CONTENT ────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  transition: margin-left var(--transition);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
body.sidebar-collapsed .main-content { margin-left: 64px; }

/* ─── TOPBAR ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.page-title { font-size: 17px; font-weight: 700; color: var(--primary); }
.btn-mobile-menu { display: none; color: var(--text-secondary); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-sede { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); background: var(--surface-2); padding: 4px 12px; border-radius: 20px; border: 1px solid var(--border); }
.notif-btn { position: relative; color: var(--text-secondary); padding: 6px; cursor: pointer; }
.notif-btn:hover { color: var(--primary); }
.notif-badge { position: absolute; top: 0; right: 0; background: var(--danger); color: #fff; font-size: 9px; font-weight: 700; border-radius: 50%; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; }

/* ─── MODULE CONTAINER ───────────────────────────────────── */
.module-container { flex: 1; padding: 24px; }

/* ─── KPI GRID ───────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 20px 24px; display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid transparent;
  transition: transform var(--transition), box-shadow var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-blue  { border-left-color: var(--primary-mid); }
.kpi-green { border-left-color: var(--success); }
.kpi-purple{ border-left-color: var(--purple); }
.kpi-gold  { border-left-color: var(--gold); }
.kpi-icon  { font-size: 22px; margin-bottom: 4px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.kpi-label { font-size: 12px; color: var(--text-secondary); }

/* ─── DASHBOARD GRID ──────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-card { background: var(--surface); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.card-title { font-size: 14px; font-weight: 700; color: var(--primary); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }

/* Citas list */
.citas-list { display: flex; flex-direction: column; gap: 10px; }
.cita-item { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--surface-2); border-radius: var(--radius); }
.cita-hora { font-size: 13px; font-weight: 700; color: var(--primary-mid); min-width: 50px; }
.cita-info { flex: 1; }
.cita-paciente { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.cita-podologo { font-size: 11px; color: var(--text-muted); }
.cita-estado { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.estado-agendada  { background: #EFF6FF; color: #1D4ED8; }
.estado-confirmada{ background: #F0FDF4; color: #15803D; }
.estado-atendida  { background: #F5F3FF; color: #6D28D9; }

/* Empty state */
.empty-state { text-align: center; color: var(--text-muted); font-size: 13px; padding: 20px 0; }

/* ─── BUTTONS ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 600; cursor: pointer; transition: all var(--transition); }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-mid); }
.btn-secondary { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border-dark); }
.btn-secondary:hover { background: var(--border); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-sm        { padding: 5px 12px; font-size: 12px; }

/* ─── TABLES ──────────────────────────────────────────────── */
.table-wrap { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th { background: var(--surface-2); font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .05em; padding: 12px 16px; text-align: left; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-primary); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ─── MODALS ──────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: all .2s; }
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 500px; max-width: 95vw; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); transform: translateY(20px); transition: transform .2s; }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 16px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 16px; font-weight: 700; color: var(--primary); }
.modal-close { color: var(--text-muted); }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ─── FORM STYLES ─────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
label.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-primary); margin-bottom: 5px; }
.form-control {
  width: 100%; height: 38px; padding: 0 10px;
  border: 1.5px solid var(--border-dark); border-radius: 8px;
  font-size: 13px; background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--primary-mid); box-shadow: 0 0 0 3px rgba(46,95,163,.12); }
textarea.form-control { height: 80px; padding: 8px 10px; resize: vertical; }

/* ─── STATUS BADGES ───────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-success { background: #DCFCE7; color: #15803D; }
.badge-warning { background: #FEF9C3; color: #854D0E; }
.badge-danger  { background: #FEE2E2; color: #B91C1C; }
.badge-info    { background: #E0F2FE; color: #0369A1; }
.badge-gray    { background: #F1F5F9; color: #475569; }

/* ─── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .btn-mobile-menu { display: flex; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-form-panel { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ─── LOGO ───────────────────────────────────────────────── */
.brand-logo-img {
  width: 260px;
  max-width: 100%;
  background: white;
  padding: 14px 20px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  display: block;
}

.sidebar-logo-img {
  width: 150px;
  max-width: 100%;
  background: white;
  padding: 6px 12px;
  border-radius: 8px;
  object-fit: contain;
  display: block;
}

.sidebar.collapsed .sidebar-logo-img { display: none; }

/* ─── SEDES GRID (dashboard admin) ──────────────────────── */
.sedes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.sede-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border-top: 4px solid var(--primary-mid);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
.sede-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.sede-card.activa { border-top-color: var(--accent); }

.sede-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.sede-card-name { font-size: 15px; font-weight: 700; color: var(--primary); }
.sede-card-status { font-size: 10px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.status-activa   { background: #DCFCE7; color: #15803D; }
.status-inactiva { background: #F1F5F9; color: #64748B; }

.sede-card-stats { display: flex; flex-direction: column; gap: 8px; }
.sede-stat { display: flex; justify-content: space-between; align-items: center; }
.sede-stat-label { font-size: 12px; color: var(--text-secondary); }
.sede-stat-value { font-size: 13px; font-weight: 700; color: var(--primary); }

.sede-card-footer {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* ─── FILTRO SEDES ────────────────────────────────────────── */
.sede-filter-btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border-dark);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.sede-filter-btn:hover { border-color: var(--primary-mid); color: var(--primary); }
.sede-filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
