/* ============================================================
   Gestor Personal — Design System
   Referencia: Linear (filosofía visual + densidad), Notion Calendar
   (calendario), Akiflow/Sunsama (agenda), patrones Mobbin (cards,
   dashboards). Tailwind se carga vía CDN (sin build step); este
   archivo define tokens propios + componentes reutilizables, y
   además re-tematiza las clases Tailwind ya usadas en las vistas
   existentes para que hereden la paleta sin editar archivo por
   archivo.
   ============================================================ */

/* ---------- 1. TOKENS ---------- */
:root {
    /* Superficies: cada capa un poco más clara que la anterior, sin
       saltos fuertes — así se logra profundidad sin bordes gritones. */
    --bg: #08090C;
    --bg-alt: #08090C;
    --sidebar: #0A0B0F;
    --sidebar-alt: #131419;
    --header: #08090C;
    --surface: #0D0E13;
    --surface-alt: #131419;
    --surface-hover: #181A21;
    --surface-elevated: #1B1D25;
    --border: rgba(255,255,255,.07);
    --border-strong: rgba(255,255,255,.12);

    /* Acento: violeta/índigo tipo Linear, no el azul genérico de
       Bootstrap. Se usa SOLO para acción primaria/selección/foco. */
    --brand: #5E6AD2;
    --brand-active: #6E7AE8;
    --brand-selected: rgba(94,106,210,.16);
    --brand-rgb: 94, 106, 210;

    --text: rgba(255,255,255,.92);
    --text-muted: rgba(255,255,255,.58);
    --text-faint: rgba(255,255,255,.38);

    --green: #4CC38A;
    --green-text: #5FE3A6;
    --amber: #E5A23C;
    --amber-text: #F2B953;
    --red: #E5484D;
    --red-text: #F87171;
    --violet: #9D7BEA;
    --violet-text: #B8A4F0;
    --cyan: #4DBFDB;
    --cyan-text: #67D3EE;
    --orange: #E8955A;
    --orange-text: #F0A96E;
    --pink: #E074A8;
    --pink-text: #ED8FBC;

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow: 0 8px 24px rgba(0,0,0,.36);
    --shadow-lg: 0 16px 48px rgba(0,0,0,.5);

    --ease: 140ms cubic-bezier(.4,0,.2,1);
    --ease-slow: 200ms cubic-bezier(.4,0,.2,1);

    --font-sans: Inter, Geist, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

    --sidebar-w: 224px;
    --sidebar-w-collapsed: 60px;
    --topbar-h: 52px;
}

html.light {
    --bg: #F7F7F8;
    --bg-alt: #F0F0F2;
    --sidebar: #FBFBFC;
    --sidebar-alt: #F0F0F2;
    --header: #FBFBFC;
    --surface: #FFFFFF;
    --surface-alt: #F5F5F6;
    --surface-hover: #EEEEF0;
    --surface-elevated: #FFFFFF;
    --border: rgba(15,15,20,.08);
    --border-strong: rgba(15,15,20,.14);

    --brand-selected: rgba(94,106,210,.10);

    --text: rgba(15,15,20,.92);
    --text-muted: rgba(15,15,20,.58);
    --text-faint: rgba(15,15,20,.40);

    --shadow-sm: 0 1px 2px rgba(15,15,20,.05);
    --shadow: 0 8px 24px rgba(15,15,20,.08);
    --shadow-lg: 0 16px 48px rgba(15,15,20,.12);
}

/* ---------- 2. BASE ---------- */
html, body { background: var(--bg); }
body { font-family: var(--font-sans); color: var(--text); -webkit-font-smoothing: antialiased; }

* { scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

/* Salvaguarda: si alguna vista no editada conserva data-aos de AOS.js
   (ya no se inicializa), que el contenido nunca quede invisible. */
[data-aos] { opacity: 1 !important; transform: none !important; }

a { transition: color var(--ease); }
button, .btn, .nav-item, .tab, input, select, textarea {
    transition: background-color var(--ease), border-color var(--ease), color var(--ease), opacity var(--ease), transform var(--ease), box-shadow var(--ease);
    font-family: var(--font-sans);
}

/* Foco visible consistente para navegación por teclado, sin depender
   del outline nativo del navegador (que no respeta los radius). */
:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px rgba(var(--brand-rgb), .55); border-radius: var(--radius-sm); }
.btn:focus-visible, .btn-icon:focus-visible, .input:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .28); }

.section-title {
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-faint);
}

h1, h2, h3, .page-title, .card-header h3 { letter-spacing: -.01em; }

