/* ================================================================
   BlueSense — Tema Claro (Bootstrap 5 Overrides)
   ================================================================ */

:root {
    /* 1. Tipografía y Estructura Base */
    --bs-font-sans-serif: 'Inter', system-ui, sans-serif;
    --sidebar-w: 240px;

    --primary: #1B4079;
    --secondary: #0092D3;
    /* 2. Colores de Marca (Blue Sense) */
    --bs-primary: #1B4079;
    /* Azul Institucional (Navbar, botones principales) */
    --bs-secondary: #0092D3;
    /* Azul Cerúleo (Logo, acentos, botones secundarios) */

    /* 3. Colores Semánticos */
    --bs-success: #10B981;
    /* Éxito - Verde esmeralda */
    --bs-warning: #F59E0B;
    /* Advertencia - Ámbar */
    --bs-danger: #EF4444;
    /* Error - Rojo claro */
    --bs-info: #0092D3;
    /* Info - Usamos tu cerúleo para mantener armonía */

    /* 4. Superficies y Fondos */
    --bs-body-bg: #F4F6F9;
    /* Gris azulado tenue para el fondo general */
    --bs-body-color: #1E293B;
    /* Texto principal oscuro (Alto contraste) */
    --color-surface: #FFFFFF;
    /* Tarjetas, modales y paneles en blanco puro */
    --color-border: #E2E8F0;
    /* Bordes y separadores sutiles */
}

/* ================================================================
   Aplicación Global
   ================================================================ */
body {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

/* Clases de utilidad extra para usar en tus vistas */
.bg-surface {
    background-color: var(--color-surface);
}

.border-custom {
    border-color: var(--color-border);
}

.btn-primary {
    /* Estado Normal */
    --bs-btn-color: #ffffff;
    --bs-btn-bg: #0092D3;
    --bs-btn-border-color: #0092D3;

    /* Estado Hover (Al pasar el cursor - un poco más oscuro) */
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: #007bb2;
    --bs-btn-hover-border-color: #0074a8;

    /* Estado Focus (El halo de accesibilidad al navegar con teclado) */
    --bs-btn-focus-shadow-rgb: 0, 146, 211;

    /* Estado Active (Al hacer clic - aún más oscuro para dar feedback táctil) */
    --bs-btn-active-color: #ffffff;
    --bs-btn-active-bg: #006e9e;
    --bs-btn-active-border-color: #006895;

    /* Estado Disabled (Botón desactivado) */
    --bs-btn-disabled-color: #ffffff;
    --bs-btn-disabled-bg: #0092D3;
    --bs-btn-disabled-border-color: #0092D3;
}

/* ── SIDEBAR ──────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 20px;
    font-weight: 700;
    color: #111827;
}

.sidebar-brand span {
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.nav-section {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #9ca3af;
    padding: 14px 10px 4px;
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border-radius: 8px;
    color: #374151;
    text-decoration: none;
    font-weight: 500;
    font-size: 13.5px;
    margin-bottom: 2px;
    transition: background 0.12s, color 0.12s;
}

.nav-link-item:hover {
    background: #f3f4f6;
    color: #111827;
}

.nav-link-item.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
}

.sidebar-footer {
    padding: 14px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.2;
}

.user-role {
    font-size: 11px;
    color: #9ca3af;
    text-transform: capitalize;
}

/* ── MAIN CONTENT ─────────────────────────────────────────────── */
.main-content {
    /* Desktop: desplazado por la sidebar */
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}

/* Mobile: sin offset, ocupa todo el ancho */
@media (max-width: 767.98px) {
    .main-content {
        margin-left: 0;
        padding-bottom: 70px;
        /* espacio para la bottom nav */
    }
}

.topbar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 14px 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.content-area {
    padding: 24px;
}

/* ── LOGIN ───────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    /* Color de fondo base (el azul marino profundo) */
    background-color: var(--bs-primary);

    /* Aquí creamos el efecto de "luces difuminadas" usando gradientes radiales múltiples */
    background-image:
        radial-gradient(at 10% 10%, rgba(0, 146, 211, 0.5) 0px, transparent 50%),
        /* Cyan arriba izq */
        radial-gradient(at 90% 90%, rgba(0, 146, 211, 0.4) 0px, transparent 50%),
        /* Cyan abajo der */
        radial-gradient(at 50% 100%, rgba(27, 64, 121, 0.8) 0px, transparent 50%);
    /* Profundidad abajo centro */
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.login-brand-icon {
    font-size: 44px;
    color: var(--primary);
}

/* ── MISC ────────────────────────────────────────────────────── */
.card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: none;
}

.card-header {
    background: #fff;
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
}

.table> :not(caption)>*>* {
    padding: 11px 14px;
}

.badge {
    font-weight: 600;
}

.btn {
    font-weight: 500;
    border-radius: 8px;
}

.form-control,
.form-select {
    border-radius: 8px;
    font-size: 14px;
}

/* ── BOTTOM NAV (mobile < md) ───────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #fff;
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: stretch;
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 10px;
    font-weight: 500;
    color: #9ca3af;
    text-decoration: none;
    transition: color 0.15s;
    border: none;
    background: none;
    cursor: pointer;
}

.bottom-nav-item i {
    font-size: 20px;
    line-height: 1;
}

.bottom-nav-item:hover {
    color: var(--secondary);
}

.bottom-nav-item.active {
    color: var(--primary);
    font-weight: 700;
}

.bottom-nav-item.active i {
    text-shadow: 0 0 8px rgba(27, 64, 121, 0.25);
}

/* ── FAB (Floating Action Button) ───────────────────────────── */
.fab-container {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 80px);
    /* Sobre la barra móvil */
    right: 20px;
    z-index: 1040;
}

@media (min-width: 768px) {
    .fab-container {
        bottom: 30px;
        right: 30px;
    }
}

.fab-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(27, 64, 121, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    cursor: pointer;
}

.fab-btn:hover,
.fab-btn:focus {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(27, 64, 121, 0.4);
    color: white;
    background: #15325c;
}

/* ── CONTENEDORES DE CHART.JS Y GASTOS ───────────────────────── */
.chart-container-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
    max-width: 320px;
    /* Tamaño ideal para móvil, en desktop se mantiene legible */
    aspect-ratio: 1 / 1;
}

.chart-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    /* Clicks traspasan al canvas */
    width: 65%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.expense-list-container {
    padding-bottom: 90px;
    /* Espacio para que el FAB no tape el último item */
}