:root {
    --primary-color: #004a99;
    --secondary-color: #0084ff;
    --bg-color: #f4f7f6;
    --text-color: #333;
    --white: #ffffff;
    --error-color: #e74c3c;
    --success-color: #2ecc71;
    --sidebar-width: 260px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Login Page Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.login-box {
    background: var(--white);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box img {
    max-width: 150px;
    margin-bottom: 20px;
}

.login-box h2 {
    margin-bottom: 20px;
    color: var(--primary-color);
}

.form-group {
    margin-bottom: 15px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
}

.btn-login {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-login:hover {
    background-color: #003366;
}

.alert {
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Main Layout Structure */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width) !important;
    background-color: var(--primary-color) !important;
    color: white !important;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    transition: all 0.3s ease;
    z-index: 9999 !important;
    /* Extremely high to be above DataTables filters/headers */
    overflow-y: auto;
    left: 0;
    top: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar.collapsed {
    width: 70px !important;
}

/* Ensure logo remains visible and centered when collapsed */
.sidebar-logo {
    padding: 0 15px 25px;
    text-align: center;
    transition: all 0.3s ease;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.sidebar-logo img {
    max-width: 140px;
    max-height: 50px;
    height: auto;
    object-fit: contain;
    transition: all 0.3s ease;
}

.sidebar.collapsed .sidebar-logo img {
    max-width: 40px;
    margin-bottom: 0;
}

.sidebar.collapsed .sidebar-logo div,
.sidebar.collapsed .sidebar-menu a span,
.sidebar.collapsed .sidebar-footer,
.sidebar.collapsed .menu-header {
    display: none !important;
}

.sidebar.collapsed .sidebar-menu a {
    text-align: center;
    padding: 15px 0;
    justify-content: center;
}

.sidebar-menu {
    list-style: none;
    flex-grow: 1;
    margin-top: 10px;
}

.sidebar-menu li {
    padding: 2px 10px;
}

.sidebar-menu a {
    color: rgba(255, 255, 255, 0.8) !important;
    text-decoration: none;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    opacity: 1;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    padding: 30px;
    transition: all 0.3s ease;
    width: calc(100% - var(--sidebar-width));
    min-width: 0;
    /* Important for grid/flex items to not overflow */
}

.main-content.expanded {
    margin-left: 70px;
    width: calc(100% - 70px);
}

.top-bar {
    background: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin: -30px -30px 30px -30px;
    position: sticky;
    top: 0;
    z-index: 100 !important;
    /* Lower than sidebar */
}

.card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    margin-bottom: 25px;
    overflow: hidden;
    /* Prevent table overflow outside card */
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
}

.stat-card .icon-box {
    width: 40px;
    height: 40px;
    background: var(--bg-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-size: 20px;
}

.stat-card .info h3 {
    font-size: 14px;
    color: #888;
    margin-bottom: 5px;
}

.stat-card .info p {
    font-size: 22px;
    font-weight: 700;
}

/* Utilities */
.text-right {
    text-align: right !important;
}

.text-center {
    text-align: center !important;
}

.text-left {
    text-align: left !important;
}

.money {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    text-align: right;
}

.date-cell {
    text-align: center !important;
}

.btn-danger {
    background-color: #d9534f;
    color: white !important;
    padding: 8px 15px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    transition: background 0.3s;
    display: inline-block;
}

.btn-danger:hover {
    background-color: #c9302c;
}

@media print {

    .sidebar,
    .header,
    .filter-bar,
    .btn-filter,
    .btn-export,
    .btn-print,
    header,
    nav {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .card {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
    }

    body,
    html {
        background: white !important;
        font-size: 10pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    table {
        width: 100% !important;
        border: 1px solid #000;
    }

    th,
    td {
        border: 1px solid #000 !important;
        padding: 5px !important;
        color: #000 !important;
    }

    h3 {
        text-align: center;
        margin-bottom: 20px;
    }
}  
/* Global Button Styles */  
.btn { padding: 8px 15px; border-radius: 6px; text-decoration: none; font-weight: 600; font-size: 14px; cursor: pointer; border: none; display: inline-block; font-family: 'Inter', sans-serif; }  
.btn-primary { background: var(--primary-color); color: white; }  
.btn-primary:hover { background: #003366; }  
.btn-secondary { background: #e2e8f0; color: #4a5568; }  
.btn-secondary:hover { background: #cbd5e0; }  
.btn-sm { padding: 5px 10px; font-size: 12px; } 


/* =======================================================
   ESTANDARIZACIN TIPOGRFICA Y DE PARRILLAS (SaaS Standard)
   ======================================================= */
:root {
    --font-base: 13.5px;
    --font-title-lg: 20px;
    --font-title-md: 16px;
    --font-title-sm: 14px;
    --font-table-th: 12px;
    --font-table-td: 13px;
    --font-label: 12.5px;
    --font-input: 13.5px;
    --font-btn: 13px;
    --font-badge: 11px;
}

body {
    font-size: var(--font-base);
    color: #2d3748;
    line-height: 1.5;
}

/* Encabezados y Ttulos */
h1, .h1 { font-size: 22px; font-weight: 700; color: #1a202c; }
h2, .h2 { font-size: var(--font-title-lg); font-weight: 700; color: #2d3748; }
h3, .h3 { font-size: var(--font-title-md); font-weight: 600; color: #2d3748; }
h4, .h4 { font-size: var(--font-title-sm); font-weight: 600; color: #4a5568; }

/* Top Bar Homologado */
.top-bar {
    font-size: 13px;
}
.top-bar .page-title h2 {
    font-size: 16px !important;
    font-weight: 700 !important;
}
.top-bar .page-title h2 span:last-child {
    font-size: 13px !important;
    font-weight: 500 !important;
}
.top-bar .user-info {
    font-size: 13px !important;
}
.top-bar .user-info span {
    font-size: 13px !important;
}
.top-bar .btn-danger {
    font-size: 12px !important;
    padding: 6px 12px !important;
}

/* Sidebar Homologado */
.sidebar-logo div {
    font-size: 12px !important;
}
.menu-header {
    font-size: 11px !important;
    letter-spacing: 0.5px;
    font-weight: 700 !important;
    text-transform: uppercase;
}
.sidebar-menu a {
    font-size: 13.5px !important;
}
.submenu li a {
    font-size: 13px !important;
}
.sidebar-footer {
    font-size: 11px !important;
}

/* PARRILLAS / TABLAS / DATATABLES HOMOLOGADAS */
table, table.dataTable, table.table {
    width: 100% !important;
    border-collapse: collapse;
    font-size: var(--font-table-td) !important;
}

/* Encabezados de Columna en Parrillas */
table thead th, 
table.dataTable thead th, 
table.table thead th {
    font-size: var(--font-table-th) !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #4a5568 !important;
    background-color: #f8fafc !important;
    padding: 10px 12px !important;
    border-bottom: 2px solid #e2e8f0 !important;
    vertical-align: middle;
}

/* Filas / Celdas de Datos */
table tbody td, 
table.dataTable tbody td, 
table.table tbody td {
    font-size: var(--font-table-td) !important;
    color: #2d3748 !important;
    padding: 10px 12px !important;
    border-bottom: 1px solid #edf2f7 !important;
    vertical-align: middle;
    line-height: 1.4;
}

table.dataTable tbody tr:hover,
table.table tbody tr:hover {
    background-color: #f8fafc !important;
}

/* Controles de DataTables (Bsqueda, Info, Paginador) */
.dataTables_wrapper {
    font-size: 12.5px !important;
}
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    font-size: 12.5px !important;
    padding: 5px 10px !important;
    border: 1px solid #cbd5e0 !important;
    border-radius: 6px !important;
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    font-size: 12px !important;
    margin-top: 12px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    font-size: 12px !important;
    padding: 4px 10px !important;
    border-radius: 4px !important;
}

/* FORMULARIOS (Labels, Inputs, Selects) */
label, .form-group label {
    font-size: var(--font-label) !important;
    font-weight: 600 !important;
    color: #374151 !important;
    margin-bottom: 5px;
    display: inline-block;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="search"],
select,
textarea,
.form-control,
.form-group input,
.form-group select {
    font-size: var(--font-input) !important;
    color: #1f2937 !important;
    padding: 8px 12px !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    background-color: #ffffff;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus, .form-control:focus {
    border-color: var(--primary-color) !important;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 74, 153, 0.15) !important;
}

/* BOTONES Y BADGES */
.btn {
    font-size: var(--font-btn) !important;
    padding: 7px 14px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
}
.btn-sm, .btn-xs {
    font-size: 11.5px !important;
    padding: 4px 8px !important;
}
.badge, .pill {
    font-size: var(--font-badge) !important;
    font-weight: 700 !important;
    padding: 3px 8px !important;
    border-radius: 12px !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* =======================================================
   RESPONSIVE DESIGN (MVIL & TABLET)
   ======================================================= */
@media (max-width: 768px) {
    /* El Sidebar se convierte en drawer lateral flotante */
    .sidebar {
        position: fixed !important;
        left: -280px !important;
        width: 260px !important;
        height: 100vh !important;
        z-index: 10001 !important;
        transition: left 0.3s ease-in-out !important;
        box-shadow: 4px 0 25px rgba(0,0,0,0.3) !important;
    }
    
    .sidebar.mobile-open {
        left: 0 !important;
    }

    /* Fondo semitransparente al abrir men en celular */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 10000;
        backdrop-filter: blur(2px);
    }
    .sidebar-backdrop.active {
        display: block;
    }

    /* Contenido principal al 100% en celular */
    .main-content,
    .main-content.expanded {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 15px !important;
    }

    /* Barra superior compacta */
    .top-bar {
        margin: -15px -15px 15px -15px !important;
        padding: 12px 15px !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }

    .top-bar .page-title {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .top-bar .user-info {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-top: 1px solid #edf2f7;
        padding-top: 8px;
        font-size: 12px !important;
    }

    /* Tablas con desplazamiento tctil fluido */
    .dataTables_wrapper,
    .table-responsive,
    .card {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Ajuste de grids en pantallas pequeas */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Ajustes para Sidebar Colapsado (Modo Estrecho 70px) */
.sidebar.collapsed .sidebar-switch-app {
    padding: 12px 0 !important;
}
.sidebar.collapsed .sidebar-switch-app .switch-text {
    display: none !important;
}
.sidebar.collapsed .sidebar-switch-app a {
    justify-content: center !important;
    padding: 0 !important;
}
.sidebar.collapsed .sidebar-switch-app .switch-icon {
    font-size: 18px !important;
    display: block !important;
    margin: 0 auto !important;
}

/* Ocultar la etiqueta del mdulo activo cuando est colapsado para evitar desborde */
.sidebar.collapsed .sidebar-module-badge-container {
    display: none !important;
}
