/* ==========================================================================
   Paleta de Colores Corporativa Oficial:
   - Azul Principal: #0071ce
   - Azul Oscuro: #00549c
   - Borde Acento Celeste: #accbe9
   - Punto / Acento Naranja: #ffa400
   - Blanco: #ffffff
   - Fondos: #f8fafc / #f1f5f9
   ========================================================================== */

:root {
    --brand-blue: #0071ce;
    --brand-blue-dark: #00549c;
    --brand-blue-light: #e8f2fc;
    --brand-accent-sky: #accbe9;
    --brand-orange: #ffa400;
    --brand-orange-dark: #e59300;
    --brand-white: #ffffff;
    --brand-gray-50: #f8fafc;
    --brand-gray-100: #f1f5f9;
    --brand-gray-200: #e2e8f0;
    --brand-gray-400: #94a3b8;
    --brand-gray-600: #475569;
    --brand-gray-800: #1e293b;
    --sidebar-width: 270px;
    --sidebar-collapsed-width: 0px;
}

body {
    background-color: var(--brand-gray-50);
    color: var(--brand-gray-800);
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ==========================================================================
   Header Superior
   ========================================================================== */
.main-header {
    background-color: var(--brand-blue);
    border-bottom: 4px solid var(--brand-accent-sky);
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 2px 10px rgba(0, 113, 206, 0.2);
}

.brand-badge {
    width: 42px;
    height: 42px;
    background-color: var(--brand-white);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-blue);
    font-size: 1.25rem;
    position: relative;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.brand-badge::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background-color: var(--brand-orange);
    border-radius: 50%;
    border: 1.5px solid var(--brand-white);
}

.brand-title {
    color: var(--brand-white);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.3px;
    margin: 0;
    line-height: 1.2;
}

.brand-subtitle {
    color: var(--brand-accent-sky);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.btn-sidebar-toggle {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: var(--brand-white);
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 1.25rem;
    line-height: 1;
    transition: all 0.2s ease;
}

.btn-sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    color: var(--brand-white);
}

/* ==========================================================================
   Estructura: Sidebar Izquierdo + Contenedor Principal
   ========================================================================== */
.app-wrapper {
    display: flex;
    flex: 1 1 auto;
    position: relative;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--brand-white);
    border-right: 1px solid var(--brand-gray-200);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1010;
    min-height: calc(100vh - 65px);
}

.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-heading {
    padding: 1rem 1.25rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--brand-gray-400);
    letter-spacing: 0.8px;
}

.sidebar-nav {
    list-style: none;
    padding: 0.5rem 0.75rem;
    margin: 0;
    flex-grow: 1;
}

.sidebar-nav .nav-item {
    margin-bottom: 0.25rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.65rem 1rem;
    color: var(--brand-gray-600);
    font-size: 0.92rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.sidebar-link:hover {
    color: var(--brand-blue);
    background-color: var(--brand-blue-light);
}

.sidebar-link.active {
    color: var(--brand-blue);
    background-color: var(--brand-blue-light);
    font-weight: 700;
    border-left: 4px solid var(--brand-orange);
}

.sidebar-link .link-icon {
    font-size: 1.15rem;
    color: var(--brand-blue);
    width: 22px;
    text-align: center;
}

.sidebar-link .dropdown-arrow {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.25s ease;
}

.sidebar-link[aria-expanded="true"] .dropdown-arrow {
    transform: rotate(90deg);
}

/* Submenús Desplegables del Sidebar */
.sidebar-submenu {
    list-style: none;
    padding: 0.25rem 0 0.25rem 2.5rem;
    margin: 0;
}

.sidebar-submenu-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    color: var(--brand-gray-600);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.sidebar-submenu-link:hover {
    color: var(--brand-blue);
    background-color: var(--brand-gray-100);
}

.sidebar-submenu-link.active {
    color: var(--brand-blue);
    font-weight: 600;
}

/* Footer del Sidebar */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--brand-gray-200);
    background-color: var(--brand-gray-50);
}