/* ---------- 3. LAYOUT SHELL ---------- */
.app-shell { display: flex; height: 100vh; overflow: hidden; background: var(--bg); }

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--ease-slow), transform var(--ease-slow);
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
    display: flex; align-items: center; gap: 9px;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    flex-shrink: 0; min-height: 52px;
}
.sidebar-brand-mark {
    width: 22px; height: 22px; border-radius: 6px;
    background: var(--brand); display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 11px; flex-shrink: 0;
}
.sidebar-brand-text { min-width: 0; overflow: hidden; }
.sidebar-brand-text p:first-child { font-weight: 600; font-size: 13px; color: var(--text); white-space: nowrap; letter-spacing: -.01em; }
.sidebar-brand-text p:last-child { font-size: 11px; color: var(--text-faint); white-space: nowrap; }
.sidebar.collapsed .sidebar-brand-text { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 14px 0; }

.sidebar-user {
    display: flex; align-items: center; gap: 9px;
    padding: 10px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-user-avatar {
    width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0;
    background: var(--surface-elevated); border: 1px solid var(--border-strong); color: var(--text); font-size: 10.5px; font-weight: 600;
    display: flex; align-items: center; justify-content: center;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-info p:first-child { font-size: 12.5px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-status { font-size: 10px; color: var(--text-faint); display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.sidebar-user-status::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .sidebar-user-info { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 10px 12px; }
.nav-group + .nav-group { margin-top: 14px; }
.nav-group-title { padding: 8px 8px 5px; }
.sidebar.collapsed .nav-group-title { display: none; }

.nav-item {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    height: 32px; padding: 0 9px; margin-bottom: 1px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 450;
    color: var(--text-muted);
    white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--brand-selected); color: var(--text); font-weight: 500; }
.nav-item.active .nav-icon { color: var(--brand-active); }
.nav-item.active::before {
    content: ''; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 2px;
    border-radius: 2px; background: var(--brand);
}
.sidebar:not(.collapsed) .nav-item.active::before { left: 0; }
.nav-item .nav-icon { width: 15px; text-align: center; flex-shrink: 0; font-size: 13px; color: var(--text-faint); }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0; }
.sidebar.collapsed .nav-item .nav-label { display: none; }
.sidebar.collapsed .nav-item.active::before { left: 0; }

/* Tooltip nativo del sidebar colapsado: aparece al instante (no el
   delay del navegador), a la derecha del ícono. */
.sidebar.collapsed .nav-item { position: relative; }
.sidebar.collapsed .nav-item[data-label]::after {
    content: attr(data-label);
    position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%) translateX(-4px);
    background: var(--surface-elevated); color: var(--text); border: 1px solid var(--border-strong);
    padding: 5px 9px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; white-space: nowrap;
    box-shadow: var(--shadow); pointer-events: none; opacity: 0; z-index: 100;
    transition: opacity var(--ease), transform var(--ease);
}
.sidebar.collapsed .nav-item[data-label]:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }

.sidebar-footer { border-top: 1px solid var(--border); padding: 8px 10px; flex-shrink: 0; }
.sidebar-footer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px; height: 30px; }
.sidebar-footer-label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 450; color: var(--text-muted); white-space: nowrap; }
.sidebar.collapsed .sidebar-footer-label span { display: none; }
.sidebar.collapsed .sidebar-footer-row { justify-content: center; }

.theme-switch { position: relative; width: 30px; height: 17px; border-radius: 999px; background: var(--surface-elevated); border: 1px solid var(--border-strong); flex-shrink: 0; cursor: pointer; }
.theme-switch::after { content: ''; position: absolute; top: 1px; left: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--text-muted); transition: transform var(--ease), background var(--ease); }
.theme-switch.on { background: var(--brand-selected); border-color: rgba(var(--brand-rgb),.4); }
.theme-switch.on::after { transform: translateX(13px); background: var(--brand); }
.sidebar.collapsed .theme-switch { display: none; }

.sidebar-collapse-btn {
    width: 20px; height: 20px; border-radius: 50%; background: var(--surface-elevated);
    border: 1px solid var(--border-strong); color: var(--text-faint);
    display: flex; align-items: center; justify-content: center; font-size: 9px;
    position: absolute; top: 18px; right: -10px; z-index: 5; cursor: pointer;
    opacity: 0; transition: opacity var(--ease), color var(--ease);
}
.sidebar:hover .sidebar-collapse-btn { opacity: 1; }
.sidebar-collapse-btn:hover { color: var(--text); }
.sidebar.collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }

/* Main column */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

