@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #003478; /* Azul corporativo Ayala */
    --primary-light: #e3f2fd;
    --primary-dark: #001e4d;
    --bg-body: #f4f7fa;
    --bg-surface: #ffffff;
    --text-main: #364152;
    --text-muted: #697586;
    --border-color: #e3e8ef;
    --border-radius: 16px;
    --shadow-soft: 0 4px 24px 0 rgba(34, 41, 47, 0.05);
    --success-color: #2ca87f;
    --warning-color: #e58a00;
    --danger-color: #dc2626;
    --info-color: #3f87f5;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] {
    --bg-body: #0b0f19; /* Fondo ultra oscuro estilo Berry */
    --bg-surface: #111827; /* Superficie oscura */
    --text-main: #f3f4f6; /* Texto claro */
    --text-muted: #9ca3af; /* Texto secundario claro */
    --border-color: #1f2937; /* Bordes oscuros */
    --primary-light: #1e293b; /* Fondo azul oscuro para hover */
    --shadow-soft: 0 4px 24px 0 rgba(0, 0, 0, 0.4);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    --primary-color: #3b82f6; /* Azul un poco más brillante para contraste */
}

/* Sobreescrituras para Modo Oscuro (Evita romper layouts que usan clases de Bootstrap) */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .card.bg-white {
    background-color: var(--bg-surface) !important;
}

[data-theme="dark"] .text-dark {
    color: var(--text-main) !important;
}

[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .table {
    color: var(--text-main) !important;
    background-color: var(--bg-surface) !important;
}

[data-theme="dark"] .table th,
[data-theme="dark"] .table td {
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .table-light {
    background-color: var(--bg-body) !important;
    color: var(--text-main) !important;
}

[data-theme="dark"] .dropdown-menu {
    background-color: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-main) !important;
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: var(--primary-light) !important;
}

[data-theme="dark"] .modal-content {
    background-color: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
}

/* =========================================
   LOGIN - SPLIT SCREEN
   ========================================= */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    background-color: var(--bg-surface);
}

.auth-form-section {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--bg-surface);
}

.auth-form-section > div {
    margin-top: auto;
    margin-bottom: auto;
    padding-top: 2rem;
    padding-bottom: 2rem;
}

.auth-image-section {
    height: 100vh;
    position: sticky;
    top: 0;
    background-image: url('../images/login-bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.auth-image-section::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: linear-gradient(to right, rgba(0, 52, 120, 0.4), rgba(0, 0, 0, 0.1));
}

.brand-logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

/* =========================================
   INPUTS & BUTTONS
   ========================================= */
.form-control {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: #f8fafc;
    transition: all 0.2s;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(0, 52, 120, 0.15);
    background-color: var(--bg-surface);
}

.form-select-unified {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: #f8fafc;
    transition: all 0.2s;
    min-width: 180px;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 52, 120, 0.2);
}

.btn-excel-global {
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.3s ease;
}

/* =========================================
   DASHBOARD LAYOUT (Berry Style)
   ========================================= */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    background-color: var(--bg-body);
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    min-width: 260px;
    max-width: 260px;
    flex-shrink: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: var(--bg-surface);
    color: var(--text-main);
    transition: all 0.3s;
    border-right: 1px solid var(--border-color);
    padding-top: 1.5rem;
    z-index: 100;
}

.sidebar .brand-logo {
    padding: 0 1.5rem;
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 2rem;
}

.sidebar a {
    padding: 0.8rem 1.5rem;
    font-size: 0.95rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
    margin: 0.2rem 1rem;
    border-radius: 8px;
}

