/**
 * MiGestion - Estilos Principales
 * 
 * Paleta: Azul (#1a5276, #2980b9) y Verde (#148f77, #1abc9c)
 * Fuentes: Inter (Google Fonts)
 */

:root {
    /* Colores principales */
    --primary-blue: #1a5276;
    --primary-blue-light: #2980b9;
    --primary-blue-dark: #154360;
    --primary-green: #148f77;
    --primary-green-light: #1abc9c;
    --primary-green-dark: #0e6655;
    
    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-bg: #1a2332;
    --sidebar-hover: #2c3e50;
    --sidebar-active: rgba(26, 188, 156, 0.15);
    
    /* Navbar */
    --navbar-height: 56px;
    
    /* Texto */
    --text-dark: #2c3e50;
    --text-muted: #7f8c8d;
    
    /* Fondos */
    --bg-light: #f4f6f9;
    --bg-card: #ffffff;
    
    /* Bordes */
    --border-color: #dee2e6;
    
    /* Sombras */
    --shadow-sm: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
    --shadow-md: 0 0.5rem 1rem rgba(0,0,0,0.15);
}

/* ============================================================ */
/* GLOBAL */
/* ============================================================ */
* {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-dark);
    overflow-x: hidden;
}

a {
    color: var(--primary-blue-light);
    text-decoration: none;
}
a:hover {
    color: var(--primary-blue);
}

/* ============================================================ */
/* NAVBAR */
/* ============================================================ */
.bg-primary-gradient {
    background: linear-gradient(135deg, var(--primary-blue-dark) 0%, var(--primary-blue) 50%, var(--primary-green-dark) 100%) !important;
}

.navbar {
    height: var(--navbar-height);
    z-index: 1030;
}

/* ============================================================ */
/* SIDEBAR */
/* ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    z-index: 1020;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(180deg, #1a2332 0%, #212f3d 100%);
}

.sidebar-sticky {
    padding-top: 0;
}

.sidebar .nav-link {
    color: rgba(255,255,255,0.7);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.sidebar .nav-link:hover {
    color: #fff;
    background-color: var(--sidebar-hover);
    border-left-color: var(--primary-green-light);
}

.sidebar .nav-link.active {
    color: #fff;
    background-color: var(--sidebar-active);
    border-left-color: var(--primary-green-light);
    font-weight: 500;
}

.sidebar-heading {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ============================================================ */
/* MAIN CONTENT */
/* ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--navbar-height);
    min-height: calc(100vh - var(--navbar-height));
    transition: margin-left 0.3s ease;
}

.sidebar-collapsed .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

.sidebar-collapsed .main-content {
    margin-left: 0;
}

/* ============================================================ */
/* TARJETAS / CARDS */
/* ============================================================ */
.card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    border-radius: 0.75rem 0.75rem 0 0 !important;
    font-weight: 600;
}

.card-header.bg-primary-blue {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%) !important;
    color: #fff;
}

.card-header.bg-primary-green {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-light) 100%) !important;
    color: #fff;
}

/* ============================================================ */
/* TARJETAS KPI / RESUMEN */
/* ============================================================ */
.kpi-card {
    border-left: 4px solid var(--primary-blue);
    border-radius: 0.5rem;
    transition: transform 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
}

.kpi-card .kpi-icon {
    font-size: 2.5rem;
    opacity: 0.3;
}

.kpi-card .kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
}

.kpi-card .kpi-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.kpi-card.border-green { border-left-color: var(--primary-green); }
.kpi-card.border-blue  { border-left-color: var(--primary-blue); }
.kpi-card.border-orange{ border-left-color: #e67e22; }
.kpi-card.border-red   { border-left-color: #e74c3c; }

/* ============================================================ */
/* BOTONES */
/* ============================================================ */
.btn-primary {
    background-color: var(--primary-blue);
    border-color: var(--primary-blue);
}

.btn-primary:hover {
    background-color: var(--primary-blue-dark);
    border-color: var(--primary-blue-dark);
}

.btn-success {
    background-color: var(--primary-green);
    border-color: var(--primary-green);
}

.btn-success:hover {
    background-color: var(--primary-green-dark);
    border-color: var(--primary-green-dark);
}

.btn-procesar {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-light) 100%);
    border: none;
    color: #fff;
    padding: 0.6rem 2rem;
    font-weight: 600;
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(20, 143, 119, 0.4);
}

.btn-procesar:hover {
    background: linear-gradient(135deg, var(--primary-green-dark) 0%, var(--primary-green) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(20, 143, 119, 0.6);
    transform: translateY(-1px);
}

/* ============================================================ */
/* DATATABLES */
/* ============================================================ */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    padding: 0.3rem 0.75rem;
}

table.dataTable {
    border-collapse: collapse !important;
}

table.dataTable thead th {
    background-color: var(--primary-blue);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: none;
    padding: 0.75rem;
}

table.dataTable tbody tr:nth-child(even) {
    background-color: rgba(26, 188, 156, 0.05);
}

table.dataTable tbody tr:hover {
    background-color: rgba(26, 188, 156, 0.1);
}

table.dataTable tbody td {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
}

/* Footer de totales en DataTable */
table.dataTable tfoot th {
    background-color: var(--primary-blue-dark) !important;
    color: #fff !important;
    font-weight: 700;
    padding: 0.5rem 0.75rem;
}

/* Botones de exportar DataTables */
.dt-buttons .btn {
    border-radius: 0.375rem;
    font-size: 0.8rem;
    padding: 0.3rem 0.75rem;
}

/* ============================================================ */
/* FORMULARIOS */
/* ============================================================ */
.form-control, .form-select {
    border-radius: 0.375rem;
    border-color: var(--border-color);
    font-size: 0.875rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-green-light);
    box-shadow: 0 0 0 0.2rem rgba(26, 188, 156, 0.25);
}

.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-dark);
}

/* ============================================================ */
/* FILTROS PANEL */
/* ============================================================ */
.filter-panel {
    background: var(--bg-card);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary-blue);
}

.filter-panel h6 {
    color: var(--primary-blue);
    font-weight: 600;
    margin-bottom: 0.75rem;
}

/* ============================================================ */
/* PANEL DE CONTROL - DASHBOARD */
/* ============================================================ */
.dashboard-section {
    background: var(--bg-card);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-blue);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--primary-green-light);
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
}

/* ============================================================ */
/* GRAFICOS */
/* ============================================================ */
.chart-container {
    position: relative;
    height: 300px;
}

/* ============================================================ */
/* SCROLLBAR PERSONALIZADO */
/* ============================================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-blue-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-blue);
}

/* ============================================================ */
/* RESPONSIVE */
/* ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }
    
    .sidebar-collapsed .sidebar {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .kpi-card .kpi-value {
        font-size: 1.2rem;
    }
}

/* ============================================================ */
/* ANIMACIONES */
/* ============================================================ */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* Loading spinner */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-overlay .spinner-grow {
    color: var(--primary-green);
}

/* ============================================================ */
/* LOGIN */
/* ============================================================ */
.login-page {
    background: linear-gradient(135deg, var(--primary-blue-dark) 0%, var(--primary-blue) 40%, var(--primary-green-dark) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: rgba(255,255,255,0.95);
    border-radius: 1rem;
    box-shadow: 0 1rem 3rem rgba(0,0,0,0.3);
    max-width: 420px;
    width: 100%;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-green) 100%);
    color: #fff;
    padding: 2rem;
    text-align: center;
}

.login-body {
    padding: 2rem;
}