.topbar {
    height: var(--topbar-h); flex-shrink: 0;
    background: var(--header); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px; padding: 0 18px;
}
.topbar-title { font-size: 13.5px; font-weight: 600; color: var(--text); line-height: 1.2; letter-spacing: -.01em; }
.topbar-date { font-size: 11px; color: var(--text-faint); margin-top: 1px; text-transform: capitalize; }

.search-box { position: relative; flex: 1; max-width: 360px; }
.search-box input {
    width: 100%; height: 32px; padding: 0 46px 0 32px; font-size: 12.5px;
    background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); outline: none;
}
.search-box input::placeholder { color: var(--text-faint); }
.search-box input:focus { border-color: var(--border-strong); box-shadow: 0 0 0 3px rgba(var(--brand-rgb),.14); background: var(--surface-elevated); }
.search-box i.icon-search { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 12px; }
.search-kbd {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    font-size: 10.5px; font-weight: 600; color: var(--text-faint); background: var(--surface-elevated);
    border: 1px solid var(--border-strong); border-radius: 5px; padding: 2px 6px; line-height: 1; pointer-events: none;
}
.search-dropdown {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60;
    background: var(--surface-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); max-height: 380px; overflow-y: auto;
    animation: menu-in var(--ease) both;
}

.icon-btn {
    width: 30px; height: 30px; border-radius: var(--radius); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); background: transparent; border: none; cursor: pointer; position: relative;
    font-size: 13px;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

.notif-badge {
    position: absolute; top: -2px; right: -2px; min-width: 14px; height: 14px; padding: 0 3px;
    border-radius: 999px; background: var(--red); color: #fff; font-size: 9px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; border: 2px solid var(--header);
}
.dropdown-panel {
    position: absolute; right: 0; top: calc(100% + 8px); width: 320px; z-index: 60;
    background: var(--surface-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); overflow: hidden;
    animation: menu-in var(--ease) both;
}
.dropdown-panel-header { padding: 11px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.dropdown-panel-header span:first-child { font-size: 12.5px; font-weight: 600; color: var(--text); }
.dropdown-panel-body { max-height: 320px; overflow-y: auto; }
.dropdown-panel-body > * { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.dropdown-panel-body > *:last-child { border-bottom: none; }
.dropdown-panel-body > *:hover { background: var(--surface-hover); }

.avatar {
    width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
    background: var(--surface-elevated); border: 1px solid var(--border-strong); color: var(--text); font-size: 11.5px; font-weight: 600;
    display: flex; align-items: center; justify-content: center;
}

.content { flex: 1; overflow-y: auto; padding: 18px 20px 26px; }

/* ---------- 4. PAGE HEADER ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-header h1, .page-title { font-size: 18px; font-weight: 600; color: var(--text); line-height: 1.3; letter-spacing: -.015em; }
.page-subtitle { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }
.page-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-faint); margin-bottom: 4px; }
.breadcrumb a { color: var(--text-faint); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb i.fa-chevron-right { font-size: 8px; opacity: .6; }

/* ---------- 5. CARDS ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: none; }
.card-header {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 13px; font-weight: 600; color: var(--text); }
.card-header-icon {
    width: 26px; height: 26px; border-radius: var(--radius-sm); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px;
}
.card-link { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.card-link:hover { color: var(--text); }
.card-body { padding: 16px; }
.card-footer { padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-alt); }

.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; }
.stat-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stat-icon { width: 28px; height: 28px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; }
.stat-value { font-size: 22px; font-weight: 600; color: var(--text); line-height: 1.1; letter-spacing: -.02em; }
.stat-label { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.stat-trend { font-size: 11px; color: var(--text-faint); margin-top: 6px; }
.stat-trend.up { color: var(--green-text); }
.stat-trend.down { color: var(--red-text); }

.list-row { display: flex; align-items: center; gap: 11px; padding: 9px 16px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-hover); }
.list-row-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ---------- 6. BUTTONS ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px; padding: 0 13px; border-radius: var(--radius); border: 1px solid transparent;
    font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1;
}
.btn i { font-size: 11.5px; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-active); }
.btn-secondary { background: var(--surface-elevated); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-danger { background: rgba(229,72,77,.12); color: var(--red-text); border-color: rgba(229,72,77,.22); }
.btn-danger:hover { background: rgba(229,72,77,.2); }
.btn-success { background: var(--green); color: #06150F; }
.btn-success:hover { opacity: .88; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border-radius: var(--radius); background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-icon:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.btn:disabled, .btn-icon:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn:active:not(:disabled), .btn-icon:active:not(:disabled) { transform: translateY(.5px); }

/* ---------- 7. BADGES ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    height: 19px; padding: 0 7px; border-radius: 5px;
    font-size: 10.5px; font-weight: 550; letter-spacing: .01em; white-space: nowrap;
}
.badge-dot::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-green  { background: rgba(76,195,138,.13); color: var(--green-text); }
.badge-amber  { background: rgba(229,162,60,.14); color: var(--amber-text); }
.badge-red    { background: rgba(229,72,77,.14); color: var(--red-text); }
.badge-blue   { background: rgba(var(--brand-rgb),.16); color: #A5ADF5; }
.badge-violet { background: rgba(157,123,234,.15); color: var(--violet-text); }
.badge-cyan   { background: rgba(77,191,219,.15); color: var(--cyan-text); }
.badge-orange { background: rgba(232,149,90,.15); color: var(--orange-text); }
.badge-gray   { background: rgba(255,255,255,.08); color: var(--text-muted); }

/* ---------- 8. FORMS ---------- */
.field { margin-bottom: 14px; }
.field-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.field-hint { font-size: 11px; color: var(--text-faint); margin-top: 5px; }
.field-error { font-size: 11px; color: var(--red-text); margin-top: 5px; }

.input, .select, .textarea,
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="time"], input[type="search"],
input[type="tel"], input[type="url"], select, textarea {
    width: 100%; min-height: 34px; padding: 0 11px; font-size: 12.5px;
    background: var(--surface-alt); border: 1px solid var(--border-strong); border-radius: 7px;
    color: var(--text); outline: none;
}
textarea, .textarea { min-height: 84px; padding: 9px 11px; resize: vertical; }
.input::placeholder, .textarea::placeholder, input::placeholder, textarea::placeholder { color: var(--text-faint); }
.input:hover, input:hover, select:hover, textarea:hover { border-color: rgba(255,255,255,.18); }
.input:focus, .select:focus, .textarea:focus,
input:focus, select:focus, textarea:focus {
    border-color: rgba(var(--brand-rgb),.55); box-shadow: 0 0 0 3px rgba(var(--brand-rgb),.16); background: var(--surface-elevated);
}
.input:disabled, input:disabled, select:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; }

