:root {
    --primary: #1e3c72;
    --primary-light: #2a5298;
    --accent: #f97316;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --sidebar-width: 270px;
    --header-height: 75px;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(15, 23, 42, 0.05), 0 2px 6px rgba(15, 23, 42, 0.02);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Inter', 'Segoe UI', sans-serif;
}

body {
    background: #f1f5f9; /* Gris-azul nítido y premium, sin degradados manchados */
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Custom Premium Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Login Page Styling (High-end with Brand Gradient Overlay) */
.login-body {
    background-image: linear-gradient(135deg, rgba(30, 60, 114, 0.45) 0%, rgba(42, 82, 152, 0.45) 100%), url('../img/fondo-login.jpg');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    display: flex;
}

.login-container {
    background: rgba(255, 255, 255, 0.65);
    padding: 45px 40px;
    border-radius: var(--radius);
    box-shadow: 0 15px 35px rgba(15, 23, 42, 0.12);
    width: 90%;
    max-width: 420px;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.login-header {
    text-align: center;
    margin-bottom: 35px;
}

.login-header h2 {
    color: var(--primary);
    font-weight: 800;
    font-size: 1.8rem;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Form Controls (Modern Minimalist) */
.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 0.82rem;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    min-height: 42px;
    border: 1px solid #dcdfe4;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-main);
    background: #ffffff;
    transition: var(--transition);
    box-sizing: border-box;
}

select.form-control {
    padding-top: 8px;
    padding-bottom: 8px;
    cursor: pointer;
    background-color: #ffffff;
}

.filter-input-rep {
    height: 42px !important;
    padding: 8px 12px !important;
    font-size: 0.9rem !important;
    line-height: 1.4 !important;
    box-sizing: border-box !important;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.12);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    width: 100%;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(30, 60, 114, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(30, 60, 114, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Sidebar Styling (High-end Luxury Dark Mode) */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0b1329 0%, #1c2541 100%);
    box-shadow: 8px 0 35px rgba(15, 23, 42, 0.05);
    height: 100vh;
    position: fixed;
    display: flex;
    flex-direction: column;
    z-index: 101;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(11, 19, 41, 0.3);
}

.sidebar-header h2 {
    color: #ffffff;
    font-size: 1.35rem;
    font-weight: 9500;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-header h2 i {
    color: #3b82f6;
    -webkit-text-fill-color: #3b82f6;
}

.nav-links {
    list-style: none;
    padding: 24px 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
}

.nav-links li a {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    color: #94a3b8;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    border-radius: 8px;
    transition: var(--transition);
}

.nav-links li a:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #ffffff;
    transform: translateX(3px);
}

.nav-links li a.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(30, 60, 114, 0.25);
    font-weight: 700;
}

.nav-links li a i {
    margin-right: 12px;
    font-size: 1.15rem;
    width: 20px;
    text-align: center;
    transition: transform 0.2s ease;
}

.nav-links li a:hover i {
    transform: scale(1.1);
}

.nav-links li a.active i {
    color: #ffffff;
}

/* Layout Content Wrapper */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0; /* Prevents flex blowout */
    background: #f1f5f9; /* Reverted to clean standard light background */
}

/* Header (Sleek Blur) */
.top-header {
    height: var(--header-height);
    background: #ffffff; /* Blanco sólido y limpio */
    border-bottom: 1px solid #e2e8f0; /* Borde nítido */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 35px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    font-weight: 700;
    color: #334155;
    font-size: 0.9rem;
}

.user-info img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(30, 60, 114, 0.1);
}

.content-wrapper {
    padding: 35px;
    flex: 1;
    min-width: 0; /* Prevents flex blowout */
}

.page-title {
    margin-bottom: 25px;
    color: var(--text-main);
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* Dashboard Cards (Premium Grid) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
    border: 1px solid #e2e8f0;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.04);
}

.stat-info h3 {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
}

