/* =========================================
   1. VARIABLES GLOBALES & RESET
   ================================********* */
:root {
    --primary-blue: #2563eb;       /* Azul Principal */
    --primary-dark: #1e40af;       /* Azul Oscuro */
    --bg-body: #f8fafc;            /* Fondo gris muy suave */
    --bg-card: #ffffff;            /* Fondo blanco */
    --text-main: #1e293b;          /* Texto oscuro */
    --text-muted: #64748b;         /* Texto secundario */
    
    --radius-md: 12px;
    --radius-pill: 50px;
    --sidebar-width: 280px;        /* Ancho del menú en PC */
}

body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    overflow-x: hidden; /* Evita el scroll horizontal */
}

/* =========================================
   2. ESTRUCTURA DEL LAYOUT (ESCRITORIO)
   ================================********* */
/* Solo aplicamos flex row si NO es la página de login */
body:not(.login-page) {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
}

/* Sidebar en Escritorio: Fijo a la izquierda */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: sticky;
    top: 0;
    left: 0;
    background: linear-gradient(180deg, var(--primary-blue) 0%, var(--primary-dark) 100%) !important;
    box-shadow: 4px 0 15px rgba(37, 99, 235, 0.1);
    color: white;
    flex-shrink: 0;
    overflow-y: auto;
    z-index: 1050; /* Por encima del contenido */
    transition: transform 0.3s ease-in-out;
}

/* Contenido Principal en Escritorio */
.main-content {
    flex-grow: 1;
    padding: 30px;
    width: calc(100% - var(--sidebar-width));
    overflow-y: auto;
    transition: margin-left 0.3s ease-in-out;
}

/* =========================================
   3. ESTILOS VISUALES (Menú, Botones, Cards)
   ================================********* */
.nav-pills .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    font-weight: 500;
    margin-bottom: 5px;
    border-radius: var(--radius-md);
    padding: 10px 15px;
    transition: all 0.2s ease;
}

.nav-pills .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: white !important;
    transform: translateX(5px);
}

.nav-pills .nav-link.active {
    background-color: white !important;
    color: var(--primary-blue) !important;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.card {
    background-color: var(--bg-card);
    border: none;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.btn-primary {
    background-color: var(--primary-blue);
    border-color: var(--primary-blue);
    border-radius: var(--radius-pill);
    padding: 8px 20px;
    font-weight: 600;
}

/* Inputs Modernos */
.form-control, .form-select {
    border-radius: 8px;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
}

.table thead th {
    background-color: #f1f5f9 !important;
    color: var(--text-main) !important;
    border-bottom: 2px solid #e2e8f0;
}

/* =========================================
   4. ESTILOS LOGIN (BLUE SPLIT)
   ================================********* */
body.login-page {
    background-color: #ffffff;
    height: 100vh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-layout { display: flex; width: 100%; height: 100%; }
.login-left {
    width: 50%; background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: white; text-align: center; clip-path: ellipse(120% 100% at 0% 50%); z-index: 10;
}
.illustration-icon { font-size: 10rem; margin-bottom: 20px; animation: floatAnimation 4s infinite; }
.login-right { width: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #fff; }
.login-form-container { width: 100%; max-width: 400px; }
.form-control-custom { width: 100%; padding: 15px 20px; border-radius: 50px; background: #f3f4f6; border: 1px solid transparent; }
.btn-login-blue { width: 100%; padding: 15px; background: var(--primary-blue); color: white; border-radius: 50px; border: none; margin-top: 10px; }
@keyframes floatAnimation { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }

/* =========================================
   5. RESPONSIVE (MÓVIL Y TABLET)
   ================================********* */
/* Overlay oscuro para cuando el menú está abierto */
.sidebar-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040; /* Debajo del sidebar, encima del contenido */
    display: none; /* Oculto por defecto */
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active { display: block; opacity: 1; }

@media (max-width: 991.98px) {
    /* 1. Cambiamos la dirección del cuerpo a columna */
    body:not(.login-page) {
        flex-direction: column;
    }

    /* 2. El Sidebar se vuelve "Flotante" y oculto a la izquierda */
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px !important; /* Ancho un poco menor en móvil */
        transform: translateX(-100%); /* Oculto fuera de pantalla */
        box-shadow: none;
    }

    /* Clase para mostrar el sidebar */
    #sidebar.active {
        transform: translateX(0); /* Entra a la pantalla */
        box-shadow: 4px 0 15px rgba(0,0,0,0.3);
    }

    /* 3. El contenido ocupa el 100% */
    .main-content {
        width: 100%;
        padding: 20px 15px; /* Menos padding en móvil */
        margin-left: 0;
    }

    /* 4. Ajustes Login en Móvil */
    .login-layout { flex-direction: column; }
    .login-left { width: 100%; min-height: 35vh; clip-path: none; border-radius: 0 0 40px 40px; padding: 20px; }
    .login-right { width: 100%; min-height: 65vh; padding: 20px; }
    .illustration-icon { font-size: 5rem; }
    .login-welcome-title { font-size: 2rem; }
    .login-title { font-size: 2rem; margin-bottom: 20px; }
}