.form-section { border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 14px; overflow: hidden; }
.form-section-title { padding: 11px 16px; border-bottom: 1px solid var(--border); background: var(--surface-alt); font-size: 12px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.form-section-body { padding: 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; }
.form-section-body .field-full { grid-column: 1 / -1; }

/* ---------- 9. TABLES ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.table thead th {
    text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-faint); padding: 8px 14px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.table tbody td { padding: 0 14px; height: 40px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
table.table tbody tr:last-child td { border-bottom: none; }
table.table tbody tr:hover td { background: var(--surface-hover); }
.table-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }

/* ---------- 10. TABS ---------- */
.tabs { display: flex; align-items: center; gap: 2px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; overflow-x: auto; }
.tab {
    display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
    padding: 6px 12px; border-radius: 5px; font-size: 12px; font-weight: 500; color: var(--text-muted);
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-elevated); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.tab .tab-count { opacity: .7; font-weight: 500; }

.tabs-line { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-line { padding: 9px 10px; font-size: 12.5px; font-weight: 500; color: var(--text-faint); border-bottom: 2px solid transparent; white-space: nowrap; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.tab-line:hover { color: var(--text-muted); background: var(--surface-hover); }
.tab-line.active { color: var(--text); border-color: var(--brand); font-weight: 600; }

/* ---------- 11. EMPTY STATE ---------- */
.empty-state { padding: 40px 20px; text-align: center; }
.empty-state-icon {
    width: 40px; height: 40px; border-radius: var(--radius-lg); background: var(--surface-alt); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; color: var(--text-faint); font-size: 15px;
}
.empty-state p.title { color: var(--text-muted); font-size: 13px; font-weight: 500; }
.empty-state p.hint { color: var(--text-faint); font-size: 12px; margin-top: 3px; }
.empty-state .btn, .empty-state a.link { margin-top: 12px; }

/* ---------- 12. ALERTS / FLASH ---------- */
.alert { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-radius: var(--radius); font-size: 12.5px; font-weight: 450; margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: rgba(76,195,138,.09); border-color: rgba(76,195,138,.22); color: var(--green-text); }
.alert-error   { background: rgba(229,72,77,.09); border-color: rgba(229,72,77,.22); color: var(--red-text); }
.alert i { flex-shrink: 0; }
.alert-close { margin-left: auto; opacity: .7; cursor: pointer; background: none; border: none; color: inherit; }
.alert-close:hover { opacity: 1; }

/* ---------- 13. MODAL / DRAWER / POPOVER ---------- */
.overlay-backdrop {
    position: fixed; inset: 0; background: rgba(4,5,8,.55); z-index: 90; backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity var(--ease-slow);
}
.overlay-backdrop.is-open { opacity: 1; pointer-events: auto; }
.modal-panel {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%) scale(.98); z-index: 91;
    width: 100%; max-width: 480px; background: var(--surface-elevated); border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
    opacity: 0; transition: opacity var(--ease-slow), transform var(--ease-slow);
}
.overlay-backdrop.is-open .modal-panel { opacity: 1; transform: translate(-50%,-50%) scale(1); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 14.5px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.modal-desc { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.modal-body { padding: 18px; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-alt); }

.drawer-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 91; width: 100%; max-width: 440px;
    background: var(--surface-elevated); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
    overflow-y: auto; transition: transform var(--ease-slow);
    transform: translateX(100%);
}
.overlay-backdrop.is-open .drawer-panel { transform: translateX(0); }

/* Mobile: el drawer pasa a ser un bottom sheet en vez de un panel lateral. */
@media (max-width: 640px) {
    .drawer-panel {
        top: auto; left: 0; right: 0; bottom: 0; max-width: none; max-height: 85vh;
        border-left: none; border-top: 1px solid var(--border);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        transform: translateY(100%);
    }
    .overlay-backdrop.is-open .drawer-panel { transform: translateY(0); }
}
/* Overlay centrado reutilizable (tarjetas de detalle, agenda del día, confirmaciones simples).
   El selector combinado .modal-center-overlay.hidden gana por especificidad sin importar el
   orden de carga frente a la utilidad .hidden de Tailwind (evita que el modal quede "trabado" visible). */
.modal-center-overlay { position: fixed; inset: 0; z-index: 70; background: rgba(4,5,8,.55); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-center-overlay.hidden { display: none; }

/* Popover: burbuja flotante compacta (detalle de evento de calendario,
   confirmaciones puntuales). Se posiciona con JS (top/left inline). */
.popover {
    position: fixed; z-index: 95; width: 300px; max-width: calc(100vw - 24px);
    background: var(--surface-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); overflow: hidden;
    animation: menu-in var(--ease) both;
}
.popover-header { padding: 13px 14px 10px; }
.popover-body { padding: 0 14px 12px; }
.popover-footer { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface-alt); }

@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ---------- 13b. MENÚ CONTEXTUAL "···" (patrón reutilizable) ----------
   Uso: <div class="menu-wrap"><button data-menu-trigger class="btn-icon">
   <i class="fas fa-ellipsis"></i></button><div class="menu" data-menu>
   <button class="menu-item">...</button></div></div>
   El toggle/click-fuera/ESC lo maneja el script delegado en footer.php. */
.menu-wrap { position: relative; display: inline-flex; }
.menu {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 80; min-width: 180px;
    background: var(--surface-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 4px; display: none;
    animation: menu-in var(--ease) both;
}
.menu.menu-left { right: auto; left: 0; }
.menu.is-open { display: block; }
.menu-item {
    display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
    height: 30px; padding: 0 9px; border-radius: var(--radius-sm); border: none; background: none;
    font-size: 12.5px; font-weight: 450; color: var(--text); cursor: pointer;
}
.menu-item i { width: 14px; text-align: center; font-size: 11.5px; color: var(--text-faint); flex-shrink: 0; }
.menu-item:hover { background: var(--surface-hover); }
.menu-item.danger { color: var(--red-text); }
.menu-item.danger i { color: var(--red-text); }
.menu-divider { height: 1px; background: var(--border); margin: 4px 2px; }

/* ---------- 13c. TOOLTIP ----------
   Uso: <span data-tooltip="Texto">...</span> — sin JS, solo CSS. */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%) translateY(2px);
    background: var(--surface-elevated); color: var(--text); border: 1px solid var(--border-strong);
    padding: 5px 8px; border-radius: var(--radius-sm); font-size: 11.5px; font-weight: 500; white-space: nowrap;
    box-shadow: var(--shadow); pointer-events: none; opacity: 0; z-index: 100;
    transition: opacity var(--ease), transform var(--ease);
}
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-tooltip-pos="right"]::after { bottom: auto; left: calc(100% + 8px); top: 50%; transform: translateY(-50%) translateX(-2px); }
[data-tooltip-pos="right"]:hover::after { transform: translateY(-50%) translateX(0); }

