/* ==========================================================================
   INVENTARIO - EPS RIOJA: SISTEMA DE DISEÑO PREMIUM (GAMA AZUL PROFESIONAL)
   ========================================================================== */

:root {
    /* Paleta de colores premium */
    --primary-color: #2563eb;       /* Azul Cobalto */
    --primary-hover: #1d4ed8;       /* Azul Cobalto Oscuro */
    --primary-light: #eff6ff;       /* Azul Cobalto Claro */
    --accent-color: #3b82f6;        /* Azul Acento */
    
    --bg-canvas: #f8fafc;           /* Fondo gris azulado neutro */
    --bg-card: #ffffff;             /* Fondo de tarjetas */
    --text-primary: #1e3a8a;        /* Texto oscuro (Navy Blue) */
    --text-secondary: #334155;      /* Texto secundario (Slate 700) */
    --text-muted: #64748b;          /* Texto atenuado (Slate 500) */
    
    --border-color: #e2e8f0;        /* Borde Slate 200 */
    --border-light: rgba(226, 232, 240, 0.6);
    --sidebar-width: 260px;
    
    /* Configuración Sidebar - Degradado Azul Real */
    --sb-bg: linear-gradient(180deg, #1e40af 0%, #2563eb 100%);
    --sb-hover: rgba(255, 255, 255, 0.08); /* Gris Translúcido */
    --sb-text: rgba(255, 255, 255, 0.85);
    --sb-border: rgba(255, 255, 255, 0.08);
}

/* --- Estilos Generales --- */
body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-canvas);
    color: var(--text-secondary);
    font-size: 0.9rem;
    overflow-x: hidden;
    letter-spacing: -0.1px;
}

/* Scrollbar Personalizado */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* --- Estilos de la Barra Lateral (Sidebar) --- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--sb-bg);
    border-right: 1px solid var(--sb-border);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--sb-border);
    height: 70px;
}

.sidebar-logo .logo-icon {
    color: var(--accent-color);
}

.sidebar-logo span {
    font-weight: 700;
    font-size: 1.1rem;
    color: #ffffff;
    letter-spacing: 0.5px;
}

.sidebar-menu {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px 12px;
}

.sidebar-menu-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.55); /* Mayor contraste en fondo azul */
    letter-spacing: 1.2px;
    margin-bottom: 8px;
    margin-top: 18px;
    padding-left: 10px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: var(--sb-text);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 500;
    margin-bottom: 4px;
    transition: all 0.2s ease-in-out;
}

.sidebar-link i {
    font-size: 1.05rem;
    margin-right: 10px;
    width: 22px;
    text-align: center;
    transition: transform 0.2s ease;
}

.sidebar-link:hover {
    background-color: var(--sb-hover);
    color: #ffffff;
}

.sidebar-link:hover i {
    transform: scale(1.1);
}

.sidebar-link.active {
    background: #ffffff !important;
    color: #1e40af !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

.sidebar-link.active i {
    color: #1e40af !important;
}

.sidebar .p-3.border-top {
    border-color: var(--sb-border) !important;
}

/* --- Estilos del Header / Navbar Superior --- */
.main-header {
    height: 70px;
    background-color: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 900;
    margin-left: var(--sidebar-width);
    backdrop-filter: blur(10px);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.02);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-light);
    transition: border-color 0.25s ease;
}

.user-profile:hover .user-avatar {
    border-color: var(--primary-color);
}

/* --- Contenedor Principal de Contenido --- */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 30px;
    min-height: calc(100vh - 70px);
}

/* --- Tarjetas Estilo Premium --- */
.card {
    background-color: var(--bg-card);
    border: 1px solid rgba(37, 99, 235, 0.05);
    border-radius: 16px;
    box-shadow: 0 4px 20px -2px rgba(37, 99, 235, 0.02), 0 2px 6px -1px rgba(37, 99, 235, 0.02), 0 20px 25px -5px rgba(37, 99, 235, 0.01);
    margin-bottom: 24px;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 20px 24px;
}

.card-body {
    padding: 24px;
}

/* Tarjetas KPI Animadas */
.kpi-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: default;
}

.card:has(.kpi-card):hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05), 0 20px 25px -5px rgba(0, 0, 0, 0.04);
}

.kpi-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

/* --- Botones Estilizados --- */
.btn {
    font-weight: 500;
    border-radius: 10px;
    padding: 8px 18px;
    transition: all 0.2s ease-in-out;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #1e40af);
    border: 0;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.18);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1d4ed8);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28);
    transform: translateY(-1px);
}

.btn-outline-secondary {
    border: 1px solid #cbd5e1;
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--text-primary);
}

/* --- Inputs y Formularios --- */
.form-control, .form-select {
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
    outline: none;
}

.form-label {
    margin-bottom: 6px;
}

