/* Root and typography */
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}
/* Population total container (not a card anymore) */
.population-card {
    padding: 1rem;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

:root {
    --gd-bg: #0b1220; /* fondo dark principal */
    --gd-surface: #0f1a2e; /* paneles */
    --gd-surface-2: #12203a; /* bordes/variaciones */
    --gd-border: #243046; /* líneas suaves */
    --gd-text: #e6eefc; /* texto principal */
    --gd-text-muted: #9fb2d0; /* texto secundario */
    --gd-primary: #4da3ff; /* acento azul */
    --gd-primary-strong: #2e8bff; /* azul más intenso */
    --gd-success: #38d39f;
    --gd-warning: #ffc861;
    --gd-info: #7ad0ff;
}

/* Focus styles */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem rgba(255,255,255,0.4), 0 0 0 0.25rem rgba(77,163,255,0.35);
}

/* Body / global */
body.dark-theme {
    margin-bottom: 60px;
    background: radial-gradient(1200px 800px at 10% 10%, #0e1730 0%, var(--gd-bg) 60%), var(--gd-bg);
    color: var(--gd-text);
}

.footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    white-space: nowrap;
    line-height: 60px;
    background-color: var(--gd-surface);
    border-top: 1px solid var(--gd-border);
    color: var(--gd-text-muted);
}

/* Navbar */
.navbar.bg-dark {
    background-color: #0b162b !important;
    border-bottom: 1px solid var(--gd-border) !important;
}

.navbar .nav-link, .navbar .navbar-brand, .navbar .navbar-text {
    color: var(--gd-text) !important;
}

    .navbar .nav-link:hover {
        color: var(--gd-primary) !important;
    }

.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

/* Containers */
.gd-container {
    max-width: 1400px;
}

/* Brand banner */
.brand-banner {
    background: linear-gradient(180deg, rgba(16,28,54,0.9) 0%, rgba(11,18,32,0) 100%);
    border-bottom: 1px solid var(--gd-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

    .brand-banner .brand-logo {
        max-height: 80px;
        width: auto;
        filter: drop-shadow(0 8px 24px rgba(0,0,0,0.35));
    }

/* Cards */
.card {
    background-color: var(--gd-surface);
    border: 1px solid var(--gd-border);
    border-radius: 14px;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, border-color 0.2s;
    color: var(--gd-text);
}

    .card:hover {
        transform: translateY(-2px);
        box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.35) !important;
        border-color: var(--gd-surface-2);
    }

.card-header {
    font-weight: 500;
    color: var(--gd-text);
}

.card .text-muted {
    color: var(--gd-text-muted) !important;
}

/* Dashboard frame and panels */
.card-frame {
    background-color: var(--gd-surface);
    border: 1px solid var(--gd-border);
    padding: 1.25rem;
}

.panel-muted {
    background: #0e1a31;
    border: 1px solid var(--gd-border);
    border-radius: 12px;
}

.map-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    width: 100%;
    /* Halved container width, reduced by an additional ~25% */
    max-width: clamp(150px, 16%, 210px);
    margin: 0 auto;
}
    /* Responsive map sizing: fill the (constrained) container, limit height */
    .map-panel img, .map-panel svg {
        width: 100%;
        max-width: 100%;
        max-height: 65vh;
        height: auto;
        opacity: 0.95;
    }

@media (max-width: 576px) {
    /* Smaller map container and image on XS (more compact) */
    .map-panel {
        max-width: 24vw;
        padding: 0.25rem;
    }

        .map-panel img, .map-panel svg {
            max-width: 100%;
            max-height: 30vh;
        }
}

/* XS compaction for the 'Población Total' card */
@media (max-width: 576px) {
    .population-card {
        padding: 0.5rem;
    }

        .population-card .fs-hero {
            font-size: clamp(1.1rem, 6.5vw, 1.6rem);
            line-height: 1.1;
        }

        .population-card .text-muted {
            font-size: 0.8rem;
        }

        .population-card .d-flex.gap-3 {
            gap: 0.5rem !important;
        }

        .population-card .panel-muted {
            padding: 0.5rem !important;
        }
        /* Stack inner cols in the card on XS for better space usage */
        .population-card .col-xl-8, .population-card .col-xl-4 {
            flex: 0 0 100%;
            max-width: 100%;
        }

        .population-card .col-xl-4 {
            margin-top: 0.5rem !important;
        }
    /* Compact badges under total on XS */
    .kpi-badges-xs .badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.4rem;
    }
}

.kpi-grid .card {
    background-color: #101d36;
}

/* Accent circles */
.bg-gradient {
    background: linear-gradient(145deg, var(--gd-primary-strong), var(--gd-primary)) !important;
}

/* Progress */
.progress {
    border-radius: 10px;
    overflow: hidden;
    background-color: #0e1a31;
}

.progress-bar {
    transition: width 0.6s ease;
}

/* Headings */
.display-6 {
    font-weight: 600;
    color: var(--gd-text);
}