/* ---------- 13d. SKELETON LOADING ---------- */
.skeleton { background: linear-gradient(90deg, var(--surface-alt) 25%, var(--surface-hover) 37%, var(--surface-alt) 63%); background-size: 400% 100%; animation: skeleton-shine 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes skeleton-shine { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- 13e. SEGMENTED CONTROL ---------- */
.segmented { display: inline-flex; align-items: center; gap: 2px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 2px; }
.segmented button { height: 26px; padding: 0 11px; border-radius: 5px; border: none; background: none; font-size: 12px; font-weight: 500; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface-elevated); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); }

/* ---------- 13f. CHIP (filtro activo) ---------- */
.chip {
    display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 6px 0 9px;
    border-radius: 999px; background: var(--brand-selected); color: var(--text); font-size: 11.5px; font-weight: 500;
    border: 1px solid rgba(var(--brand-rgb),.25);
}
.chip button { display: flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; border: none; background: none; color: inherit; opacity: .7; cursor: pointer; font-size: 10px; }
.chip button:hover { opacity: 1; background: rgba(255,255,255,.12); }

/* ---------- 14. FULLCALENDAR ---------- */
.fc {
    --fc-border-color: var(--border);
    --fc-page-bg-color: transparent;
    --fc-neutral-bg-color: var(--surface-alt);
    --fc-list-event-hover-bg-color: var(--surface-hover);
    --fc-today-bg-color: rgba(var(--brand-rgb), .06);
    --fc-event-border-color: transparent;
    --fc-now-indicator-color: var(--red);
    color: var(--text); font-size: 12.5px;
}
.fc .fc-toolbar-title { font-size: 14.5px; font-weight: 600; color: var(--text); letter-spacing: -.01em; text-transform: capitalize; }
.fc .fc-button-primary { background: var(--surface-alt); border: 1px solid var(--border); color: var(--text-muted); box-shadow: none; text-transform: capitalize; font-weight: 500; font-size: 12px; padding: 5px 11px; }
.fc .fc-button-primary:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.fc .fc-button-primary:focus { box-shadow: 0 0 0 3px rgba(var(--brand-rgb),.18); }
.fc .fc-button-primary:not(:disabled).fc-button-active { background: var(--surface-elevated); border-color: var(--border-strong); color: var(--text); font-weight: 600; }
.fc .fc-button-primary:disabled { opacity: .35; }
.fc .fc-today-button { text-transform: capitalize; }
.fc .fc-col-header-cell { background: transparent; border-color: var(--border); }
.fc .fc-col-header-cell-cushion { color: var(--text-faint); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 8px 4px; }
.fc .fc-daygrid-day-number { color: var(--text-muted); font-size: 12px; font-weight: 500; padding: 6px 8px; }
.fc .fc-daygrid-day.fc-day-today, .fc .fc-timegrid-col.fc-day-today { background: rgba(var(--brand-rgb), .05); }
.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
    color: #fff; background: var(--brand); border-radius: 999px; width: 22px; height: 22px; display: flex;
    align-items: center; justify-content: center; padding: 0; font-weight: 600; margin: 3px;
}
.fc .fc-daygrid-day-frame:hover { background: var(--surface-hover); }
.fc .fc-timegrid-axis-cushion, .fc .fc-timegrid-slot-label-cushion { color: var(--text-faint); font-size: 10.5px; }
.fc .fc-timegrid-now-indicator-line { border-color: var(--red); }
.fc .fc-timegrid-now-indicator-arrow { border-color: var(--red); color: var(--red); }

