/* ====================================================================
   COLORES (modo claro y modo oscuro)
   Todo el sitio usa estas variables: al cambiar de modo, cambian solas
   ==================================================================== */

:root {
    --bg-principal: #F3F3F3;
    --bg-card: #FFFFFF;
    --bg-hover: #F6F6F6;
    --bg-menu-hover: #EAEAEA;
    --border-color: #E5E5E5;
    --text-primary: #1A1A1A;
    --text-secondary: #737373;
    --accent-color: #0067C0;
}

body.modo-oscuro {
    --bg-principal: #202020;
    --bg-card: #2B2B2B;
    --bg-hover: #323232;
    --bg-menu-hover: #2D2D2D;
    --border-color: #3c3c3c;
    --text-primary: #FFFFFF;
    --text-secondary: #bcbcbc;
    --accent-color: #4CC2FF;
}

/* ====================================================================
   ESTRUCTURA GENERAL
   Menú lateral a la izquierda, contenido principal a la derecha
   ==================================================================== */

body {
    display: flex;
    height: 100vh;
    margin: 0;
    background-color: var(--bg-principal);
    font-family: "Segoe UI", sans-serif;
}

/* Los input y button no heredan la fuente por defecto: se la pedimos */
input,
button {
    font-family: inherit;
}

.LATERAL {
    width: 300px;
    padding: 20px;
}

