/*
 * Archivo: main.css
 * Autor: Joel Chala
 * Versión: 1.0
 * Descripción: Estilos globales con variables CSS, tema dark/light,
 *              layout de sidebar + bottom nav, componentes reutilizables
 *              (cards, botones, tablas, modales, formularios).
 * Ruta: pagotrack/assets/css/main.css
 */

/* ═════════════════════════════════════════════
   Variables — Dark theme (default)
   ═════════════════════════════════════════════ */
:root {
    --bg:        #0a0f1e;
    --surface:   #111827;
    --surface2:  #1a2235;
    --border:    #1f2d45;
    --accent:    #00d4a8;
    --accent2:   #3b82f6;
    --danger:    #f43f5e;
    --warn:      #f59e0b;
    --green:     #10b981;
    --text:      #e2e8f0;
    --muted:     #64748b;
    --purple:    #8b5cf6;

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.25);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.35);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.45);
    --radius:    12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --sidebar-w: 240px;
    --header-h:  64px;
}

[data-theme="light"] {
    --bg:       #f8fafc;
    --surface:  #ffffff;
    --surface2: #f1f5f9;
    --border:   #e2e8f0;
    --text:     #0f172a;
    --muted:    #94a3b8;

    --shadow-sm: 0 2px 8px rgba(15,23,42,0.06);
    --shadow-md: 0 8px 24px rgba(15,23,42,0.08);
    --shadow-lg: 0 20px 60px rgba(15,23,42,0.12);
}

/* ═════════════════════════════════════════════
   Reset y base
   ═════════════════════════════════════════════ */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Syne', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s, color 0.3s;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--text);
}
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

p { margin: 0 0 10px; }

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s;
}
a:hover { color: var(--accent2); }

code, pre, .mono {
    font-family: 'Space Mono', monospace;
}

/* ═════════════════════════════════════════════
   Layout principal: sidebar + main
   ═════════════════════════════════════════════ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}
.sidebar-brand .badge {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    display: flex; align-items: center; justify-content: center;
    color: #0a0f1e;
    font-weight: 800;
    font-family: 'Syne', sans-serif;
    font-size: 15px;
}
.sidebar-brand .nombre {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 17px;
}

.sidebar a.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
}
.sidebar a.nav-item:hover {
    background: var(--surface2);
    color: var(--text);
}
.sidebar a.nav-item.activo {
    background: linear-gradient(135deg, rgba(0,212,168,0.15), rgba(59,130,246,0.10));
    color: var(--text);
}
.sidebar a.nav-item .icono {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.sidebar-bottom {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.btn-tema {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s;
}
.btn-tema:hover {
    color: var(--text);
    border-color: var(--accent);
}

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 28px 32px 80px;
    min-width: 0;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-header h1 { margin: 0; }
.page-header .subtitulo {
    font-family: 'Space Mono', monospace;
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

/* ═════════════════════════════════════════════
   Cards y grid
   ═════════════════════════════════════════════ */
.grid {
    display: grid;
    gap: 18px;
}
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.card-titulo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 10px;
}
.card-titulo h2,
.card-titulo h3 { margin: 0; }
.card-titulo .accion {
    font-size: 12px;
    color: var(--accent);
    cursor: pointer;
}

/* ═════════════════════════════════════════════
   Métricas / KPIs
   ═════════════════════════════════════════════ */
.kpi {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.kpi .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    font-family: 'Space Mono', monospace;
}
.kpi .valor {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    font-family: 'Syne', sans-serif;
}
.kpi.accent .valor { color: var(--accent); }
.kpi.danger .valor { color: var(--danger); }
.kpi.green  .valor { color: var(--green); }
.kpi.warn   .valor { color: var(--warn); }

/* ═════════════════════════════════════════════
   Botones
   ═════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s, background 0.15s, border-color 0.15s;
    text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #0a0f1e;
}
.btn-primary:hover { opacity: 0.92; color: #0a0f1e; }

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--accent); }

.btn-danger {
    background: rgba(244,63,94,0.1);
    color: var(--danger);
    border-color: rgba(244,63,94,0.3);
}
.btn-danger:hover { background: rgba(244,63,94,0.18); }

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); }

.btn-sm  { padding: 6px 10px; font-size: 12px; }
.btn-lg  { padding: 14px 22px; font-size: 14px; }
.btn-full { width: 100%; }

/* ═════════════════════════════════════════════
   Formularios
   ═════════════════════════════════════════════ */
.form-grupo { margin-bottom: 14px; }
.form-grupo label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Space Mono', monospace;
}
.form-grupo input,
.form-grupo select,
.form-grupo textarea {
    width: 100%;
    padding: 11px 13px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-grupo input:focus,
.form-grupo select:focus,
.form-grupo textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,212,168,0.15);
}
.form-grupo textarea { min-height: 80px; resize: vertical; }
.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 12px;
}

