/**
 * Layout.css - Estructura Inmutable V2
 * 
 * Este archivo solo maneja dimensiones y posiciones.
 * Los colores y fuentes vienen de las CSS Variables inyectadas.
 */

:root {
    --sidebar-width: 280px;
    --header-height: 80px;
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

.shell-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    height: 100vh; /* Altura fija de la ventana */
    width: 100%;
    overflow: hidden; /* Bloquea el scroll del body */
}

#main-sidebar {
    width: var(--sidebar-width);
    background-color: var(--brand-primary);
    color: white;
    height: 100vh;
    position: relative; /* Ya no necesita sticky/fixed porque el shell no scrollea */
    padding: 2rem;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: left var(--transition-speed) ease, width var(--transition-speed) ease;
}

#view-container {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-body);
    min-width: 0;
    height: 100vh;
    overflow-y: auto; /* El scroll ahora vive aquí */
    -webkit-overflow-scrolling: touch;
}

#top-bar {
    min-height: var(--header-height);
    padding: 0.75rem 3rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: white;
    border-bottom: 1px solid #f0f0f0;
}

#content-area {
    padding: 3rem;
    flex: 1;
}

/* --- UTILIDADES GLOBALES (DISPONIBLES EN TODAS LAS RESOLUCIONES) --- */
.sidebar-overlay {
    display: none;
}

.table-container-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.hide-mobile {
    /* Por defecto es visible, se oculta en @media */
    display: block; 
}

/* Utilidades de Marca */
.btn-primary {
    background-color: var(--brand-primary);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    transition: opacity var(--transition-speed);
}

.btn-primary:hover {
    opacity: 0.9;
}

.text-accent {
    color: var(--brand-secondary);
}

/* --- COMPONENTES ATÓMICOS: INPUTS & SELECTS --- */
.login-input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-family: var(--brand-font);
    font-weight: 700;
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition-speed) ease;
    background-color: #fafafa;
}

.login-input:focus {
    border-color: var(--brand-primary);
    background-color: white;
}

/* --- DISENO GLOBAL DE MODALES V2 --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    z-index: 1500;
    align-items: center;
    justify-content: center;
}

.modal-card {
    background: white;
    padding: 2.5rem;
    border-radius: 32px;
    border: 1px solid #f0f0f0;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: #fafafa;
    border: 1px solid #eee;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--text-muted);
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-style: solid;
}

.modal-close-btn:hover {
    background: #f0f0f0;
    color: var(--text-main);
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--brand-primary);
    margin-top: 0;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: -0.5px;
}

.modal-subtitle {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0;
    margin-bottom: 2rem;
}

.label-tiny {
    display: block;
    font-size: 0.7rem;
    font-weight: 900;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
}

/* --- COMPONENTES SAAS: CARDS ESTABLES --- */
.condo-card, .user-card, .theme-card {
    background: white;
    padding: 2.2rem;
    border-radius: 24px;
    border: 1px solid #f0f0f0;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: 250px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.01);
}

.condo-card:hover, .user-card:hover, .theme-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.06);
    border-color: var(--brand-primary);
}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 1024px) {
    .shell-container {
        grid-template-columns: 1fr;
        padding: 0 !important;
    }

    #main-sidebar {
        position: fixed;
        left: -280px;
        width: 280px;
        box-shadow: 20px 0 50px rgba(0,0,0,0.1);
    }

    #main-sidebar.active {
        left: 0;
    }

    #top-bar {
        padding: 1rem 1.25rem;
        height: auto;
        min-height: var(--header-height);
    }

    #content-area {
        padding: 1rem 0.75rem;
    }

    .sidebar-overlay.active {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.3);
        backdrop-filter: blur(4px);
        z-index: 90;
    }

    .hide-mobile {
        display: none !important;
    }

    .mobile-stack {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .full-width-mobile {
        width: 100% !important;
        max-width: none !important;
    }

    /* Filtros en Cuadrícula */
    .filter-grid-mobile {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    .nav-filter {
        flex: 1 1 calc(50% - 0.5rem) !important;
        padding: 0.8rem 0.5rem !important;
        font-size: 0.6rem !important;
        text-align: center;
        min-width: 120px;
    }

    /* Cards de Datos */
    .mobile-data-card {
        background: white;
        padding: 1rem;
        border-radius: 16px;
        border: 1px solid #f0f0f0;
        margin-bottom: 0.8rem;
        display: flex;
        flex-direction: column;
        gap: 0.6rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.02);
        width: 100%;
        box-sizing: border-box;
    }

    .mobile-data-card .card-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .text-balance-mobile {
        font-size: 0.85rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}