.stat-info .number {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(30, 60, 114, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.35rem;
}

/* Cards & Panels (ERP Standard) */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 25px;
    margin-bottom: 30px;
    border: 1px solid #e2e8f0;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 15px;
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 800;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tables (Highly Legible & Custom Badges) */
.table-responsive {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

th, td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

th {
    color: #475569;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.5px;
    background: #f8fafc;
}

td {
    font-size: 0.88rem;
    color: #1e293b;
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: #f8fafc;
}

/* Badges (Soft HSL Custom outlines) */
.badge {
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 0.74rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid transparent;
}

.badge.success { 
    background: #ecfdf5; 
    color: #047857; 
    border-color: #a7f3d0; 
}
.badge.warning { 
    background: #fffbeb; 
    color: #b45309; 
    border-color: #fde68a; 
}
.badge.danger { 
    background: #fef2f2; 
    color: #b91c1c; 
    border-color: #fecaca; 
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-danger {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* Modal Custom CSS with backdrop-blur & slide animation */
.modal-custom, .modal-backdrop {
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(15, 23, 42, 0.45); 
    backdrop-filter: blur(5px); 
    z-index: 1050; 
    align-items: center; 
    justify-content: center;
}

.modal-content {
    background: white; 
    padding: 28px; 
    border-radius: 12px; 
    width: 90%; 
    max-width: 520px; 
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.15); 
    animation: zoomIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    border: 1px solid #f1f5f9;
}

@keyframes zoomIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding-bottom: 15px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
}

.modal-header h3 { 
    color: var(--primary); 
    font-size: 1.25rem; 
    font-weight: 800;
}

.close-modal {
    background: none; 
    border: none; 
    font-size: 1.6rem; 
    cursor: pointer; 
    color: var(--text-muted);
    transition: var(--transition);
}

.close-modal:hover { 
    color: #1e293b; 
}

/* Action Buttons inside tables */
.btn-action {
    border: none;
    padding: 7px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.78rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-edit { 
    background: #eff6ff; 
    color: #1d4ed8; 
    border: 1px solid #bfdbfe;
}
.btn-edit:hover { 
    background: #3b82f6;
    color: white;
}

.btn-delete { 
    background: #fef2f2; 
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.btn-delete:hover { 
    background: #ef4444;
    color: white;
}

/* Responsive Styles for Mobile and Tablet (High-fidelity) */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        width: 270px;
    }
    
    .sidebar.show-mobile-sidebar {
        transform: translateX(0);
    }
    
    .close-sidebar-mobile {
        display: block !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }
    
    .btn-menu-toggle {
        display: block !important;
        background: none;
        border: none;
        font-size: 1.4rem;
        cursor: pointer;
        color: var(--primary);
        margin-right: 15px;
        padding: 5px;
        transition: var(--transition);
    }
    
    .btn-menu-toggle:hover {
        opacity: 0.8;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) !important;
    }
    
    .top-header {
        padding: 0 20px;
    }
    
    .content-wrapper {
        padding: 20px;
    }
    
    .card {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    .user-info span {
        display: none; /* Ocultar el nombre en celulares muy pequeños para no distorsionar el header */
    }
    
    .top-header {
        height: 65px;
    }
    
    .page-title {
        font-size: 1.4rem;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px;
    }
}

/* =========================================
   DARK MODE SYSTEM 
   ========================================= */
body.dark-mode {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    background: #0f172a;
}

body.dark-mode .date-filter-form {
    background: var(--card-bg) !important;
    border-color: #334155 !important;
}

body.dark-mode .date-filter-form input[type="date"] {
    color-scheme: dark;
}

/* Notificaciones Custom Classes */
.notif-container { background: #f8fafc; }
.notif-card { background: white; border: 1px solid #e2e8f0; }
.notif-card.read { background: #f8fafc; border: 1px solid #f1f5f9; box-shadow: none !important; }
.notif-title { color: #0f172a; }
.notif-message { color: #334155; }
.notif-details { background: #f1f5f9; color: #475569; }

body.dark-mode .notif-container { background: #0f172a !important; }
body.dark-mode .notif-card { background: #1e293b !important; border-color: #334155 !important; }
body.dark-mode .notif-card.read { background: #0f172a !important; border-color: #1e293b !important; }
body.dark-mode .notif-title { color: #f8fafc !important; }
body.dark-mode .notif-message { color: #cbd5e1 !important; }
body.dark-mode .notif-details { background: #334155 !important; color: #94a3b8 !important; }
body.dark-mode .notif-empty { background: #1e293b !important; border-color: #334155 !important; color: #94a3b8 !important; }

body.dark-mode .main-content {
    background: #0f172a;
}

body.dark-mode .top-header {
    background: #1e293b;
    border-bottom: 1px solid #334155;
}

body.dark-mode .card,
body.dark-mode .stat-card,
body.dark-mode .modal-content {
    background: var(--card-bg) !important;
    border-color: #334155 !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2) !important;
}

body.dark-mode .card-header {
    border-bottom: 1px solid #334155 !important;
    background: #1e293b !important;
}

body.dark-mode .card-header h3,
body.dark-mode .stat-info .number,
body.dark-mode .user-info span,
body.dark-mode td,
body.dark-mode .page-title,
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode label {
    color: var(--text-main) !important;
}

body.dark-mode th {
    background: #334155 !important;
    color: #e2e8f0 !important;
    border-bottom: 1px solid #475569 !important;
}

body.dark-mode td {
    border-bottom: 1px solid #334155;
}

body.dark-mode tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

body.dark-mode .form-control {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

body.dark-mode .form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.25);
}

body.dark-mode .user-dropdown-menu,
body.dark-mode #notificacionesDropdownMenu {
    background: #1e293b !important;
    border: 1px solid #334155 !important;
}

body.dark-mode .dropdown-item,
body.dark-mode #notificacionesDropdownMenu span,
body.dark-mode #notificacionesDropdownMenu a {
    color: #e2e8f0 !important;
}

body.dark-mode .dropdown-item:hover,
body.dark-mode #notificacionesDropdownMenu a:hover {
    background: #334155 !important;
    color: white !important;
}

body.dark-mode .user-info:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

body.dark-mode .modal-header {
    border-bottom: 1px solid #334155 !important;
}

body.dark-mode .stat-card {
    border: 1px solid #334155 !important;
}

body.dark-mode .table-responsive {
    border-color: #334155 !important;
}

/* Modals inputs & text */
body.dark-mode .modal-content p,
body.dark-mode .modal-content span {
    color: #cbd5e1;
}

body.dark-mode .close-modal {
    color: #94a3b8;
}
body.dark-mode .close-modal:hover {
    color: #f8fafc;
}

/* Dropdown background adjustments for dark mode */
body.dark-mode #notificacionesDropdownMenu > div:first-child {
    background: #1e293b !important;
    border-bottom: 1px solid #334155 !important;
}
body.dark-mode #notificacionesDropdownMenu > a:last-child {
    background: #1e293b !important;
    border-top: 1px solid #334155 !important;
}
body.dark-mode #notificacionesDropdownMenu > a:last-child:hover {
    background: #334155 !important;
}
