/* FBot Ion — shell (sidebar, topbar, gaveta). Depende de fbot-tokens.css. */
:root {
    --sb-w: 248px;
    --sb-w-collapsed: 72px;
    --topbar-h: 64px;
}

.fb-shell {
    display: grid;
    grid-template-columns: var(--sb-w) minmax(0, 1fr);
    min-height: 100vh;
}

.fb-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 120;
    display: flex;
    flex-direction: column;
    padding: 14px 10px;
    background: linear-gradient(180deg, rgba(10, 14, 24, 0.94), rgba(6, 9, 16, 0.97));
    border-right: 1px solid var(--line);
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(130, 170, 255, 0.2) transparent;
}

.fb-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 4px 12px;
}

.fb-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--r);
}

.fb-brand-mark {
    width: 36px;
    height: 36px;
    flex: none;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(47, 140, 255, 0.35));
}

.fb-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.fb-brand-text b { font-family: var(--font-display); font-size: 1.0625rem; font-weight: 700; letter-spacing: -0.01em; }
.fb-brand-text small { font-size: 0.6875rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fb-icon-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: var(--r);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.fb-icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); border-color: var(--line); }
.fb-icon-btn:active { transform: scale(0.97); }
.fb-icon-btn .ic { width: 18px; height: 18px; transition: transform var(--t); }

.fb-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.fb-nav-group { display: flex; flex-direction: column; gap: 2px; }
.fb-nav-label {
    margin: 14px 10px 6px;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-3);
    white-space: nowrap;
}

.fb-nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 0 10px;
    border-radius: var(--r);
    color: var(--text-2);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--t-fast), color var(--t-fast);
}
.fb-nav-item .ic { width: 18px; height: 18px; opacity: 0.85; }
.fb-nav-item:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.fb-nav-item:active { transform: scale(0.985); }
.fb-nav-item.active {
    color: #e6f0ff;
    background: linear-gradient(90deg, rgba(47, 140, 255, 0.2), rgba(47, 140, 255, 0.03));
    box-shadow: inset 0 0 0 1px rgba(90, 168, 255, 0.14);
}
.fb-nav-item.active .ic { opacity: 1; color: var(--brand-hi); }
.fb-nav-item.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--ion);
    box-shadow: 0 0 10px var(--ion);
}
.fb-nav-text { overflow: hidden; text-overflow: ellipsis; }
.fb-nav-meta { margin-left: auto; font-family: var(--mono); font-size: 0.6875rem; color: var(--text-3); }
.fb-nav-item--sm { min-height: 34px; font-size: 0.8125rem; }
.fb-nav-item--danger:hover { color: #fecaca; background: var(--loss-muted); }

.fb-sidebar-foot {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.fb-user { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 10px; color: var(--text-2); font-size: 0.8125rem; }
.fb-user-avatar {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: none;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    color: var(--brand-hi);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.fb-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fb-sidebar-close { display: none; }

.fb-main { display: flex; flex-direction: column; min-width: 0; }

.fb-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: var(--topbar-h);
    padding: 10px 24px;
    background: rgba(7, 10, 18, 0.8);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border-bottom: 1px solid var(--line);
}
.fb-topbar::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(56, 214, 255, 0.35), transparent);
    pointer-events: none;
}
.fb-topbar-menu { display: none; }
.fb-topbar-title { flex: 1 1 auto; min-width: 0; }
.fb-topbar-title h1 { margin: 0; font-family: var(--font-display); font-size: 1.125rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; color: var(--text); }
.fb-topbar-title p { margin: 2px 0 0; font-size: 0.75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-topbar-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; min-width: 0; }

.fb-tabs {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
}
.fb-tabs .panel-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-2);
    font: 600 0.8125rem/1.2 var(--font);
    white-space: nowrap;
    cursor: pointer;
    text-shadow: none;
    transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.fb-tabs .panel-tab .ic { width: 16px; height: 16px; }
.fb-tabs .panel-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.fb-tabs .panel-tab.active {
    color: #e6f0ff;
    background: linear-gradient(180deg, rgba(47, 140, 255, 0.3), rgba(47, 140, 255, 0.14));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 0 1px rgba(90, 168, 255, 0.3);
    border: 0;
}
.fb-tabs .panel-tab.active .ic { color: var(--brand-hi); }

.fb-scrim {
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(2, 4, 8, 0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.fb-scrim[hidden] { display: none; }

@media (min-width: 1024px) {
    .fb-shell { transition: grid-template-columns var(--t) ease; }
    html.fb-sb-collapsed .fb-shell { grid-template-columns: var(--sb-w-collapsed) minmax(0, 1fr); }
    html.fb-sb-collapsed .fb-brand-text,
    html.fb-sb-collapsed .fb-nav-text,
    html.fb-sb-collapsed .fb-nav-meta,
    html.fb-sb-collapsed .fb-user-name { display: none; }
    html.fb-sb-collapsed .fb-sidebar-head { flex-direction: column; padding-inline: 0; }
    html.fb-sb-collapsed .fb-nav-label { height: 1px; margin: 10px 8px; font-size: 0; background: var(--line); }
    html.fb-sb-collapsed .fb-nav-item { justify-content: center; padding: 0; }
    html.fb-sb-collapsed .fb-user { justify-content: center; padding-inline: 0; }
    html.fb-sb-collapsed .fb-sidebar-collapse .ic { transform: rotate(180deg); }
}

@media (max-width: 1023px) {
    .fb-shell { grid-template-columns: minmax(0, 1fr); }
    .fb-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(300px, 86vw);
        height: auto;
        transform: translateX(-100%);
        transition: transform var(--t) ease;
        box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
    }
    html.fb-sb-open { overflow: hidden; }
    html.fb-sb-open .fb-sidebar { transform: none; }
    .fb-sidebar-collapse { display: none; }
    .fb-sidebar-close { display: inline-grid; }
    .fb-topbar-menu { display: inline-grid; }
    .fb-topbar { padding: 10px 16px; gap: 12px; }
}

@media (max-width: 640px) {
    .fb-topbar { flex-wrap: wrap; }
    .fb-topbar-actions { flex: 1 1 100%; justify-content: flex-start; }
    .fb-tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
}

/* Ponto "bot rodando" no item Painel. Só aparece na tela do painel, que conhece o status (#statusBadge). */
html:has(#statusBadge.running) .fb-nav-item[data-nav="painel"]::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 12px;
    width: 7px;
    height: 7px;
    margin-top: -3.5px;
    border-radius: 50%;
    background: var(--gain);
    box-shadow: 0 0 8px var(--gain);
    animation: fb-live 2s ease-in-out infinite;
}
@keyframes fb-live { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@media (min-width: 1024px) {
    html.fb-sb-collapsed:has(#statusBadge.running) .fb-nav-item[data-nav="painel"]::after { top: 9px; right: 14px; margin-top: 0; }
}