/* Switch / toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 44px; height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 24px;
    transition: 0.2s;
}
.switch .slider::before {
    content: "";
    position: absolute;
    height: 18px; width: 18px;
    left: 2px; bottom: 2px;
    background: var(--muted);
    border-radius: 50%;
    transition: 0.2s;
}
.switch input:checked + .slider {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border-color: transparent;
}
.switch input:checked + .slider::before {
    transform: translateX(20px);
    background: #0a0f1e;
}

/* ═════════════════════════════════════════════
   Tablas
   ═════════════════════════════════════════════ */
.tabla-wrap { overflow-x: auto; }
table.tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.tabla th,
table.tabla td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
table.tabla th {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Space Mono', monospace;
}
table.tabla tr:last-child td { border-bottom: 0; }
table.tabla tr.pagado td { background: rgba(16,185,129,0.05); }
table.tabla tr.pendiente td { background: rgba(244,63,94,0.04); }
table.tabla tfoot td { font-weight: 700; }

/* ═════════════════════════════════════════════
   Barras de progreso
   ═════════════════════════════════════════════ */
.progreso {
    height: 8px;
    background: var(--surface2);
    border-radius: 99px;
    overflow: hidden;
}
.progreso .barra {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    transition: width 0.4s ease;
    border-radius: 99px;
}
.progreso.thick { height: 12px; }
.progreso.thin  { height: 5px; }

/* ═════════════════════════════════════════════
   Modales
   ═════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,15,30,0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 16px;
}
.modal-overlay.activo { display: flex; }
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}
.modal h2 { margin-bottom: 16px; }
.modal-acciones {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
}

/* ═════════════════════════════════════════════
   Badges / tags
   ═════════════════════════════════════════════ */
.badge-tag {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-family: 'Space Mono', monospace;
}
.badge-tag.activo     { background: rgba(16,185,129,0.15);  color: var(--green);  }
.badge-tag.pendiente  { background: rgba(244,63,94,0.15);   color: var(--danger); }
.badge-tag.warning    { background: rgba(245,158,11,0.15);  color: var(--warn);   }
.badge-tag.info       { background: rgba(59,130,246,0.15);  color: var(--accent2); }
.badge-tag.purple     { background: rgba(139,92,246,0.15);  color: var(--purple); }

/* ═════════════════════════════════════════════
   Alertas
   ═════════════════════════════════════════════ */
.alerta {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 13px;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alerta.warn    { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.3); color: var(--warn); }
.alerta.danger  { background: rgba(244,63,94,0.08);  border-color: rgba(244,63,94,0.3);  color: var(--danger); }
.alerta.info    { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.3); color: var(--accent2); }
.alerta.success { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.3); color: var(--green); }

/* ═════════════════════════════════════════════
   Utilidades
   ═════════════════════════════════════════════ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-4  { gap: 4px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-green  { color: var(--green); }
.text-warn   { color: var(--warn); }
.text-sm  { font-size: 12px; }
.text-xs  { font-size: 11px; }
.text-lg  { font-size: 16px; }
.text-xl  { font-size: 22px; font-weight: 700; }
.mono { font-family: 'Space Mono', monospace; }
.hidden { display: none !important; }

/* ═════════════════════════════════════════════
   Responsive — móvil
   ═════════════════════════════════════════════ */
@media (max-width: 900px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        top: auto; bottom: 0; left: 0; right: 0;
        width: 100%;
        height: 64px;
        flex-direction: row;
        padding: 8px;
        border-right: 0;
        border-top: 1px solid var(--border);
        gap: 4px;
        overflow-x: auto;
        overflow-y: hidden;
        z-index: 200;
    }
    .sidebar-brand,
    .sidebar-bottom { display: none; }
    .sidebar a.nav-item {
        flex-direction: column;
        font-size: 10px;
        padding: 6px 8px;
        gap: 2px;
        min-width: 60px;
        text-align: center;
        white-space: nowrap;
    }
    .sidebar a.nav-item .icono { font-size: 18px; width: auto; }
    .sidebar a.nav-item .texto { display: block; }
    .main { margin-left: 0; padding: 20px 16px 96px; }
}

/* ═════════════════════════════════════════════
   Impresión
   ═════════════════════════════════════════════ */
@media print {
    .sidebar, .btn, .modal-overlay, #loading-screen, .no-print { display: none !important; }
    .main { margin: 0; padding: 0; }
    body { background: #fff; color: #000; }
    .card { border-color: #ccc; box-shadow: none; }
}