/* --- Tablas y Estilos de Datos --- */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    font-weight: 600;
    color: var(--text-primary);
    background-color: #f1f7ff;
    border-bottom: 2px solid rgba(37, 99, 235, 0.15);
    padding: 14px 16px;
    font-size: 0.85rem;
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.table tbody tr {
    transition: background-color 0.15s ease;
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges de Estado del Sistema */
.badge {
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* --- Personalizaciones de Paginación (Bootstrap 5 y DataTables) --- */

/* Contenedor y distribución */
.dataTables_wrapper .dataTables_paginate {
    padding-top: 15px !important;
}

.dataTables_wrapper .dataTables_paginate .pagination {
    display: flex !important;
    gap: 6px !important; /* Espacio de separación uniforme entre botones */
    justify-content: flex-end;
    margin: 0;
}

/* Resetear estilos del contenedor LI de Bootstrap para evitar cajas dobles */
.dataTables_wrapper .dataTables_paginate li.paginate_button {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: inline !important;
    min-width: auto !important;
    height: auto !important;
    box-shadow: none !important;
}

/* Estilo para los botones interactivos de paginación */
.pagination .page-link,
.dataTables_wrapper .dataTables_paginate .paginate_button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 38px !important;
    height: 38px !important;
    padding: 0 14px !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    color: var(--text-secondary) !important;
    background-color: #f1f5f9 !important; /* Color sólido sin borde */
    border: none !important; /* Sin bordes */
    border-radius: 10px !important; /* Redondeado premium */
    margin: 0 3px !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    box-shadow: none !important;
}

/* Hover */
.pagination .page-link:hover,
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background-color: var(--primary-light) !important; /* Azul muy claro al pasar el ratón */
    color: var(--primary-color) !important;
    border: none !important;
}

/* Botón Activo (Página Actual) */
.pagination .page-item.active .page-link,
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: linear-gradient(135deg, var(--primary-color), #1d4ed8) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2) !important;
}

/* Botón Deshabilitado (Ej. Anterior/Siguiente cuando no hay más páginas) */
.pagination .page-item.disabled .page-link,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    background-color: #f8fafc !important;
    color: #cbd5e1 !important;
    border: none !important;
    opacity: 0.6;
    cursor: not-allowed !important;
}

/* ==========================================================================
   DISEÑO RESPONSIVO Y SIDEBAR COLAPSABLE
   ========================================================================== */

/* Transiciones Suaves Globales de Layout */
.sidebar, .main-header, .main-content {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Fondo Oscuro / Overlay para Menú Móvil */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.5);
    z-index: 999;
    display: none;
    backdrop-filter: blur(4px);
}

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

/* Evitar scroll del body cuando el overlay está activo */
body.mobile-sidebar-open {
    overflow: hidden;
}

/* --- ESTADO COLAPSADO EN ESCRITORIO --- */
body.collapsed-sidebar {
    --sidebar-width: 70px;
}

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

body.collapsed-sidebar .sidebar-logo {
    justify-content: center !important;
    padding: 15px 0 !important;
}

body.collapsed-sidebar .logo-text,
body.collapsed-sidebar .sidebar-menu-title,
body.collapsed-sidebar .sidebar-link span,
body.collapsed-sidebar .sidebar .p-3.border-top span {
    display: none !important;
}

body.collapsed-sidebar .sidebar-menu {
    padding: 15px 8px;
}

body.collapsed-sidebar .sidebar-link {
    justify-content: center;
    padding: 12px 0;
    margin-bottom: 8px;
}

body.collapsed-sidebar .sidebar-link i {
    margin-right: 0 !important;
    font-size: 1.25rem;
}

body.collapsed-sidebar .sidebar .p-3.border-top {
    padding: 15px 0 !important;
    text-align: center;
}

body.collapsed-sidebar .sidebar .p-3.border-top a {
    justify-content: center;
    padding: 10px 0;
}

/* Ajustes de margen de contenido cuando está colapsado */
body.collapsed-sidebar .main-header,
body.collapsed-sidebar .main-content {
    margin-left: 70px;
}

/* --- ADAPTACIÓN PARA MÓVILES Y TABLETS (Responsividad) --- */
@media (max-width: 991.98px) {
    :root {
        --sidebar-width: 260px;
    }

    body {
        overflow-x: hidden;
    }

    /* Ocultar barra lateral por defecto */
    .sidebar {
        left: calc(-1 * var(--sidebar-width));
        box-shadow: 0 0 25px rgba(0, 0, 0, 0.2);
    }

    /* Desplegar barra lateral */
    .sidebar.mobile-show {
        left: 0;
    }

    /* Anular márgenes izquierdos */
    .main-header {
        margin-left: 0 !important;
        padding: 0 20px;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 20px 15px;
        min-height: calc(100vh - 70px);
    }

    /* Ajuste en tarjetas y márgenes */
    .card-body {
        padding: 18px;
    }

    .card-header {
        padding: 15px 18px;
    }
}

/* Ajustes adicionales para pantallas extra pequeñas (Teléfonos) */
@media (max-width: 575.98px) {
    .main-header {
        padding: 0 15px;
    }

    .page-layout-title {
        font-size: 1rem !important;
    }

    .user-profile {
        gap: 5px;
    }

    .user-avatar {
        width: 35px;
        height: 35px;
    }

    /* Ajustes generales de tablas */
    .table-responsive {
        border: 0;
        margin-bottom: 0;
    }

    /* Asegurar que las DataTables ocupen 100% de la tarjeta */
    .dataTables_wrapper .row > div {
        padding: 0 !important;
    }
}

/* --- Overlay de Carga (Loader Global) --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
    transition: all 0.3s ease;
}

.loading-overlay .spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
