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

:root {
  --cream:        #F5F2FF;
  --cream-dark:   #EDE8FC;
  --white:        #ffffff;
  --primary-dark: #1A0E30;
  --primary:      #7C3AED;
  --primary-mid:  #6D28D9;
  --primary-light:#DDD6FE;
  --primary-pale: #EDE9FE;
  --beige:        #E2D9F8;
  --beige-light:  #EDE9FE;
  --beige-mid:    #CFC3F5;
  --text:         #18181B;
  --text-mid:     #3A3A4E;
  --text-muted:   #7272A0;
  --border:       #E4DCFB;
  --border-dark:  #CFC3F5;
  --warning-bg:   #fdf0dc;
  --warning-text: #8a4a10;
  --danger-bg:    #fce8e8;
  --danger-text:  #8a1818;
  --info-bg:      #e0ecf8;
  --info-text:    #1a3a6a;
  /* Sidebar / green palette */
  --green-dark:   #1a2332;
  --green:        #2d6a4f;
  --green-mid:    #3a7a60;
  --green-light:  #a8d5ba;
  --green-pale:   #f0f8f4;
}

/* ── DARK MODE VARIABLES ── */
[data-theme="dark"] {
  --cream:        #13111f;
  --cream-dark:   #1c1a2e;
  --white:        #1e1b30;
  --primary-dark: #EDE9FE;
  --primary-light:#4C1D95;
  --primary-pale: #2e1f5e;
  --beige:        #2a2440;
  --beige-light:  #231d38;
  --beige-mid:    #332b50;
  --text:         #F4F4F8;
  --text-mid:     #C4C4D8;
  --text-muted:   #8888AA;
  --border:       #2e2a48;
  --border-dark:  #3d3660;
  --warning-bg:   #2a1f0a;
  --warning-text: #f5c87a;
  --danger-bg:    #2a0f0f;
  --danger-text:  #f87171;
  --info-bg:      #0f1e33;
  --info-text:    #93c5fd;
}
[data-theme="dark"] body { background: var(--cream); }
[data-theme="dark"] .sidebar { background: #0d0b1a; }
[data-theme="dark"] .topbar { background: var(--white); border-bottom-color: var(--border); }
[data-theme="dark"] .card { background: var(--white) !important; border-color: var(--border) !important; }
[data-theme="dark"] .stat-card { background: var(--white) !important; border-color: var(--border) !important; }
[data-theme="dark"] .input,
[data-theme="dark"] .select { background: var(--beige-light) !important; border-color: var(--border) !important; color: var(--text) !important; }
[data-theme="dark"] .search-box { background: var(--beige-light); border-color: var(--border); }
[data-theme="dark"] .icon-btn { background: var(--beige-light); border-color: var(--border); }
[data-theme="dark"] .modal { background: var(--white) !important; border-color: var(--border) !important; }
[data-theme="dark"] .table tr:hover td { background: var(--beige-light); }
[data-theme="dark"] .table td { border-bottom-color: var(--border); color: var(--text); }
[data-theme="dark"] .table th { color: var(--text-muted); border-bottom-color: var(--border); }
[data-theme="dark"] .mobile-bottom-nav { background: #0d0b1a; }
[data-theme="dark"] .btn-beige { background: var(--beige-light) !important; color: var(--text) !important; border-color: var(--border) !important; }
[data-theme="dark"] .progress-bar { background: var(--beige) !important; }

/* ── DARK MODE — PAGE-SPECIFIC CLASS OVERRIDES (need !important, page CSS loads after) ── */
/* Tab bars across all pages */
[data-theme="dark"] .tab-bar { background: var(--beige-light) !important; }
[data-theme="dark"] .tab-btn { color: var(--text-muted) !important; }
[data-theme="dark"] .tab-btn.active { background: var(--primary) !important; color: #fff !important; box-shadow: none !important; }
[data-theme="dark"] .tab-btn:hover:not(.active) { background: var(--beige) !important; color: var(--text) !important; }

/* Page-local card classes */
[data-theme="dark"] .plan-card   { background: var(--white) !important; border-color: var(--border) !important; }
[data-theme="dark"] .kpi-card    { background: var(--white) !important; border-color: var(--border) !important; }
[data-theme="dark"] .report-card { background: var(--white) !important; border-color: var(--border) !important; }
[data-theme="dark"] .config-section { background: var(--white) !important; border-color: var(--border) !important; }
[data-theme="dark"] .config-row { border-bottom-color: var(--border) !important; }
[data-theme="dark"] .config-row-label { color: var(--text) !important; }
[data-theme="dark"] .config-row-sub  { color: var(--text-muted) !important; }

/* Status chips in pagos */
[data-theme="dark"] .status-paid    { background: #0d2b1d !important; color: #4ade80 !important; }
[data-theme="dark"] .status-pending { background: #2a200a !important; color: #fcd34d !important; }
[data-theme="dark"] .status-overdue { background: var(--danger-bg) !important; color: var(--danger-text) !important; }

/* Period buttons in reportes */
[data-theme="dark"] .period-btn { color: var(--text-muted) !important; background: transparent !important; }
[data-theme="dark"] .period-btn.active { background: var(--primary) !important; color: #fff !important; }

/* Inline hardcoded backgrounds that bleed through */
[data-theme="dark"] [style*="background:#f5f0e8"],
[data-theme="dark"] [style*="background:#fdfaf5"],
[data-theme="dark"] [style*="background:#fdf0dc"],
[data-theme="dark"] [style*="background:#f5f2ff"],
[data-theme="dark"] [style*="background:#fdfaff"],
[data-theme="dark"] [style*="background:#F5F2FF"] {
  background: var(--beige-light) !important;
}
[data-theme="dark"] [style*="background:#fff;"],
[data-theme="dark"] [style*="background: #fff;"],
[data-theme="dark"] [style*="background:#ffffff"] {
  background: var(--white) !important;
}
/* Alert/warning sections */
[data-theme="dark"] [style*="background:linear-gradient(135deg,#fdf0dc"],
[data-theme="dark"] [style*="background:linear-gradient(135deg, #fdf0dc"] {
  background: var(--warning-bg) !important;
  border-color: var(--border) !important;
}
/* Text in dark mode — fix hardcoded colors */
[data-theme="dark"] [style*="color:#1A0E30"],
[data-theme="dark"] [style*="color: #1A0E30"],
[data-theme="dark"] [style*="color:#18181B"] { color: var(--text) !important; }
[data-theme="dark"] [style*="color:#6a7a6e"],
[data-theme="dark"] [style*="color:#8a9a8e"],
[data-theme="dark"] [style*="color:#7272A0"],
[data-theme="dark"] [style*="color:#aaa"]    { color: var(--text-muted) !important; }
[data-theme="dark"] [style*="color:#52525B"] { color: var(--text-mid) !important; }

/* Toggle slider in dark mode */
[data-theme="dark"] .toggle-slider { background: var(--beige) !important; }
[data-theme="dark"] .toggle input:checked + .toggle-slider { background: var(--primary) !important; }

/* Step indicators */
[data-theme="dark"] .step.pending { background: var(--beige-light) !important; color: var(--text-muted) !important; }
[data-theme="dark"] .step-line { background: var(--border) !important; }

/* ── DARK MODE TOGGLE BUTTON ── */
.dark-toggle-btn {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--cream); border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s; flex-shrink: 0;
  font-size: 16px; line-height: 1;
}
.dark-toggle-btn:hover { background: var(--beige-light); }

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--cream); color: var(--text); }
a { text-decoration: none; color: inherit; }

/* ── LAYOUT ── */
.layout { display: flex; height: 100vh; overflow: hidden; }
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.page-content { flex: 1; overflow-y: auto; padding: 28px 28px; }

/* ── SIDEBAR ── */
.sidebar {
  width: 220px;
  background: var(--green-dark);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
}
.sidebar-logo {
  padding: 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 9px;
}
.sidebar-logo-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(167,139,250,0.15);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo-text { font-weight: 800; font-size: 14px; color: #fff; letter-spacing: -0.3px; }
.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-section-label {
  font-size: 9px; font-weight: 700;
  color: rgba(255,255,255,0.50);
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 14px 8px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: #e2e8f0;
  cursor: pointer; text-decoration: none;
  transition: all .15s;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.10); color: #fff; }
.nav-item.active { background: var(--green); color: #fff; font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.nav-item svg { opacity: 0.75; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 99px;
}
.nav-badge-green { background: rgba(45,106,79,0.6); color: #a8d5ba; }
.nav-badge-red { background: rgba(180,40,40,0.5); color: #f8c8c8; }
.sidebar-profile {
  padding: 10px 8px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.profile-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; transition: background .15s;
}
.profile-btn:hover { background: rgba(255,255,255,0.06); }
.profile-name { font-size: 12px; font-weight: 600; color: #DDD6FE; }
.profile-plan { font-size: 10px; color: rgba(255,255,255,0.35); }
.profile-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(167,139,250,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #C4B5FD;
  flex-shrink: 0;
}

/* ── TOPBAR ── */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.topbar-title { font-size: 13px; font-weight: 600; color: var(--text); }
.topbar-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--cream); border: 1.5px solid var(--border);
  border-radius: 9px; padding: 6px 12px;
  font-size: 12px; color: var(--text-muted);
  cursor: pointer; width: 200px;
}
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--cream); border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s; position: relative;
}
.icon-btn:hover { background: var(--beige-light); }
.notif-dot {
  width: 7px; height: 7px; background: #dc3030;
  border-radius: 50%; position: absolute; top: 4px; right: 4px;
  border: 1.5px solid white;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600;
  padding: 8px 18px; border-radius: 99px;
  cursor: pointer; transition: all .15s;
  text-decoration: none; border: none;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, #7C3AED 0%, #DB2777 100%); color: #fff; }
.btn-primary:hover { background: #6D28D9; }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-pale); }
.btn-beige { background: var(--beige-light); color: var(--text); border: 1px solid var(--border); }
.btn-beige:hover { background: var(--beige); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--beige-light); }
.btn-sm { font-size: 11px; padding: 5px 12px; }
.btn-lg { font-size: 15px; padding: 12px 28px; }
.btn-danger { background: #c83030; color: #fff; }

/* ── CARDS ── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}
.card-sm { padding: 14px 16px; border-radius: 11px; }
.card-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.card-sub { font-size: 12px; color: var(--text-muted); }

/* ── STAT CARDS ── */
.stat-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 20px;
}
.stat-label { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-change { font-size: 11px; font-weight: 600; margin-top: 6px; }
.stat-up { color: #059669; }
.stat-neutral { color: var(--text-muted); }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
}
.badge-green  { background: var(--primary-light); color: #3B0764; }
.badge-amber  { background: var(--warning-bg); color: var(--warning-text); }
.badge-red    { background: var(--danger-bg); color: var(--danger-text); }
.badge-blue   { background: var(--info-bg); color: var(--info-text); }
.badge-beige  { background: var(--beige-light); color: var(--text-mid); }

/* ── AVATAR ── */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.av-green { background: #DDD6FE; color: #3B0764; }
.av-blue  { background: #d0e0f8; color: #1a3a7a; }
.av-amber { background: #fce8c8; color: #7a4010; }
.av-purple{ background: #e8d8f8; color: #4a1a8a; }
.av-pink  { background: #f8d8e8; color: #8a1a4a; }
.av-teal  { background: #E9D5FF; color: #4C1D95; }
.av-red   { background: #f8d8d8; color: #8a1a1a; }

/* ── TABLE ── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-align: left; padding: 8px 12px;
  border-bottom: 1.5px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.table td {
  font-size: 13px; padding: 11px 12px;
  border-bottom: 1px solid var(--cream-dark);
  vertical-align: middle; color: var(--text);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--cream); }
.table-clickable tbody tr { cursor: pointer; }

/* ── PROGRESS ── */
.progress-bar { height: 6px; border-radius: 99px; background: var(--beige); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: var(--primary); }
.progress-warn { background: #d4880a; }
.progress-danger { background: #c83030; }

/* ── FORM ── */
.form-group { margin-bottom: 16px; }
.label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-mid); margin-bottom: 5px;
}
.input {
  width: 100%; border: 1.5px solid var(--border);
  border-radius: 10px; padding: 10px 14px;
  font-size: 13px; font-family: 'Inter', sans-serif;
  background: var(--cream); color: var(--text); outline: none;
  transition: border-color .15s, background .15s;
}
.input:focus { border-color: var(--primary); background: var(--white); box-shadow: 0 0 0 3px rgba(124,58,237,0.10); }
.input::placeholder { color: var(--text-muted); }
.select {
  width: 100%; border: 1.5px solid var(--border);
  border-radius: 10px; padding: 10px 14px;
  font-size: 13px; font-family: 'Inter', sans-serif;
  background: var(--cream); color: var(--text); outline: none;
  appearance: none; cursor: pointer;
}

/* ── MISC ── */
.section-tag {
  display: inline-block; background: var(--primary-light); color: var(--primary);
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 3px 10px; border-radius: 99px; margin-bottom: 10px;
}
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.page-header { margin-bottom: 22px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.page-title { font-size: 20px; font-weight: 800; color: var(--text); }
.page-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state p { font-size: 13px; margin-top: 8px; }

/* ── MOBILE NAV BUTTON (hamburger) ── */
.mobile-menu-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: var(--cream); border: 1.5px solid var(--border);
  border-radius: 9px; cursor: pointer; flex-shrink: 0;
}

/* ── SIDEBAR OVERLAY (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 190;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

/* ── MOBILE BOTTOM NAV ── */
.mobile-bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--green-dark);
  border-top: 1px solid rgba(255,255,255,0.08);
  z-index: 150;
  padding: 0 2px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.mobile-bottom-nav-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  padding: 8px 2px 10px;
  color: rgba(255,255,255,0.45);
  font-size: 9px; font-weight: 600;
  text-decoration: none;
  transition: color 0.15s;
  text-align: center; line-height: 1.2;
}
.mobile-bottom-nav-item.active,
.mobile-bottom-nav-item:hover { color: #fff; }
.mobile-bottom-nav-item.active svg { opacity: 1; }
.mobile-bottom-nav-item svg { opacity: 0.6; }

/* ── RESPONSIVE BREAKPOINT ── */
@media (max-width: 768px) {

  /* Sidebar: off-canvas overlay */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.35);
  }

  /* Main area takes full width */
  .layout { overflow-x: hidden; }
  .main-area { width: 100vw; min-width: 0; overflow: hidden; }

  /* Reduce padding */
  .page-content { padding: 14px 14px 84px; }
  .topbar { padding: 10px 14px; }

  /* Show hamburger, hide search */
  .mobile-menu-btn { display: flex; }
  .search-box { display: none !important; }

  /* Page header stacks */
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
  .page-title { font-size: 17px; }

  /* Stat grids: 2 columns on mobile */
  .page-content > div[style*="grid-template-columns"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* 2-col form grids inside cards/modals → 1 col */
  .card > div[style*="grid-template-columns:1fr 1fr"],
  .modal > div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns:1fr 1fr"][style*="gap:14"],
  div[style*="grid-template-columns:1fr 1fr"][style*="gap:16"] {
    grid-template-columns: 1fr !important;
  }

  /* Tables: horizontal scroll */
  .card { overflow-x: auto; }
  .table { min-width: 480px; }

  /* Topbar: wrap actions on small screens */
  .topbar { flex-wrap: wrap; gap: 8px; }
  .topbar-actions { flex-wrap: wrap; gap: 6px; }
  .topbar > div:first-child { flex: 1; min-width: 0; }

  /* Modals: slide up from bottom */
  .modal-overlay { align-items: flex-end !important; padding: 0 !important; }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 92vh !important;
    margin: 0 !important;
    overflow-y: auto !important;
  }

  /* Bottom nav visible */
  .mobile-bottom-nav { display: flex; }

  /* Icon buttons: smaller */
  .icon-btn { width: 30px; height: 30px; border-radius: 8px; }
  .dark-toggle-btn { width: 30px; height: 30px; border-radius: 8px; }

  /* Stat values slightly smaller */
  .stat-value { font-size: 22px; }
  .stat-card { padding: 14px; }

  /* Buttons in topbar: hide text labels on very small */
  .btn.btn-sm .btn-label { display: none; }

  /* Plan cards grid → 1 col */
  #planes-grid { grid-template-columns: 1fr !important; }

  /* Citas layout: sidebar panel hidden, week takes full width */
  .citas-layout { grid-template-columns: 1fr !important; }
  .mini-cal-panel { display: none !important; }

  /* Tab bars horizontal scroll on mobile */
  .tab-bar { overflow-x: auto; flex-wrap: nowrap !important; }
  .tab-btn  { white-space: nowrap; flex-shrink: 0; }

  /* Config sections: form grids single col */
  .config-section div[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  .config-section div[style*="grid-template-columns:repeat(3"] { grid-template-columns: 1fr !important; }
}

@media (max-width: 400px) {
  .page-content > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  .stat-value { font-size: 20px; }
  /* Topbar: hide subtitle on very small screens */
  .topbar-sub { display: none; }
}
