/* css/layout.css - App Shell, Sidebar, Topbar */

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #030512;
}

.sa-app {
    display: flex;
    width: 100%;
    min-height: 100vh;
    /* Permite que el app shell crezca */
    background: #030512;
}

.sa-sidebar {
    width: 260px;
    background: linear-gradient(180deg, #020617 0%, #1e293b 70%, #4c1d95 100%);
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 20px 18px;
    box-sizing: border-box;
    position: relative;
}

.sa-sidebar::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(180deg, transparent 0%, #a855f7 100%);
}

.sa-logo {
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sa-logo img {
    max-width: 100%;
    height: auto;
    max-height: 40px;
}

.sa-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sa-nav-item {
    border: none;
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #e5e7eb;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.sa-nav-item:hover:not(.sa-nav-item--active) {
    background: rgba(124, 58, 237, 0.1);
}

.sa-nav-item--active {
    background: var(--gradient-sa);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.4);
}

.sa-sidebar-footer {
    margin-top: auto;
    padding: 16px;
    padding-bottom: 24px;
    z-index: 2;
    width: 100%;
    box-sizing: border-box;
}

.sa-login-btn {
    width: 100%;
    border-radius: 999px;
    border: 1px solid var(--border-slate);
    background: rgba(15, 23, 42, 0.6);
    color: #e5e7eb;
    font-size: 0.8rem;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
}

.sa-login-btn:hover {
    background: rgba(15, 23, 42, 0.9);
    border-color: var(--accent-blue);
}

.sa-login-img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sa-user-text {
    display: block;
    flex: 0 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.sa-main {
    flex: 1;
    background: #030512;
    overflow: hidden;
    /* Mantiene la barra scroll oculta al inicio */
    overflow-x: hidden;
    height: 100%;
    position: relative;
    scrollbar-gutter: stable;
    /* Evita saltos cuando aparece el scroll */
}

/* Contenedor Maestro que controla la expansión de los módulos */
.sa-content-container {
    width: 96%;
    /* Deja solo un 2% de margen negro a cada lado */
    max-width: 1800px;
    /* Evita que en monitores ultra-wide se deforme */
    margin: 0 auto;
    /* Centra todo el bloque */
    padding: 5px 0 20px 0 !important;
    /* Ajuste milimétrico solicitado */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Succión vertical: Espacio de 8px con la cabecera */
    min-height: 100%;
}

.sa-topbar {
    display: flex;
    justify-content: space-between;
    align-items: baseline !important;
    /* Alineación milimétrica baseline */
    width: 100%;
    box-sizing: border-box;
    padding: 5px 0 0 0 !important;
    margin-bottom: 0;
    /* Controlado por el gap de 8px del container */
}

.sa-subtitle {
    margin: 0;
    font-size: 0.9rem;
    color: #94a3b8;
    line-height: 1;
    /* Elimina espacio extra sobre las letras */
    font-family: inherit;
}

.sa-center-layout {
    display: flex;
    flex-direction: column;
    gap: 12px !important;
    /* Compresión entre módulos de 12px */
    width: 100%;
    max-width: 100%;
    padding: 0;
    box-sizing: border-box;
}

.sa-chat,
.sa-upload,
.sa-report,
.sa-dashboard-module {
    margin-top: 0 !important;
    /* Succión hacia arriba */
}

/* Mandatory Login / Locked State (V13 Absolute Grayscale) */
.sa-app--locked .sa-sidebar {
    background: #030512 !important;
}

.sa-app--locked .sa-sidebar::after,
.sa-app--locked .sa-sidebar {
    border-image: none !important;
    border-bottom-color: #262626 !important;
}

.sa-app--locked .sa-sidebar::after {
    background: #262626 !important;
}

.sa-app--locked .sa-main {
    background: #030512 !important;
}

.sa-app--locked .sa-logo img,
.sa-app--locked .sa-nav,
.sa-app--locked .sa-main {
    filter: grayscale(100%) !important;
    pointer-events: none;
    opacity: 0.6;
}

.sa-app--locked .sa-subtitle,
.sa-app--locked #sa-active-service-pill {
    display: none !important;
}

/* Solo el botón Log In permanece funcional y con color vibrante */
.sa-app--locked .sa-sidebar-footer {
    filter: none !important;
    pointer-events: auto !important;
    opacity: 1 !important;
}

.sa-app--locked .sa-login-btn {
    filter: none !important;
    background: var(--gradient-sa) !important;
    /* Forzar gradiente lila/verde */
    border: none !important;
    color: white !important;
    opacity: 1 !important;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4) !important;
}

@media (max-width: 768px) {
    .sa-app {
        flex-direction: column;
        min-height: auto;
        overflow: auto;
    }

    .sa-sidebar {
        width: 100%;
        align-items: center;
        padding: 10px 12.5%;
        background: var(--bg-dark);
        border-bottom: 1px solid transparent;
        border-image: linear-gradient(90deg, transparent, #38bdf8, #6366f1, transparent) 1;
        z-index: 50000;
        position: relative;
    }

    .sa-sidebar::after {
        display: none;
    }

    .sa-topbar {
        flex-direction: row;
        /* Mantiene fila para poder alinear a la derecha */
        justify-content: flex-end;
        align-items: center;
        gap: 0;
        margin-bottom: 0 !important;
    }

    .sa-subtitle {
        display: none !important;
        /* Ocultar en móvil como se solicitó */
    }

    .sa-content-container {
        width: 100%;
        padding: 5px 15px;
        /* Reducción de padding superior */
        gap: 5px;
        /* Succión vertical adicional en móvil */
    }

    .sa-nav {
        flex-direction: row;
        overflow-x: auto;
        width: 100%;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    /* Ocultar barra de scroll en móvil (global) */
    * {
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }

    *::-webkit-scrollbar {
        display: none !important;
    }

    .sa-main {
        padding: 5px 0 60px 0 !important;
    }
}

/* Page Label (Top Right) - Restored White Border */
.sa-pill--service {
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    font-weight: 500;
    padding: 6px 16px;
    border-radius: 99px;
}