@import 'utilities.css';

/* 
 * base.css
 * Estilos generales y layout principal de ONE
 * Basado en patrones de clase (Flexbox/Grid)
 */

/* RESET COMPLETO */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Paleta de colores base - TEMA OSCURO VERDE (Default) */
    --color-fondo: #050608;
    --color-fondo-panel: #0E1017;
    --color-fondo-tarjeta: #101219;
    --color-fondo-bloque: #151823;
    --color-header: #0B0C10;
    --color-borde: #1E1F27;

    --color-texto-principal: #F5F5F5;
    --color-texto-blanco: #FDFDFE;
    --color-texto-secundario: #A0A1B2;
    --color-texto-tenue: #686A7A;

    --color-acento: #429155;
    /* Verde */
    --color-acento-hover: #1C4C2D;

    /* Tipografía */
    --fuente-principal: 'Times New Roman', Times, serif;
    /* Manteniendo la fuente original por ahora */
}

/* TEMA GRIS */
[data-theme="gray"] {
    --color-acento: #524F4F;
    --color-acento-hover: #3E3B3B;
}

/* TEMA CLARO */
[data-theme="light"] {
    --color-fondo: #FAFAFA;
    --color-fondo-panel: #FFFFFF;
    --color-fondo-tarjeta: #F5F5F5;
    --color-fondo-bloque: #EEEEEE;
    --color-header: #FFFFFF;
    --color-borde: #E0E0E0;

    --color-texto-principal: #212121;
    --color-texto-blanco: #1A1A1A;
    --color-texto-secundario: #616161;
    --color-texto-tenue: #9E9E9E;

    --color-acento: #388E3C;
    /* Verde más oscuro para contraste en fondo claro */
    --color-acento-hover: #2E7D32;
}

body {
    font-family: var(--fuente-principal);
    background-color: var(--color-fondo);
    color: var(--color-texto-principal);
    min-height: 100dvh;
}

/* Botón Hamburguesa Estilizado (Global - Oculto en Desktop) */
.btn-hamburger {
    display: none !important;
    align-items: center;
    justify-content: center;
    background-color: transparent !important;
    border: none;
    color: var(--color-texto-blanco);
    padding: 8px;
    margin-right: 4px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.btn-hamburger:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-hamburger svg {
    width: 26px;
    height: 26px;
    stroke-width: 2;
}

/* (Mobile Media Query moved to end of file) */

/* LAYOUT PRINCIPAL */
.layout-app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    /* Evitar scroll horizontal accidental */
}

/* HEADER SUPERIOR */
.encabezado-app {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background-color: var(--color-header);
    border-bottom: 1px solid var(--color-borde);
    gap: 20px;
}

.logo-app {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #B69AD2;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-app img {
    height: 32px;
    filter: brightness(1.2);
}

/* SELECTOR DE ESPACIOS EN HEADER */
.selector-espacios {
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.boton-espacio {
    padding: 10px 18px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--color-texto-secundario);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

.boton-espacio:hover {
    color: var(--color-texto-blanco);
    background: rgba(255, 255, 255, 0.05);
}

.boton-espacio.activo-espacio {
    background: var(--color-acento);
    color: var(--color-texto-blanco);
    box-shadow: 0 4px 12px rgba(66, 145, 85, 0.3);
}

.boton-espacio i {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.boton-espacio i svg {
    width: 100%;
    height: 100%;
}

.usuario-superior {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inicial-usuario {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--color-acento);
    color: var(--color-texto-blanco);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 0 15px rgba(66, 145, 85, 0.4);
}

.nombre-usuario {
    font-size: 0.95rem;
    color: var(--color-texto-blanco);
}

/* DROPDOWN PERFIL Y TEMAS */
.usuario-superior {
    position: relative;
}

.perfil-usuario-wrapper {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.perfil-usuario-wrapper:hover {
    background: rgba(255, 255, 255, 0.05);
}

.dropdown-perfil {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--color-fondo-panel);
    border: 1px solid var(--color-borde);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
}

.dropdown-perfil.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-section {
    padding: 8px 0;
}

.dropdown-section:not(:last-child) {
    border-bottom: 1px solid var(--color-borde);
}

.dropdown-title {
    padding: 8px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-texto-tenue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.theme-option,
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--color-texto-secundario);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.theme-option:hover,
.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-texto-blanco);
}

