/* =========================================
   LAYOUT PRINCIPAL
   ========================================= */

/* Header: Altura fija de 60px (necesaria para el cálculo del layout) */
.main-header {
    background: #000;
    height: 60px;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-img {
    height: 40px;
}

.brand-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.system-title {
    font-size: 0.9rem;
    font-family: var(--font-heading);
    letter-spacing: 0.1em;
    line-height: 1;
    margin: 0;
    color: var(--primary-color);
}

.system-subtitle {
    font-size: 0.6rem;
    color: #A1A1AA;
    text-transform: uppercase;
    margin-top: 2px;
}

.complex-name-header {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
    text-transform: uppercase;
    text-align: center;
    flex: 1;
}

/* Layout: Ocupa el resto de la pantalla (100vh - 60px) */
.app-layout {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    height: calc(100vh - 60px);
    overflow: hidden;
    /* Scroll bloqueado a nivel global */
    width: 100%;
}

/* Área de contenido: Scroll independiente */
.main-content-area {
    flex: 1;
    padding: 20px 40px;
    background: var(--bg-color);
    overflow-y: auto;
    height: 100%;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 20px;
}

/* =========================================
   SIDEBAR (BEM STRICT)
   ========================================= */
.sidebar {
    width: 260px;
    background: #080808;
    border-right: 1px solid #222;
    display: flex;
    flex-direction: column;
    padding: 20px;
    height: 100%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

/* Estado oculto */
.sidebar--hidden {
    width: 0;
    padding: 0;
    border: none;
    overflow: hidden;
    opacity: 0;
}

/* Menú: Items arriba con gap pequeño */
.sidebar__menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Gap solicitado */
    margin: 0;
    padding: 0;
}

/* Ítem del menú */
.sidebar__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #888;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-heading, sans-serif);
    font-size: 0.95rem;
    border-left: 2px solid transparent;
    /* Espacio reservado para borde */
    text-decoration: none;
}

/* Fix para Emojis: Evita cajas de colores y asegura renderizado consistente */
.sidebar__item span {
    font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
    font-size: 1.2rem;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 24px;
    line-height: 1;
    filter: none;
    /* Asegura colores originales, usar grayscale(1) si se prefiere monocromo */
}

/* Hover State */
.sidebar__item:hover {
    background: #1a1a1a;
    color: var(--primary-color);
}

/* Active State */
.sidebar__item--active {
    background: #1a1a1a;
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

/* Botón activo tiene brillo suave en el ícono */
.sidebar__item--active span {
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
}

/* Footer opcional */
.sidebar__footer {
    margin-top: auto;
    padding-top: 20px;
    color: #444;
    font-size: 0.75rem;
    text-align: center;
}

/* MOBILE */
@media (max-width: 900px) {
    .sidebar {
        position: absolute;
        z-index: 1000;
        height: calc(100vh - 60px);
        border-right: 1px solid #333;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
    }

    .complex-name-header {
        font-size: 1rem;
    }
}

/* =========================================
   DASHBOARD GRIDS
   ========================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.dashboard-grid--top-gap {
    margin-top: 20px;
}

/* Header Controls */
.header-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Search Wrappers */
.search-wrapper {
    margin-bottom: 20px;
}

.search-input {
    width: 100%;
    padding: 12px;
    background: #111;
    border: 1px solid #333;
    color: #fff;
    border-radius: 6px;
    font-size: 1rem;
}

/* Admin Stats Panel (formerly inline) */
.admin-stats-panel {
    margin-bottom: 30px;
    background: #000;
    padding: 40px;
    border-radius: 12px;
    border: 1px solid #333;
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-size: 1.8rem;
}

/* Settings Form Container */
.settings-form-container {
    background: #111;
    padding: 30px;
    border-radius: 8px;
}

/* =========================================
   GENERIC LAYOUT HELPERS
   ========================================= */
.flex-row-wrap {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.grid-auto-fit {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

/* Spanning Utilities */
.grid-row-span-2 {
    grid-row: span 2;
}

.flex-1 {
    flex: 1;
}