/**
 * BluePartner Ops Console — 03 · SHELL
 * Estrutura da aplicação: sidebar fixa de comando + frame (topbar + conteúdo).
 *
 *   body.app
 *   ├── aside.app-sidebar (.sidebar)
 *   └── div.app-frame
 *       ├── header.app-topbar (.dashboard-header)
 *       └── main.app-content (.dashboard-main.unified-layout)
 *           └── .main-content  →  #alerts-container · #summary-cards · #table-content
 */

body.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100vh;
    overflow: hidden;
}

/* Containers utilitários fora do fluxo do grid (erros globais, loading de auth) */
body.app > #error-container {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1200;
    width: min(560px, 92vw);
}
body.app > #error-container:empty {
    display: none;
}

/* ═══ SIDEBAR ═══════════════════════════════════════════════════════════ */

.app-sidebar {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg-inset);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Brand lockup */
.sb-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.sb-brand .header-logo {
    height: 32px;
    width: auto;
    filter: drop-shadow(0 0 10px rgba(0, 217, 255, 0.22));
}
[data-theme="light"] .sb-brand .header-logo {
    filter: none;
}
.sb-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}
.sb-brand-name {
    font-size: var(--text-md);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    white-space: nowrap;
}
.sb-brand-sub {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent);
    white-space: nowrap;
}
[data-theme="light"] .sb-brand-sub {
    color: var(--accent-ink);
}

/* Seções */
.sb-section {
    padding: 18px 14px 6px;
}
.sb-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--ink-3);
    margin: 0 4px 10px;
}
.sb-label::before {
    content: "";
    width: 3px;
    height: 11px;
    border-radius: 2px;
    background: var(--accent);
    box-shadow: 0 0 8px rgba(0, 217, 255, 0.45);
    flex-shrink: 0;
}
[data-theme="light"] .sb-label::before {
    box-shadow: none;
}

/* Navegação de serviços */
.navigation-tabs {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.service-tab {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--ink-2);
    cursor: pointer;
    user-select: none;
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.service-tab:hover {
    background: var(--bg-hover);
    color: var(--ink);
}
.service-tab.active {
    background: var(--accent-dim);
    border-color: rgba(0, 217, 255, 0.20);
    color: var(--accent-ink);
    font-weight: 600;
}
[data-theme="light"] .service-tab.active {
    border-color: var(--accent-border);
    color: var(--accent-ink);
}
.service-tab.active::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 7px;
    bottom: 7px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.55);
}
[data-theme="light"] .service-tab.active::before {
    box-shadow: none;
}
.service-tab__icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    opacity: 0.9;
}

/* Filtros */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 0 4px;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-group > label {
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--ink-3);
}

/* Rodapé de sistema */
.sb-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 18px;
    border-top: 1px solid var(--line);
    flex-shrink: 0;
}
.sb-foot-item {
    font-family: var(--font-data);
    font-size: 10.5px;
    letter-spacing: 0.05em;
    color: var(--ink-4);
    white-space: nowrap;
}

/* ═══ FRAME (topbar + conteúdo) ═════════════════════════════════════════ */

.app-frame {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    position: relative;
    z-index: 1;
}

/* ── Topbar ── */
.app-topbar {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--topbar-h);
    padding: 0 var(--gutter);
    background: var(--bg-topbar);
    backdrop-filter: blur(14px) saturate(1.15);
    -webkit-backdrop-filter: blur(14px) saturate(1.15);
    border-bottom: 1px solid var(--line);
}

.tb-left {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}
.tb-crumb {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--ink-3);
    letter-spacing: 0.02em;
}
.tb-sep {
    color: var(--ink-4);
    font-size: var(--text-sm);
}
.tb-title {
    font-size: var(--text-md);
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tb-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Relógio de operação */
.tb-clock {
    display: flex;
    align-items: baseline;
    gap: 7px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--bg-inset);
}
.tb-clock-time {
    font-family: var(--font-data);
    font-size: var(--text-sm);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--ink-2);
}
.tb-clock-zone {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: var(--ink-4);
}

/* ── Conteúdo ── */
.app-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--gutter);
}
.main-content {
    display: flex;
    flex-direction: column;
    gap: var(--gutter);
    max-width: 1720px;
    margin: 0 auto;
    width: 100%;
}

/* Revelação de entrada */
.app-sidebar { animation: rise-in 360ms var(--ease) both; }
.app-topbar { animation: rise-in 360ms var(--ease) 60ms both; }
.main-content > * { animation: rise-in 420ms var(--ease) both; }
.main-content > *:nth-child(2) { animation-delay: 90ms; }
.main-content > *:nth-child(3) { animation-delay: 160ms; }

/* ═══ RESPONSIVO ════════════════════════════════════════════════════════ */

@media (max-width: 1180px) {
    :root { --sidebar-w: 216px; --gutter: 18px; }
}

@media (max-width: 900px) {
    body.app {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }
    .app-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px;
        border-right: none;
        border-bottom: 1px solid var(--line);
        overflow: visible;
    }
    .sb-brand { border-bottom: none; }
    .sb-section { padding: 10px 14px; }
    .sb-footer { display: none; }
    .navigation-tabs { flex-direction: row; flex-wrap: wrap; }
    .service-tab.active::before { display: none; }
    .app-content { overflow: visible; }
}