.fs-hero {
    font-size: clamp(2.2rem, 6vw, 4rem);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.fs-kpi {
    font-size: clamp(1.6rem, 4vw, 2.6rem);
    font-weight: 700;
}

/* Badges override to fit dark scheme */
.badge.bg-primary {
    background-color: var(--gd-primary) !important;
    color: #0b1220;
}

.badge.bg-success {
    background-color: var(--gd-success) !important;
    color: #072016;
}

.badge.bg-warning {
    background-color: var(--gd-warning) !important;
    color: #3b2a00;
}

.badge.bg-info {
    background-color: var(--gd-info) !important;
    color: #082030;
}

/* Buttons */
.btn {
    transition: all 0.2s ease-in-out;
}

    .btn:hover {
        transform: translateY(-1px);
    }

.btn-outline-primary {
    border-color: var(--gd-primary);
    color: var(--gd-primary);
}

    .btn-outline-primary:hover {
        background-color: var(--gd-primary);
        color: #0b1220;
    }

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #0c1426;
}

::-webkit-scrollbar-thumb {
    background: #1f2a40;
    border-radius: 4px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: #2a3650;
    }

/* Alerts */
.alert {
    animation: slideInDown 0.3s ease-out;
    background-color: #12203a;
    color: var(--gd-text);
    border: 1px solid var(--gd-border);
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Loading */
@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Responsive tweaks */
@media (max-width: 768px) {
    .display-6 {
        font-size: 1.75rem;
    }

    .fs-2 {
        font-size: 1.5rem !important;
    }

    .card-body {
        padding: 1rem;
    }
}



/* SIDEBAR LATERAL*/

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px; 
    height: 100vh;
    background-color: #0b162b;
    border-right: 1px solid var(--gd-border);
    padding: 20px 0; 
    overflow-y: auto;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

/* Ajustar el contenedor principal */
.gd-container {
    margin-left: 260px; 
    padding: 30px;
    max-width: calc(100% - 260px);
    overflow-x: hidden;
}


footer.footer {
    margin-left: 260px; 
}

/* Logo/Título del sidebar */
.sidebar .nav-item:first-child .nav-link {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gd-primary) !important;
    padding: 15px 20px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--gd-border);
}

/* Navbar interna */
.sidebar .navbar {
    width: 100%;
    background-color: transparent !important;
    border: none !important;
    padding: 0;
}

.sidebar .navbar-nav {
    width: 100%;
    padding: 0 10px;
}

/* Links normales */
.sidebar .nav-link {
    color: var(--gd-text-muted) !important;
    padding: 12px 15px; 
    font-size: 15px;
    border-radius: 8px;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
}

.sidebar .nav-link:hover {
    background-color: var(--gd-surface-2);
    color: var(--gd-primary) !important;
     transform: translateX(3px); 
}


.sidebar i {
    width: 22px;
    margin-right: 10px;
    color: var(--gd-primary);
    text-align: center;
}

.sidebar .nav-item.dropdown {
    position: relative;
}

/* El link del dropdown */
.sidebar .dropdown-toggle {
    width: 100%;
    text-align: left;
}

    .sidebar .dropdown-toggle::after {
        float: right;
        margin-top: 8px;
        transition: transform 0.2s;
    }


    .sidebar .dropdown-toggle[aria-expanded="true"]::after {
        transform: rotate(180deg);
    }



.sidebar .dropdown-menu {
    position: static; 
    margin: 5px 15px 10px 15px;
    background-color: var(--gd-surface-2);
    border: none; 
    border-radius: 8px;
    padding: 0; 
    min-width: unset; 
    box-shadow: none; 
    transform: none !important; 
}

/* Asegura que los textos largos en los dropdowns se ajusten correctamente */
.sidebar .dropdown-item {
    color: var(--gd-text-muted);
    padding: 8px 15px;
    display: flex; /* Asegura que el ícono y el texto se alineen bien */
    align-items: center;
    /* AÑADE ESTAS PROPIEDADES PARA EL AJUSTE */
    white-space: normal; /* Permite que el texto fluya a la siguiente línea */
    word-wrap: break-word; /* Solución para IE/Edge */
    word-break: break-word; /* Fuerza el salto de línea si la palabra es demasiado larga */
    height: auto; /* Permite que el elemento crezca en altura */
}

    .sidebar .dropdown-item i {
        
        flex-shrink: 0;
    }

    .sidebar .dropdown-item:hover {
        background-color: var(--gd-surface);
        color: var(--gd-primary);
    }

.sidebar .dropdown-divider {
    border-color: var(--gd-border);
    margin: 2px 0;
}


.sidebar > nav > .container-fluid {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar .navbar-collapse {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.sidebar .navbar-nav {
    flex-grow: 1; 
}


.sidebar .mt-4 {
    margin-top: auto !important; 
    padding: 15px 20px;
    border-top: 1px solid var(--gd-border);
}

.sidebar .navbar-text {
    color: var(--gd-text-muted) !important;
    font-size: 13px;
    padding: 5px 0;
}

/* Botón cerrar sesión */
.sidebar button.btn {
    border-radius: 8px;
    padding: 10px;
    font-weight: 500;
    transition: all 0.2s;
}

.sidebar button.btn:hover {
     background-color: var(--gd-primary) !important;
     color: #0b1220 !important;
     transform: translateY(-1px);
}

/* SCROLLBAR DEL SIDEBAR  */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #1f2a40;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
        background: #2a3650;
}


/* RESPONSIVE */

@media (max-width: 992px) {
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--gd-border);
    }

    .gd-container {
        margin-left: 0;
        max-width: 100%;
    }

    footer.footer {
        margin-left: 0;
    }


    .sidebar .dropdown-menu {
        position: static;
        margin-left: 0;
        margin-top: 5px;
        box-shadow: none;
    }
}

}
