/* ===== Variables ===== */
:root {
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 60px;
    --color-ingreso: #28a745;
    --color-gasto: #dc3545;
    --color-ahorro: #007bff;
    --navbar-height: 56px;
}

/* ===== Layout ===== */
body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background-color: #f4f6f9;
    font-size: 0.92rem;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    min-height: calc(100vh - var(--navbar-height));
    transition: width 0.25s ease;
    overflow: hidden;
    position: sticky;
    top: var(--navbar-height);
    height: calc(100vh - var(--navbar-height));
    background-color: #1a1d23 !important;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.75);
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    border-radius: 0.375rem;
    margin: 2px 8px;
}

.sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar .nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-weight: 600;
}

.sidebar.collapsed .nav-text {
    display: none;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    margin: 2px 6px;
    padding: 0.6rem;
}

/* ===== Overlay sidebar (mobile) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1034;
}

.sidebar-overlay.active {
    display: block;
}

/* ===== Main content ===== */
.main-content {
    min-height: calc(100vh - var(--navbar-height));
    transition: margin-left 0.25s ease;
    overflow-x: hidden;
}

/* ===== Botón flotante ===== */
.btn-floating {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    z-index: 1050;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-floating:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(40, 167, 69, 0.5);
}

/* ===== Cards ===== */
.card {
    border-radius: 0.6rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.card-header {
    font-size: 0.9rem;
    padding: 0.65rem 1rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* ===== Tablas ===== */
.table-hover tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.04);
}

/* ===== Badges ===== */
.badge {
    font-size: 0.75em;
    font-weight: 600;
}

/* ===== Navbar ===== */
.navbar {
    z-index: 1040;
}

/* ===== Toast ===== */
.toast {
    min-width: 280px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 767.98px) {
    /* Sidebar: posición fija, oculto fuera de pantalla */
    .sidebar {
        position: fixed;
        z-index: 1035;
        left: -240px;
        top: var(--navbar-height);
        width: var(--sidebar-width) !important;
        height: calc(100vh - var(--navbar-height));
        transition: left 0.25s ease;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    /* El contenido siempre ocupa todo el ancho en mobile */
    .main-content {
        margin-left: 0 !important;
        padding: 0.75rem !important;
        padding-bottom: 96px !important;
    }

    /* Botón flotante más pequeño */
    .btn-floating {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 3rem;
        height: 3rem;
        font-size: 1rem;
    }

    /* Ocultar columnas "Mes anterior" y "Año" en KPIs del dashboard */
    .kpi-col-extra {
        display: none !important;
    }

    /* KPI: la columna "Último mes" ocupa todo el ancho */
    .kpi-col-extra ~ .col-4:not(.kpi-col-extra),
    .col-4:not(.kpi-col-extra) {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ===== Utilidades ===== */
.text-ingreso { color: var(--color-ingreso) !important; }
.text-gasto { color: var(--color-gasto) !important; }
.text-ahorro { color: var(--color-ahorro) !important; }
.bg-ingreso { background-color: var(--color-ingreso) !important; }
.bg-gasto { background-color: var(--color-gasto) !important; }

/* ===== Spinner cotización ===== */
.spinner-cotizacion {
    width: 1rem;
    height: 1rem;
}

/* ===== Login ===== */
body.login-page {
    background: linear-gradient(135deg, #1a1d23 0%, #2d3748 100%);
}

/* ===== Sticky header tabla proyección ===== */
.sticky-top {
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    z-index: 1;
}

/* ===== Campana de notificaciones ===== */
#btnCampana {
    text-decoration: none;
    line-height: 1;
}

#btnCampana:hover {
    opacity: 0.8;
}

@keyframes bellRing {
    0%, 100% { transform: rotate(0deg); }
    20%       { transform: rotate(15deg); }
    40%       { transform: rotate(-15deg); }
    60%       { transform: rotate(10deg); }
    80%       { transform: rotate(-10deg); }
}

.bell-ring {
    animation: bellRing 0.6s ease 2;
}

/* ===== Speed dial: tamaño mínimo táctil ===== */
.btn-speed-dial {
    min-width: 44px;
    min-height: 44px;
}

/* ===== Botón voz: animación pulse =====  */
@keyframes voicePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.6); }
    50%      { box-shadow: 0 0 0 14px rgba(220, 53, 69, 0); }
}

.btn-pulsing {
    animation: voicePulse 0.8s infinite;
}

body.page-presupuesto .speed-dial-container { display: none !important; }
body.page-reportes .speed-dial-container { display: none !important; }

/* Botón flotante presupuesto */
.btn-flotante-agregar-presupuesto {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1050;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: #9b59b6;
    color: white;
    border: none;
    font-size: 1.5rem;
    padding: 0;
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-flotante-agregar-presupuesto:hover {
    background-color: #8e44ad;
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(155, 89, 182, 0.6);
}

.btn-flotante-agregar-presupuesto:active {
    transform: scale(0.95);
}

/* ── Tabs de Configuración: solo íconos en mobile ── */
@media (max-width: 767.98px) {
    #configTabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    #configTabs .nav-link {
        padding: 10px 14px;
        min-width: 48px;
        text-align: center;
    }
    .tab-icono {
        font-size: 1.1rem;
    }
}

/* Eliminar delay de 300ms en toda la app (Safari iOS) */
body { touch-action: manipulation; }

/* ===== Botones navbar: altura y estilo consistentes ===== */
.btn-toggle-vista,
.btn-perfil-navbar {
    height: 38px !important;
    min-height: 38px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 14px !important;
    font-size: 0.875rem !important;
    border-radius: 6px !important;
    white-space: nowrap !important;
    vertical-align: middle !important;
}

.btn-toggle-vista {
    touch-action: manipulation !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: rgba(13, 110, 253, 0.2);
    transition: opacity 0.15s ease;
}

@media (max-width: 767px) {
    .btn-toggle-vista,
    .btn-perfil-navbar {
        min-width: 44px !important;
        padding: 0 12px !important;
        touch-action: manipulation !important;
    }
}

/* ===== Fix alert dismissible: X centrada vertical ===== */
.alert-dismissible {
    display: flex !important;
    align-items: center !important;
    padding-right: 1rem !important;
}

.alert-dismissible .btn-close {
    position: static !important;
    flex-shrink: 0 !important;
    margin-left: auto !important;
    padding: 0.25rem !important;
    align-self: center !important;
    transform: none !important;
    top: auto !important;
    right: auto !important;
}