/* Área de Contenido Principal */
.content-wrapper {
    flex: 1 1 auto;
    padding: 1.75rem 2rem;
    background-color: var(--brand-gray-50);
    transition: all 0.3s ease;
    min-width: 0;
}

/* ==========================================================================
   Botones y Componentes con Paleta Oficial
   ========================================================================== */
.btn-brand-primary {
    background-color: var(--brand-blue);
    border-color: var(--brand-blue);
    color: var(--brand-white);
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-brand-primary:hover {
    background-color: var(--brand-blue-dark);
    border-color: var(--brand-blue-dark);
    color: var(--brand-white);
    box-shadow: 0 4px 12px rgba(0, 113, 206, 0.25);
}

.btn-brand-accent {
    background-color: var(--brand-orange);
    border-color: var(--brand-orange);
    color: #1a1a1a;
    font-weight: 700;
    transition: all 0.2s ease;
}

.btn-brand-accent:hover {
    background-color: var(--brand-orange-dark);
    border-color: var(--brand-orange-dark);
    color: #000;
    box-shadow: 0 4px 12px rgba(255, 164, 0, 0.35);
}

.btn-brand-outline {
    background-color: transparent;
    border: 2px solid var(--brand-blue);
    color: var(--brand-blue);
    font-weight: 600;
}

.btn-brand-outline:hover {
    background-color: var(--brand-blue);
    color: var(--brand-white);
}

/* Tarjetas */
.brand-card {
    background: var(--brand-white);
    border: 1px solid var(--brand-gray-200);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.brand-card:hover {
    box-shadow: 0 4px 14px rgba(0, 113, 206, 0.1);
}

.brand-card-accent {
    border-top: 4px solid var(--brand-orange);
}

/* Hero Banner */
.brand-hero {
    background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-blue-dark) 100%);
    color: var(--brand-white);
    border-radius: 16px;
    padding: 2.25rem 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 113, 206, 0.2);
}

.brand-hero::after {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 70%);
    border-radius: 50%;
}

.hero-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: var(--brand-orange);
    border-radius: 50%;
    margin-left: 2px;
}

.badge-brand-orange {
    background-color: var(--brand-orange);
    color: #1a1a1a;
    font-weight: 700;
    padding: 0.35rem 0.75rem;
    border-radius: 50rem;
}

.badge-brand-soft {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--brand-white);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-weight: 600;
    padding: 0.4rem 0.8rem;
    border-radius: 50rem;
}

/* Indicadores de Estado */
.status-dot-active {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
    animation: pulse 2s infinite;
}

.status-dot-warning {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--brand-orange);
    box-shadow: 0 0 0 3px rgba(255, 164, 0, 0.2);
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Footer Principal */
.main-footer {
    background-color: #0d1b2a;
    color: #94a3b8;
    border-top: 3px solid var(--brand-blue);
    padding: 1.25rem 0;
    font-size: 0.85rem;
}

.main-footer a {
    color: var(--brand-accent-sky);
    text-decoration: none;
}

.main-footer a:hover {
    color: var(--brand-white);
    text-decoration: underline;
}

/* Overlay móvil */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1005;
}

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 65px;
        left: 0;
        bottom: 0;
        height: calc(100vh - 65px);
        margin-left: calc(-1 * var(--sidebar-width));
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
    }
    
    .sidebar.show {
        margin-left: 0;
    }

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

    .content-wrapper {
        padding: 1.25rem;
    }
}

/* ==========================================================================
   Encabezados de Tabla Ordenables (Mayor o Menor)
   ========================================================================== */
.th-sortable {
    cursor: pointer !important;
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.th-sortable:hover {
    background-color: #e2e8f0 !important;
    color: var(--brand-blue) !important;
}

.th-sortable.active-sort {
    color: var(--brand-blue) !important;
    background-color: #eff6ff !important;
}

