/* styles.css - EREYS Intranet v100 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    text-decoration: none;
    list-style: none;
}
:root {
    --azul-ereys: #004a87;
    --azul-deep:  #002d54;
    --gris-fondo: #f8fafc;
    --blanco:     #ffffff;
    --verde:      #10b981;
    --rojo:       #ef4444;
}
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--gris-fondo);
    display: block;
    min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--azul-ereys), var(--azul-deep));
    color: white;
    padding: 30px 20px;
    position: fixed;
    height: 100vh;
    left: 0; top: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar img {
    max-height: 52px;
    max-width: 150px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}
.sidebar h2 {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 15px;
}
.sidebar-menu li { margin-bottom: 10px; }
.sidebar-menu a {
    color: white;
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-radius: 10px;
    transition: 0.3s;
}
.sidebar-menu a i { margin-right: 12px; width: 20px; text-align: center; }
.sidebar-menu a:hover { background: rgba(255,255,255,0.1); color: white; }
.user-welcome { margin-bottom: 30px; }
.user-welcome small { font-size: 0.7rem; opacity: 0.7; letter-spacing: 1px; }
.user-welcome p { margin: 5px 0; font-size: 1.1rem; }
.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar-nav li { margin-bottom: 10px; }
.sidebar-nav a {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    border-radius: 8px;
    transition: background 0.3s;
    font-size: 0.95rem;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.1); color: white; }
.sidebar-nav i { width: 20px; text-align: center; font-size: 1.1rem; }

/* Overlay oscuro al abrir sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}
.sidebar-overlay.active { display: block; }

/* ── TOPBAR MOBILE ── */
.topbar-mobile {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--azul-ereys);
    z-index: 998;
    align-items: center;
    padding: 0 16px;
    gap: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.topbar-mobile .hamburger {
    background: none;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
}
.topbar-mobile .topbar-title {
    color: white;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.5px;
    flex: 1;
}
.topbar-mobile .topbar-logo {
    height: 32px;
    width: auto;
    object-fit: contain;
}

/* ── CONTENIDO PRINCIPAL ── */
.main-content {
    margin-left: 260px;
    padding: 40px;
    width: calc(100% - 260px);
    min-height: 100vh;
    box-sizing: border-box;
}

/* ── STAT CARDS ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}
.stat-card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    border: 1px solid #edf2f7;
}
.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-right: 20px;
    flex-shrink: 0;
}
.stat-info h3 {
    font-size: 0.8rem;
    color: #718096;
    text-transform: uppercase;
    margin: 0;
}
.stat-info p {
    font-size: 1.8rem;
    font-weight: bold;
    margin: 5px 0 0 0;
    color: var(--azul-ereys);
}

/* ── BOTONES ── */
.btn-premium {
    background: var(--azul-ereys);
    color: white;
    padding: 12px 25px;
    border-radius: 10px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: 0.2s;
    border: none;
    cursor: pointer;
}
.btn-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,74,135,0.2);
    color: white;
}

/* ── CARDS ── */
.card {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

/* ── BADGES ── */
.badge { padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; display: inline-block; }
.badge.verde    { background: #dcfce7; color: #166534; }
.badge.rojo     { background: #fee2e2; color: #b91c1c; }
.badge.amarillo { background: #fef9c3; color: #92400e; }
.badge.naranja  { background: #ffedd5; color: #9a3412; }

/* ── TABLAS ── */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; }
thead th {
    background: #f8fafc;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    border-bottom: 1px solid #e2e8f0;
}
tbody tr { border-bottom: 1px solid #f1f5f9; }
tbody tr:hover td { background: #fafafa; }

/* ── FORMULARIOS ── */
input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    box-sizing: border-box;
    margin-bottom: 4px;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--azul-ereys);
    box-shadow: 0 0 0 3px rgba(0,74,135,0.1);
}
label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: #475569;
    margin-bottom: 5px;
}

/* ── DATA ITEMS ── */
.data-item {
    padding: 6px 0;
    font-size: 0.88rem;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 8px;
}
.data-item i { color: var(--azul-ereys); width: 16px; }

/* ── BOTONES RAPIDOS (dashboard) ── */
.botonesrap {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* ── BOTTOM NAV (solo APK standalone) ── */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: white;
    border-top: 1px solid #e2e8f0;
    z-index: 900;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: #64748b;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 8px;
    flex: 1;
    transition: color 0.2s;
}
.bottom-nav a i { font-size: 1.2rem; }
.bottom-nav a.active,
.bottom-nav a:hover { color: var(--azul-ereys); }

/* Mostrar bottom nav SOLO en standalone (APK) via clase JS */
body.is-standalone .bottom-nav { display: flex !important; }
body.is-standalone .main-content { padding-bottom: 80px !important; }

/* ══════════════════════════════════════════════════
   RESPONSIVE MOBILE
══════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* Sidebar oculto, se abre con hamburguesa */
    .sidebar {
        transform: translateX(-100%) !important;
        width: 280px !important;
        padding: 20px 16px !important;
        padding-top: 70px !important;
        position: fixed !important;
        left: 0 !important; top: 0 !important;
        z-index: 1000 !important;
    }
    .sidebar.open { transform: translateX(0) !important; }

    /* Topbar visible en mobile */
    .topbar-mobile { display: flex !important; }

    /* Contenido: full width, empuja bajo topbar */
    .main-content {
        margin-left: 0 !important;
        padding: 76px 16px 24px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Cards mas compactas */
    .card {
        padding: 16px !important;
        border-radius: 12px !important;
    }

    /* Stats 2 columnas */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
        margin-bottom: 16px !important;
    }
    .stat-card {
        padding: 14px 10px !important;
        flex-direction: column !important;
        text-align: center !important;
        gap: 8px !important;
    }
    .stat-icon { margin-right: 0 !important; width: 36px !important; height: 36px !important; font-size: 0.95rem !important; }
    .stat-info p { font-size: 1.3rem !important; }
    .stat-info h3 { font-size: 0.65rem !important; }

    /* Botones rapidos 2 cols */
    .botonesrap { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }

    /* Botones */
    .btn-premium { padding: 11px 14px !important; font-size: 0.85rem !important; }

    /* Headers inline a columna */
    header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }

    /* Tablas: las paginas con cards mobile NO necesitan scroll,
       pero las que no tienen alternativa si. Usamos overflow-x auto. */
    .table-scroll { overflow-x: auto !important; }
    .table-scroll table { min-width: 480px; }

    /* Modales */
    .modal-content, .modal-box {
        width: 95% !important;
        margin: 10px auto !important;
        padding: 18px !important;
    }

    /* Tipografia */
    h1 { font-size: 1.2rem !important; }
    h2 { font-size: 1rem !important; }
    h3 { font-size: 0.92rem !important; }

    /* Formularios mas comodos */
    input, select, textarea { font-size: 16px; } /* evita zoom en iOS */
}

@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr !important; }
    .botonesrap { grid-template-columns: 1fr !important; }
}