.theme-option.active {
    color: var(--color-acento);
    font-weight: 500;
}

.theme-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-icon svg {
    width: 100%;
    height: 100%;
}

.theme-check {
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 1rem;
}

.theme-option.active .theme-check {
    opacity: 1;
}

.dropdown-item i {
    width: 18px;
    height: 18px;
}

.dropdown-item.logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
}


/* CUERPO PRINCIPAL */
.cuerpo-app {
    display: flex;
    flex: 1;
}

/* SIDEBAR LATERAL */
.menu-lateral {
    width: 220px;
    background-color: var(--color-fondo-panel);
    border-right: 1px solid var(--color-borde);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: width 0.4s cubic-bezier(0.25, 1, 0.5, 1), transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    /* Transición suave */
    position: relative;
    z-index: 50;
}

.titulo-menu {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-texto-tenue);
    margin-top: 16px;
    margin-bottom: 8px;
}

.titulo-menu:first-child {
    margin-top: 0;
}

.opcion-menu {
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--color-texto-secundario);
    font-size: 0.95rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.opcion-menu i {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.opcion-menu i svg {
    width: 100%;
    height: 100%;
}

.opcion-menu:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--color-texto-blanco);
}

.opcion-menu.activo-menu {
    background-color: var(--color-acento);
    color: var(--color-texto-blanco);
}

/* SIDEBAR COLAPSADO (Estado) */
body.sidebar-collapsed .menu-lateral {
    width: 80px;
    padding: 24px 12px;
}

body.sidebar-collapsed .titulo-menu {
    opacity: 0;
    pointer-events: none;
    height: 0;
    margin: 0;
    overflow: hidden;
    transition: opacity 0.2s;
}

body.sidebar-collapsed .opcion-menu {
    justify-content: center;
    padding: 12px 0;
    font-size: 0;
    /* OCULTAR TEXTO: Truco para nudos de texto sin span */
}

/* No necesitamos ocultar span si usamos font-size: 0 en el padre */
/* body.sidebar-collapsed .opcion-menu span { display: none; } */

body.sidebar-collapsed .opcion-menu i {
    width: 24px;
    height: 24px;
    margin: 0;
    font-size: 1rem;
    /* Restaurar tamaño para iconos si fueran fuente (aunque son SVG) */
}

/* Botón de Colapso (REDISEÑADO) */
.btn-toggle-sidebar {
    margin-top: auto;
    width: 32px;
    height: 32px;
    background: var(--color-fondo-bloque);
    border: 1px solid var(--color-borde);
    border-radius: 50%;
    color: var(--color-texto-secundario);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    align-self: flex-end;
}

body.sidebar-collapsed .btn-toggle-sidebar {
    align-self: center;
    transform: rotate(180deg);
}

.btn-toggle-sidebar:hover {
    background: var(--color-acento);
    color: white;
    border-color: var(--color-acento);
    box-shadow: 0 0 10px rgba(66, 145, 85, 0.4);
}

.btn-toggle-sidebar svg {
    width: 16px;
    height: 16px;
}


/* ZONA DE CONTENIDO PRINCIPAL */
.zona-contenido {
    flex: 1;
    padding: 32px 40px;
    overflow-y: scroll;
    /* Forzar scrollbar para evitar saltos de layout */
    height: calc(100dvh - 73px);
    /* Altura exacta restando el header */
}

/* COMPONENTES COMUNES (Dashboard / Insights) */
.dashboard-card {
    background: var(--color-fondo-tarjeta);
    border: 1px solid var(--color-borde);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}