.PRINCIPAL {
    flex: 1;
    min-width: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ====================================================================
   MENÚ LATERAL
   Tarjeta de usuario, botones de sección y separadores
   ==================================================================== */

.USUARIO {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px;
    border-radius: 8px;
    background: var(--bg-menu-hover);
    outline: 1px solid var(--border-color);
}

.AVATAR {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.NOMBRE {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.CORREO {
    font-size: 12px;
    color: var(--text-primary);
}

.MENU {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px 0;
}

.SEPARADOR {
    height: 1px;
    background: var(--border-color);
    margin: 10px 0;
    flex-shrink: 0;
}

.BOTON {
    position: relative;
    padding: 10px;
    line-height: 20px;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

.BOTON:hover,
.BOTON.activo {
    background-color: var(--bg-menu-hover);
    color: var(--text-primary);
}

/* Barrita azul a la izquierda del botón activo */
.BOTON::before {
    content: "";
    position: absolute;
    left: 0;
    width: 3px;
    height: 0;
    background-color: var(--accent-color);
    border-radius: 3px;
}

.BOTON.activo::before {
    height: 16px;
}

.BOTON-ADJUNTAR {
    font-size: 14px;
    line-height: 20px;
    color: #ffffff;
    background: #0067C0;
    border: none;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
}

/* ====================================================================
   SECCIONES Y ACORDEONES
   Solo la sección .activa se ve
   Un acordeón .abierto muestra su cuerpo y su pie
   ==================================================================== */

.SECCION {
    display: none;
    flex-direction: column;
    gap: 10px;
}

.SECCION.activa {
    display: flex;
}

.ACORDEON-SECCION {
    background: var(--bg-card);
    outline: 1px solid var(--border-color);
    border-radius: 8px;
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}

.ACORDEON-CABECERA {
    display: flex;
    cursor: pointer;
    padding: 20px;
    line-height: 20px;
    border-radius: 8px;
}

.ACORDEON-CABECERA:hover {
    background: var(--bg-hover);
}

.ACORDEON-SECCION.abierto .ACORDEON-CABECERA {
    border-radius: 8px 8px 0 0;
}

.ACORDEON-INFO {
    display: flex;
    flex-direction: column;
}

.ACORDEON-TITULO {
    font-size: 14px;
    color: var(--text-primary);
}

.ACORDEON-DESCRIPCION {
    font-size: 12px;
    color: var(--text-secondary);
}

.ACORDEON-ICONO {
    width: 25px;
    height: 25px;
    margin-right: 20px;
    align-self: center;
}

body.modo-oscuro .ACORDEON-ICONO {
    filter: invert(1);
}

.ACORDEON-ACCIONES {
    display: flex;
    align-items: center;
    margin-left: auto;
}

/* Flecha dibujada con dos bordes de un cuadrado girado */
.FLECHA {
    width: 7px;
    height: 7px;
    border-right: 1px solid var(--text-secondary);
    border-bottom: 1px solid var(--text-secondary);
    transform: rotate(45deg) translateX(-4px);
}

.ACORDEON-SECCION.abierto .FLECHA {
    transform: rotate(-135deg) translateY(-4px);
}

.ACORDEON-CUERPO {
    padding: 20px;
    display: none;
    border-top: 1px solid var(--border-color);
}

.ACORDEON-SECCION.abierto .ACORDEON-CUERPO {
    display: block;
}

.ACORDEON-PIE {
    display: none;
    justify-content: flex-end;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.ACORDEON-SECCION.abierto .ACORDEON-PIE {
    display: flex;
}

/* Barra con los botones Nuevo, Guardar y Eliminar, alineada a la derecha */
.BARRA-ACCIONES {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}

.BOTON-ACCION {
    padding: 10px;
    font-size: 14px;
    line-height: 20px;
    color: var(--text-primary);
    background: var(--bg-card);
    border: none;
    outline: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
}

.BOTON-ACCION:hover {
    background: var(--bg-hover);
}

/* ====================================================================
   FILAS Y CAMPOS
   Cada fila es una grilla de 8 columnas; span-N = ancho del campo
   ==================================================================== */

.FILA-CAMPOS {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 9px;
}

.FILA-CAMPOS + .FILA-CAMPOS {
    margin-top: 9px;
}

.CAMPO.span-8 {grid-column: span 8;}
.CAMPO.span-6 {grid-column: span 6;}
.CAMPO.span-4 {grid-column: span 4;}
.CAMPO.span-3 {grid-column: span 3;}
.CAMPO.span-2 {grid-column: span 2;}
.CAMPO.span-1 {grid-column: span 1;}

.CAMPO {
    position: relative;
    background: var(--bg-card);
    outline: 1px solid var(--border-color);
    border-radius: 8px;
}

.CAMPO:hover,
.CAMPO:focus-within {
    background: var(--bg-hover);
}

.CAMPO input {
    width: 100%;
    box-sizing: border-box;
    border: none;
    background: transparent;
    font-size: 14px;
    line-height: 20px;
    color: var(--text-primary);
    outline: none;
    padding: 10px;
    overflow: hidden;
}

.CAMPO input::placeholder {
    color: var(--text-secondary);
}

/* Fila unida: campos pegados, con un solo borde por fuera
   y una línea vertical entre ellos */
.FILA-CAMPOS.FILA-UNIDA {
    gap: 0;
    outline: 1px solid var(--border-color);
    border-radius: 8px;
}

.FILA-UNIDA .CAMPO {
    outline: none;
    border-radius: 0;
}

.FILA-UNIDA .CAMPO + .CAMPO {
    border-left: 1px solid var(--border-color);
}

.FILA-UNIDA .CAMPO:first-child {
    border-radius: 8px 0 0 8px;
}

.FILA-UNIDA .CAMPO:last-child {
    border-radius: 0 8px 8px 0;
}

.FILA-UNIDA:has(.CAMPO:first-child.abierto) {
    border-bottom-left-radius: 0;
}

.FILA-UNIDA:has(.CAMPO:last-child.abierto) {
    border-bottom-right-radius: 0;
}

/* ====================================================================
   SELECT PERSONALIZADO
   El input es el campo y el buscador; la lista aparece debajo
   ==================================================================== */

.CAMPO-SELECT input {
    cursor: pointer;
}

/* Abierto: el campo pierde sus esquinas de abajo para pegarse a la lista */
.CAMPO.CAMPO-SELECT.abierto {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.SELECT-MENU {
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    outline: 1px solid var(--border-color);
    border-radius: 0 0 8px 8px;
    display: none;
    z-index: 10;
    overflow: hidden;
}

.CAMPO-SELECT.abierto .SELECT-MENU {
    display: block;
}

.SELECT-LISTA {
    max-height: 260px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0 4px 4px;
    margin-right: 4px;
    container-type: scroll-state;
}

/* Si la lista tiene scroll, separar las opciones de la barra */
@container scroll-state(scrollable: y) {
    .OPCION {
        margin-right: 4px;
    }
}

.OPCION {
    position: relative;
    padding: 10px;
    font-size: 14px;
    height: 20px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    flex-shrink: 0;
}

.OPCION.seleccionado,
.OPCION.resaltada,
.OPCION:hover {
    background-color: var(--bg-hover);
}

/* Barrita azul a la izquierda de la opción elegida */
.OPCION.seleccionado::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    border-radius: 4px;
    background: var(--accent-color);
}

.OPCION-CREAR {
    color: var(--accent-color);
    line-height: 20px;
}

.OPCION-CREAR.resaltada,
.OPCION-CREAR:hover {
    background-color: rgba(77, 166, 255, 0.1);
}

.SIGLA {
    font-family: 'Consolas', monospace;
}

/* ====================================================================
   BARRA DE SCROLL Y TOOLTIP
   ==================================================================== */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    margin: 4px 0;
}

::-webkit-scrollbar-thumb {
    background: #6e6e6e;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #8a8a8a;
}

.TOOLTIP-OPCION {
    position: fixed;
    display: none;
    align-items: center;
    box-sizing: border-box;
    padding: 0 10px;
    font-size: 14px;
    white-space: nowrap;
    color: var(--text-primary);
    background: var(--bg-hover);
    border-radius: 4px;
    pointer-events: none;
    z-index: 100;
}

.TOOLTIP-OPCION.visible {
    display: flex;
}

/* ====================================================================
   MENÚ RESPONSIVO (como Windows 11)
   Pantalla angosta: el menú se oculta y se abre con el botón hamburguesa
   ==================================================================== */

.HAMBURGUESA,
.FONDO-MENU {
    display: none;
}

@media (max-width: 1000px) {
    .HAMBURGUESA {
        position: fixed;
        top: 20px;
        left: 20px;
        z-index: 1100;
        width: 40px;
        height: 40px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        border: none;
        border-radius: 8px;
        background: transparent;
        cursor: pointer;
    }

    .HAMBURGUESA:hover {
        background: var(--bg-menu-hover);
    }

    .HAMBURGUESA span {
        width: 16px;
        height: 1.5px;
        background: var(--text-primary);
        border-radius: 1px;
    }

    .LATERAL {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1000;
        box-sizing: border-box;
        max-width: 85vw;
        padding-top: 80px;
        overflow-y: auto;
        background: var(--bg-principal);
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 0.1s ease, visibility 0.25s;
    }

    body.menu-abierto .LATERAL {
        transform: translateX(0);
        visibility: visible;
    }

    .FONDO-MENU {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 900;
        background: rgba(0, 0, 0, 0.3);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.1s ease;
    }

    body.menu-abierto .FONDO-MENU {
        opacity: 1;
        pointer-events: auto;
    }

    .PRINCIPAL {
        padding: 80px 20px 20px;
    }
}

/* ====================================================================
   TELÉFONOS: las filas pasan a 2 columnas
   Todo campo ocupa el ancho completo, salvo span-3 que ocupa la mitad
   ==================================================================== */

@media (max-width: 600px) {
    .FILA-CAMPOS {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .CAMPO[class*="span-"] {
        grid-column: span 2;
    }

    .CAMPO.span-1 {
        grid-column: span 1;
    }

    .FILA-UNIDA .CAMPO + .CAMPO {
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .FILA-UNIDA .CAMPO:first-child {
        border-radius: 8px 8px 0 0;
    }

    .FILA-UNIDA .CAMPO:last-child {
        border-radius: 0 0 8px 8px;
    }

    .FILA-UNIDA:has(.CAMPO:first-child.abierto) {
        border-bottom-left-radius: 8px;
    }

}