/* Eventos: minimalistas — barra de color + texto, sin bloques saturados. */
.fc-event {
    cursor: pointer; border: none; border-left: 2.5px solid var(--fc-event-accent, var(--brand));
    background: var(--fc-event-bg, rgba(var(--brand-rgb),.12)); color: var(--fc-event-fg, var(--text));
    border-radius: 4px; font-size: 11px; font-weight: 500; line-height: 1.4; padding: 1.5px 6px;
    transition: filter var(--ease);
}
.fc-event:hover { filter: brightness(1.15); }
.fc-daygrid-event { white-space: nowrap; }
.fc-daygrid-dot-event { padding: 1.5px 6px; }
.fc-event-main-frame { display: flex; align-items: center; gap: 4px; min-width: 0; }
.fc-event-title-container { display: flex; align-items: center; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.fc-event-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-weight: 500; }
.fc-event-time { flex-shrink: 0; font-weight: 600; opacity: .85; }
.fc-daygrid-event-harness { margin-bottom: 2px; }
.fc-daygrid-day-events { min-height: 0 !important; padding: 0 3px; }
.fc-daygrid-more-link { font-size: 10.5px; font-weight: 600; color: var(--text-faint); }
.fc-daygrid-more-link:hover { color: var(--text); }
.fc-popover { background: var(--surface-elevated) !important; border: 1px solid var(--border-strong) !important; box-shadow: var(--shadow-lg) !important; border-radius: var(--radius-lg) !important; overflow: hidden; }
.fc-popover-header { background: var(--surface-alt) !important; color: var(--text) !important; padding: 8px 10px !important; }
.fc-daygrid-day-frame { cursor: pointer; }
.fc-timegrid-event { border-radius: 6px; padding: 3px 7px; }
.fc-timegrid-event .fc-event-main { padding: 0; }
.fc-list { border-color: var(--border) !important; }
.fc-list-day-cushion { background: var(--surface-alt) !important; }
.fc-list-event:hover td { background: var(--surface-hover) !important; }
.fc-list-event-dot { border-color: var(--fc-event-accent, var(--brand)) !important; }
.fc-list-empty { background: transparent !important; color: var(--text-faint); }
.fc-scrollgrid { border-color: var(--border) !important; }