/* BLOQUE SUPERIOR REFINADO */
.titulo-seccion-superior {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 32px;
}

.info-titular h1 {
    margin-bottom: 8px;
}

.dashboard-card h3 {
    color: var(--color-texto-blanco);
    font-size: 1.1rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    display: inline-block;
    background: var(--color-fondo-panel);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* BOTONES GENERALES */
.boton-primario {
    background-color: var(--color-acento);
    color: var(--color-texto-blanco);
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    font-family: inherit;
}

.boton-primario:hover {
    background-color: var(--color-acento-hover);
}

.boton-secundario {
    background-color: transparent;
    color: var(--color-texto-secundario);
    padding: 10px 18px;
    border: 1px solid var(--color-borde);
    border-radius: 10px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.boton-secundario:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--color-texto-blanco);
    border-color: var(--color-texto-secundario);
}

/* MODALES & TOASTS (UI System) */

/* Overlay con Blur */
.modal-overlay-ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: rgba(5, 6, 8, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    animation: fadeIn 0.2s forwards;
}

.modal-content-ui {
    background: var(--color-fondo-panel);
    border: 1px solid var(--color-borde);
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-content-ui h3 {
    color: var(--color-texto-blanco);
    font-size: 1.25rem;
    margin-bottom: 12px;
}

.modal-content-ui p {
    color: var(--color-texto-secundario);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 24px;
}

.modal-actions-ui {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-actions-ui button {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-cancel-ui {
    background: transparent;
    border: 1px solid var(--color-borde);
    color: var(--color-texto-secundario);
}

.btn-cancel-ui:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-texto-blanco);
}

.btn-confirm-ui {
    background: var(--color-acento);
    border: none;
    color: white;
}

.btn-confirm-ui:hover {
    background: var(--color-acento-hover);
    transform: translateY(-1px);
}

/* TOASTS */
.toast-container-ui {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 11000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast-ui {
    background: var(--color-fondo-panel);
    border: 1px solid var(--color-borde);
    padding: 16px 20px;
    border-radius: 12px;
    color: var(--color-texto-blanco);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
    overflow: hidden;
}

.toast-ui::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.toast-success::before {
    background: #429155;
}

.toast-error::before {
    background: #EF4444;
}

.toast-info::before {
    background: #3B82F6;
}

/* Iconos Toast */
.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-content {
    flex: 1;
    font-size: 0.9rem;
}

/* Animations */
@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    to {
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOutRight {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* RESPONSIVE DESIGN (Mobile) - MOVED TO BOTTOM FOR SPECIFICITY */
@media (max-width: 768px) {

    /* Mostrar Hamburguesa en Móvil */
    .btn-hamburger {
        display: flex !important;
    }

    /* Layout Switch */
    .cuerpo-app {
        flex-direction: column;
    }

    /* Sidebar - Mobile Drawer */
    .menu-lateral {
        position: fixed;
        top: 0;
        left: 0;
        height: 100dvh;
        z-index: 2000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
        width: 250px;
        /* Ancho fijo para móvil */
    }

    /* Cuando está activo (abierto) */
    .menu-lateral.mobile-open {
        transform: translateX(0);
    }

    /* Ajuste para sidebar colapsado en móvil (lo ignoramos o forzamos expandido) */
    body.sidebar-collapsed .menu-lateral {
        width: 250px;
        padding: 24px 16px;
    }

    body.sidebar-collapsed .titulo-menu {
        display: block;
    }

    body.sidebar-collapsed .opcion-menu {
        justify-content: flex-start;
        padding: 10px 12px;
        font-size: 0.95rem;
        gap: 10px;
    }

    body.sidebar-collapsed .opcion-menu i {
        margin: 0;
    }

    /* Header Mobile Refinado */
    .encabezado-app {
        padding: 16px 24px;
        /* AUMENTADO: Mayor margen lateral */
        gap: 12px;
        flex-wrap: wrap;
        /* Permitir que el selector baje */
    }

    .logo-app {
        font-size: 1.1rem;
        flex: 1;
        flex: 0 0 auto;
    }

    .logo-app img {
        height: 24px;
    }

    /* Usuario - Solo Avatar en Móvil */
    .usuario-superior .nombre-usuario {
        display: none;
    }

    /* Asegurar que Hamburguesa, Logo y Usuario estén en la primera fila */
    .btn-hamburger,
    .logo-app,
    .usuario-superior {
        z-index: 2;
    }

    .usuario-superior {
        margin-left: auto;
    }

    /* Selector Espacios - INTEGRADO EN HEADER (2da Fila) */
    .selector-espacios {
        position: static;
        order: 3;
        width: 100%;
        background: transparent;
        padding: 8px 0;
        /* Más espacio vertical visual */
        border: none;
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        justify-content: center;
        gap: 12px;
        /* Más separación entre botones */
        -webkit-overflow-scrolling: touch;
    }

    .selector-espacios::-webkit-scrollbar {
        display: none;
    }

    /* Tipografía Responsiva Global */
    h1 {
        font-size: 1.5rem !important;
        /* Reducir títulos gigantes */
        line-height: 1.2;
    }

    h2 {
        font-size: 1.2rem !important;
    }

    .titulo-principal {
        font-size: 1.5rem !important;
    }

    .descripcion-principal {
        font-size: 0.9rem !important;
    }

    .boton-espacio {
        flex: 0 0 auto;
        padding: 10px 18px;
        /* Botones más grandes y touch-friendly */
        font-size: 0.95rem;
        /* Texto más legible */
        background: rgba(255, 255, 255, 0.08);
        /* Fondo base más visible */
        border-radius: 12px;
        /* Más redondeado estilo iOS/Moderno */
        border: 1px solid rgba(255, 255, 255, 0.05);
        color: var(--color-texto-secundario);
        font-weight: 500;
        transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    }

    .boton-espacio.activo-espacio {
        background: var(--color-acento);
        color: white;
        box-shadow: 0 4px 12px rgba(66, 145, 85, 0.4);
        /* Glow sutil */
        border-color: transparent;
        transform: translateY(-1px);
    }

    /* Ajuste padding body */
    .zona-contenido {
        padding: 24px;
        /* AUMENTADO: Más aire a los costados */
        flex: 1;
        height: auto;
        min-height: 50vh;
        overflow-y: visible;
        padding-bottom: 80px;
    }

    /* Overlay Oscuro */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100dvh;
        background: rgba(0, 0, 0, 0.6);
        z-index: 1500;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s;
        backdrop-filter: blur(2px);
    }

    .mobile-overlay.visible {
        opacity: 1;
        visibility: visible;
    }

    /* Dashboard Cards Stack */
    .titulo-seccion-superior {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .acciones-titular {
        width: 100%;
    }

    .boton-primario {
        width: 100%;
        justify-content: center;
    }
}
/* Estilos para acciones en Bloque de Clase (Horario) */
.bloque-clase {
    /* Ya tiene position absolute inline, esto asegura contexto por si acaso */
    position: absolute; 
    border-radius: 6px;
    padding: 6px 8px;
    color: white;
    font-size: 0.8rem;
    overflow: hidden;
    transition: transform 0.2s, z-index 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.bloque-clase:hover {
    z-index: 10;
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.bloque-clase h4 {
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 20px; /* Espacio para el botón */
}

.bloque-clase p {
    font-size: 0.75rem;
    opacity: 0.9;
    margin-bottom: 2px;
    line-height: 1.1;
}

.acciones-clase {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 5;
}

.btn-eliminar-clase {
    background: rgba(0, 0, 0, 0.2);
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-eliminar-clase:hover {
    background: rgba(239, 68, 68, 0.8); /* Rojo alerta */
    color: white;
}