.sidebar a:hover, .sidebar a[aria-expanded="true"] {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.sidebar a i {
    margin-right: 12px;
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar .collapse a {
    padding-left: 3.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.sidebar .collapse a:hover {
    color: var(--primary-color);
    background-color: transparent;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Topbar */
.topbar {
    background-color: var(--bg-surface);
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border-color);
}

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

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.2rem;
}

/* Page Content */
.page-content {
    padding: 2rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1.5rem;
}

/* =========================================
   CARDS & TABLES
   ========================================= */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    background-color: var(--bg-surface);
    transition: all 0.3s ease-in-out;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    font-size: 1.1rem;
}

.card-body {
    padding: 1.5rem;
}

/* Table styling */
.table {
    color: var(--text-main);
}
.table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
    padding: 1rem;
}
.table td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}
.table tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    padding: 0.5em 0.8em;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.8rem;
}
.badge-pending { background-color: #fff3cd; color: #856404; }
.badge-success { background-color: #d4edda; color: #155724; }

/* =========================================
   RESPONSIVE DESIGN (MOBILE)
   ========================================= */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        height: 100vh;
        z-index: 1050;
        box-shadow: 0 0 15px rgba(0,0,0,0.1);
        transition: left 0.3s ease;
        background-color: var(--bg-surface);
    }

    .sidebar.show {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

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

    .topbar {
        padding: 0 1rem;
    }

    .page-content {
        padding: 1rem;
    }
}

/* =========================================
   PREMIUM UTILITIES (Able Pro Style)
   ========================================= */
.card-premium {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    background: var(--bg-surface);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
}

.card-premium:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.08);
}

.stat-card {
    position: relative;
    padding: 1.5rem;
    color: white;
}

.stat-card i {
    position: absolute;
    right: 1.5rem;
    bottom: 1.5rem;
    font-size: 3rem;
    opacity: 0.2;
}

.bg-premium-blue { background: linear-gradient(135deg, #3f87f5, #1b62d4); }
.bg-premium-green { background: linear-gradient(135deg, #2ca87f, #1e7d5d); }
.bg-premium-orange { background: linear-gradient(135deg, #e58a00, #b86e00); }
.bg-premium-purple { background: linear-gradient(135deg, #673ab7, #4527a0); }
.bg-premium-red { background: linear-gradient(135deg, #dc2626, #b91c1c); }

.glass-effect {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .glass-effect {
    background: rgba(17, 24, 39, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-premium {
    border-radius: 10px;
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.btn-premium::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease-out, height 0.3s ease-out;
}

.btn-premium:active::after {
    width: 200px;
    height: 200px;
    opacity: 0;
}

.table-premium thead th {
    background-color: var(--primary-light);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

[data-theme="dark"] .table-premium thead th {
    color: var(--text-main);
}

.table-responsive {
    border-radius: var(--border-radius);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.animate-up {
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Micro-animations */
.hover-scale {
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.hover-scale:hover {
    transform: scale(1.02);
}

/* =========================================
   COLLAPSED SIDEBAR (Hidden Sidebar)
   ========================================= */
@media (min-width: 769px) {
    .sidebar.collapsed {
        min-width: 0;
        max-width: 0;
        overflow: hidden;
        padding: 0;
        border-right: none;
    }
}

/* =========================================
   PRINT STYLES (Global)
   ========================================= */
@media print {
    /* Ocultar elementos de navegación y UI que no deben imprimirse */
    .sidebar, .topbar, .navbar, .btn, .input-group, select, input, .d-print-none, .sidebar-overlay {
        display: none !important;
    }
    
    /* Ajustar el contenedor principal para que use toda la hoja */
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        flex: none !important;
        display: block !important;
    }
    
    .wrapper {
        display: block !important;
    }

    .page-content {
        padding: 0 !important;
    }

    body {
        background-color: white !important;
        color: black !important;
    }

    /* Remover sombras y bordes de las tarjetas */
    .card, .card-premium {
        box-shadow: none !important;
        border: none !important;
        background: transparent !important;
    }

    /* Expandir tablas para que no tengan scroll interno */
    .table-responsive {
        overflow: visible !important;
        max-height: none !important;
    }
    
    .table {
        width: 100% !important;
        border-collapse: collapse !important;
    }
    
    .table th, .table td {
        background-color: transparent !important;
        color: black !important;
        border: 1px solid #ddd !important;
    }
    
    /* Imprimir fondos de badges o filas si es posible */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