/* ============================================================
   15. RESKIN GLOBAL — remapea las clases Tailwind ya usadas en
   las vistas todavía no reescritas a mano, para que hereden la
   paleta oscura sin editar archivo por archivo.
   ============================================================ */
html.light body { background: var(--bg); color: var(--text); }

.bg-gray-50, .bg-gray-100,
.bg-white, .bg-gray-50\/50, .bg-gray-50\/40 { background-color: var(--surface) !important; }

.text-gray-900, .text-gray-800 { color: var(--text) !important; }
.text-gray-700 { color: var(--text) !important; }
.text-gray-600 { color: var(--text-muted) !important; }
.text-gray-500 { color: var(--text-muted) !important; }
.text-gray-400, .text-gray-300 { color: var(--text-faint) !important; }

.border-gray-50, .border-gray-100, .border-gray-200,
.divide-gray-50 > :not([hidden]) ~ :not([hidden]),
.divide-gray-100 > :not([hidden]) ~ :not([hidden]) { border-color: var(--border) !important; }

input, select, textarea {
    background-color: var(--surface-alt) !important;
    border-color: var(--border-strong) !important;
    color: var(--text) !important;
}
input::placeholder, textarea::placeholder { color: var(--text-faint) !important; }

/* Radius consistente en todo lo no reescrito a mano (escala: sm/md/lg) */
.rounded-3xl { border-radius: var(--radius-lg) !important; }
.rounded-2xl { border-radius: var(--radius-lg) !important; }
.rounded-xl  { border-radius: var(--radius) !important; }

.shadow-sm, .shadow, .shadow-md, .shadow-lg, .shadow-xl, .shadow-2xl { box-shadow: var(--shadow-sm) !important; }

.card-hover:hover { transform: none !important; box-shadow: var(--shadow) !important; }

/* Banners "hero" con gradiente de marca hardcodeado como inline style en
   ~30 vistas (cabeceras de materia/proyecto/rutina/etc.): en vez de un
   bloque saturado de color, superficie oscura + acento sutil arriba,
   más cerca de Linear que de un banner de marketing. */
[style*="linear-gradient(135deg"] {
    background: linear-gradient(160deg, var(--surface-elevated), var(--surface)) !important;
    border: 1px solid var(--border-strong);
    position: relative;
}
[style*="linear-gradient(135deg"]::before {
    content: ''; position: absolute; inset: 0 0 auto 0; height: 2px; border-radius: inherit;
    background: var(--gradient-accent, var(--brand));
}
[style*="667eea"], [style*="#818cf8"] { --gradient-accent: var(--brand); }
[style*="11998e"], [style*="#22c55e"] { --gradient-accent: var(--green); }
[style*="f7971e"], [style*="#f59e0b"] { --gradient-accent: var(--amber); }
[style*="eb3349"], [style*="#ef4444"] { --gradient-accent: var(--red); }
[style*="#8b5cf6"], [style*="#7c3aed"] { --gradient-accent: var(--violet); }
[style*="#06b6d4"], [style*="#0891b2"] { --gradient-accent: var(--cyan); }
[style*="#ec4899"] { --gradient-accent: var(--pink); }

/* stat-blue/green/amber/red: ya no son bloques sólidos de color de fondo
   (chillón sobre un dashboard neutro): superficie + ícono coloreado. */
.stat-blue, .stat-green, .stat-amber, .stat-red { background: var(--surface-elevated) !important; border: 1px solid var(--border); }
.stat-blue  { color: var(--brand-active) !important; }
.stat-green { color: var(--green-text) !important; }
.stat-amber { color: var(--amber-text) !important; }
.stat-red   { color: var(--red-text) !important; }

.sidebar-bg { background: var(--sidebar) !important; }
.nav-active { background: var(--brand-selected) !important; color: var(--text) !important; }

