/* =========================================
   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;
}

/* Estilos para la paleta de colores */
.color-swatch {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    margin: 5px;
    display: inline-block;
    border: 1px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s;
}

.color-swatch:hover {
    transform: scale(1.1);
}

#selectedColorSwatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
    vertical-align: middle;
}

/* =========================================
   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;
    }
}

/* =========================================
   6. TABLAS RESPONSIVAS (MÓVIL)
   ================================********* */
@media (max-width: 768px) {

    .table-responsive-md table,
    .table-responsive-md tbody,
    .table-responsive-md tr,
    .table-responsive-md td {
        display: block;
        width: 100%;
    }

    .table-responsive-md thead {
        /* Se oculta con d-none d-md-table-header-group en HTML, pero por si acaso */
        display: none;
    }

    .table-responsive-md tr {
        margin-bottom: 1rem;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        background: white;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        padding: 10px;
    }

    .table-responsive-md td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 8px 10px;
        border-bottom: 1px solid #f1f5f9;
        font-size: 0.95rem;
    }

    .table-responsive-md td:last-child {
        border-bottom: none;
    }

    .table-responsive-md td::before {
        content: attr(data-label);
        font-weight: 600;
        text-transform: uppercase;
        font-size: 0.8rem;
        color: var(--text-muted);
        margin-right: 15px;
        text-align: left;
    }

    /* Ajustes específicos para filas de acordeón */
    .fila-acordeon td.detalles-acordeon {
        background-color: #f8fafc;
    }
}

/* =========================================
   7. DATATABLES RESPONSIVE CUSTOMIZATION
   ================================********* */
/* Default State: Collapsed (+) */
table.dataTable.dtr-inline.collapsed>tbody>tr>td.dtr-control:before,
table.dataTable.dtr-inline.collapsed>tbody>tr>th.dtr-control:before {
    background-color: #198754 !important;
    /* Green */
    box-shadow: none !important;
    line-height: 14px !important;
    content: '+' !important;
    text-indent: 0 !important;
    font-family: 'Courier New', Courier, monospace !important;
    font-weight: 900 !important;
    font-size: 16px !important;
    border: none !important;
    width: 18px !important;
    height: 18px !important;
    display: inline-flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin-right: 10px !important;
    top: 50% !important;
    margin-top: -9px !important;
    border-radius: 50% !important;
    color: white !important;
}

/* Expanded State: Open (-) */
table.dataTable.dtr-inline.collapsed>tbody>tr.parent>td.dtr-control:before,
table.dataTable.dtr-inline.collapsed>tbody>tr.parent>th.dtr-control:before {
    background-color: #dc3545 !important;
    /* Red */
    content: '-' !important;
}