/* Pastillas de estado (badges) con paleta clara de Tailwind -> versión oscura consistente */
.bg-emerald-50, .bg-emerald-100 { background-color: rgba(76,195,138,.13) !important; }
.text-emerald-600, .text-emerald-700 { color: var(--green-text) !important; }
.bg-red-50, .bg-red-100 { background-color: rgba(229,72,77,.14) !important; }
.text-red-600, .text-red-700 { color: var(--red-text) !important; }
.bg-amber-50, .bg-amber-100 { background-color: rgba(229,162,60,.14) !important; }
.text-amber-600, .text-amber-700 { color: var(--amber-text) !important; }
.bg-blue-50, .bg-blue-100 { background-color: rgba(var(--brand-rgb),.16) !important; }
.text-blue-600, .text-blue-700 { color: #A5ADF5 !important; }
.bg-indigo-50, .bg-indigo-100 { background-color: rgba(var(--brand-rgb),.16) !important; }
.text-indigo-600, .text-indigo-700 { color: #A5ADF5 !important; }
.bg-violet-50, .bg-violet-100, .bg-purple-50, .bg-purple-100 { background-color: rgba(157,123,234,.15) !important; }
.text-violet-600, .text-violet-700, .text-purple-600, .text-purple-700 { color: var(--violet-text) !important; }
.bg-cyan-50, .bg-cyan-100 { background-color: rgba(77,191,219,.15) !important; }
.text-cyan-600, .text-cyan-700 { color: var(--cyan-text) !important; }
.bg-orange-50, .bg-orange-100 { background-color: rgba(232,149,90,.15) !important; }
.text-orange-600, .text-orange-700 { color: var(--orange-text) !important; }
.bg-pink-50, .bg-pink-100 { background-color: rgba(224,116,168,.15) !important; }
.text-pink-600, .text-pink-700 { color: var(--pink-text) !important; }
.bg-gray-50, .bg-gray-100.rounded-full { background-color: rgba(255,255,255,.08) !important; }

.text-primary { color: var(--brand-active) !important; }
.text-primary:hover, .hover\:text-secondary:hover, .hover\:text-primary:hover { color: var(--text) !important; }
.bg-primary { background-color: var(--brand) !important; }

.hover\:bg-gray-50:hover, .hover\:bg-gray-100:hover { background-color: var(--surface-hover) !important; }
.hover\:bg-white\/15:hover, .hover\:bg-white\/10:hover { background-color: rgba(255,255,255,.08) !important; }
.hover\:border-gray-300:hover { border-color: var(--border-strong) !important; }
.focus\:border-primary:focus { border-color: rgba(var(--brand-rgb),.55) !important; }
.focus\:ring-primary\/10:focus { box-shadow: 0 0 0 3px rgba(var(--brand-rgb),.16) !important; }
.bg-gray-100 { background-color: var(--surface-alt) !important; }

html.light [style*="linear-gradient(135deg"] { background: linear-gradient(160deg, var(--surface-elevated), var(--surface)) !important; }

/* ---------- 16. RESPONSIVE (off-canvas sidebar en tablet/mobile) ---------- */
.sidebar-overlay { display: none; }

@media (max-width: 1024px) {
    .sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: 80;
        transform: translateX(-100%);
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar.collapsed { width: var(--sidebar-w); }
    .sidebar.collapsed .sidebar-brand-text,
    .sidebar.collapsed .sidebar-user-info,
    .sidebar.collapsed .nav-item .nav-label,
    .sidebar.collapsed .nav-group-title,
    .sidebar.collapsed .sidebar-footer-label span { display: revert; }
    .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 0 9px; }
    .sidebar.collapsed .sidebar-brand { justify-content: flex-start; padding: 14px 16px; }
    .sidebar.collapsed .sidebar-user { justify-content: flex-start; padding: 10px 16px; }
    .sidebar.collapsed .sidebar-footer-row { justify-content: space-between; }
    .sidebar-collapse-btn { display: none; }
    .sidebar-overlay.show {
        display: block; position: fixed; inset: 0; background: rgba(4,5,8,.55); z-index: 70; backdrop-filter: blur(1px);
    }
    .mobile-menu-btn { display: flex !important; }
}
@media (min-width: 1025px) {
    .mobile-menu-btn { display: none; }
}

@media (max-width: 768px) {
    .content { padding: 14px 14px 22px; }
    .search-box { display: none; }
    .stat-card, .form-section-body { grid-template-columns: 1fr; }
    .btn { min-height: 36px; }
    .btn-icon { min-width: 36px; min-height: 36px; }
}
