/* ==========================================
   Hub Core — Design System Foundation
   Tokens: var(--hub-*) como fonte da verdade
   Retrocompatibilidade: var(--beto-*) mantido via aliases em :root
   ========================================== */

/* --- :root — Tokens Fundamentais + Retrocompatibilidade --- */
:root {
    /* ==========================================
       1. TOKENS FUNDAMENTAIS HUB (Fonte da Verdade)
       ========================================== */
    /* Cores Base */
    --hub-bg: #111111;
    --hub-surface: #171717;
    --hub-surface-raised: #1d1d1d;
    --hub-surface-hover: rgba(255, 255, 255, 0.03);
    --hub-border: rgba(255, 255, 255, 0.06);
    --hub-border-strong: rgba(255, 255, 255, 0.11);

    /* Texto */
    --hub-text: #ffffff;
    --hub-text-muted: #a6a6a6;
    --hub-text-inverse: var(--hub-bg);

    /* Ação e Estados */
    --hub-primary: #cb7b37;
    --hub-primary-hover: #e09a5c;
    --hub-success: #4f9768;
    --hub-warning: #c19138;
    --hub-danger: #be524b;
    --hub-info: #447acb;

    /* Tipografia — Tamanhos */
    --hub-text-eyebrow: 10px;
    --hub-text-label: 11px;
    --hub-text-chip: 11px;
    --hub-text-table: 12px;
    --hub-text-body: 13px;
    --hub-text-card-title: 15px;
    --hub-text-heading: 18px;
    --hub-text-page: 24px;

    /* Tipografia — Pesos */
    --hub-weight-extralight: 200;
    --hub-weight-light: 300;
    --hub-weight-medium: 500;
    --hub-weight-semibold: 600;
    --hub-weight-bold: 700;

    /* Tipografia — Line-height */
    --hub-leading-tight: 1.12;
    --hub-leading-snug: 1.25;
    --hub-leading-normal: 1.45;

    /* Cores de texto sobre fundo semântico */
    --hub-text-on-success: #d9f3df;
    --hub-text-on-warning: #f3d89c;
    --hub-text-on-danger: #ffd5d1;
    --hub-text-on-info: #a9c3f4;
    --hub-text-on-primary: #140c06;

    /* Forma e Densidade */
    --hub-radius: 4px;
    --hub-control-height: 36px;
    --hub-button-height: 36px;
    --hub-view-section-gap: 16px;
    /* Tokens de Suporte (Fase 1) */
    --hub-input-bg: #050505;
    --hub-overlay-bg: rgba(0, 0, 0, 0.58);
    --hub-shell-header-height: 68px;
    --hub-surface-soft: #181818;

    /* Casca de Modal / Drawer (Canônico v2) */
    --hub-modal-bg: var(--hub-surface);
    --hub-modal-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    --hub-modal-head-padding: 16px var(--space-m);
    --hub-modal-body-padding: var(--space-m);
    --hub-modal-footer-padding: 12px var(--space-m);
    --hub-modal-width-sm: 480px;
    --hub-modal-width-md: 760px;
    --hub-modal-width-lg: 920px;
    --hub-drawer-width-narrow: 460px;
    --hub-drawer-width-record: clamp(640px, 48vw, 760px);
    --hub-drawer-width-wide: clamp(720px, 54vw, 880px);

    /* ==========================================
       2. TOKENS ESTRUTURAIS E DE APOIO (Sem equivalentes --hub-*)
       ========================================== */
    --space-xs: 8px;
    --space-s: 16px;
    --space-m: 24px;
    --space-l: 40px;
    --space-xl: 64px;
    --beto-rose: #ba4a78;
    --beto-brown: #a27763;
    --beto-gray: #d4d4d4;
    --beto-surface-3: #202020;
    --beto-rail-width: 72px;
    --beto-sidebar-width: 268px;
    --beto-strategy-sidebar-width: 348px;
    --beto-chart-height: 280px;
    --beto-table-primary-col-width: 280px;
    --beto-matrix-unit-col-width: 320px;
    --beto-matrix-value-col-width: 104px;
    --beto-font: "Albert Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    /* Aliases de retrocompatibilidade ativos (Categoria 3: Estruturais) */
    --beto-radius: var(--hub-radius);
    --beto-card-bg: var(--hub-surface-soft);
    --beto-card-bg-soft: var(--hub-surface);
    --beto-card-border: var(--hub-border);
    --beto-top-block-height: var(--hub-shell-header-height);
}

/* --- Reset & Base --- */
html:has(.beto-app) {
    margin-top: 0 !important; /* FSE */
    padding-top: 0 !important; /* FSE */
}

html:has(.beto-app) #wpadminbar {
    display: none !important; /* FSE */
}

body:has(.beto-app) {
    overflow: hidden !important; /* FSE */
    padding: 0 !important; /* FSE */
    margin: 0 !important; /* FSE */
}

/* Achatamento universal de todos os contêineres ancestrais do Hub */
body:has(.beto-app) :has(.beto-app) {
    display: block !important; /* FSE */
    position: static !important; /* FSE */
    max-width: none !important; /* FSE */
    width: auto !important; /* FSE */
    height: auto !important; /* FSE */
    padding: 0 !important; /* FSE */
    margin: 0 !important; /* FSE */
    transform: none !important; /* FSE */
    perspective: none !important; /* FSE */
    filter: none !important; /* FSE */
    container-type: normal !important; /* FSE */
    contain: none !important; /* FSE */
    will-change: auto !important; /* FSE */
    box-shadow: none !important; /* FSE */
}

/* Ocultação cirúrgica de cabeçalhos, rodapés e títulos de página do tema */
body:has(.beto-app) header:not(.beto-app *),
body:has(.beto-app) footer:not(.beto-app *),
body:has(.beto-app) .wp-block-template-part:not(.beto-app *),
body:has(.beto-app) h1.wp-block-post-title,
body:has(.beto-app) .wp-block-post-title {
    display: none !important; /* FSE */
}


.beto-app,
.beto-app * {
    box-sizing: border-box;
}

/* --- Scrollbar --- */
.beto-app *::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.beto-app *::-webkit-scrollbar-track {
    background: transparent;
}

.beto-app *::-webkit-scrollbar-thumb {
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
}

.beto-app *::-webkit-scrollbar-thumb:hover {
    background: rgba(203, 123, 55, 0.42);
}

/* --- Skeleton Loading --- */
@keyframes skeletonLoading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.beto-skeleton {
    background: linear-gradient(90deg, var(--hub-surface) 25%, rgba(255, 255, 255, 0.05) 50%, var(--hub-surface) 75%);
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s infinite;
    border-radius: 4px;
    color: transparent !important; /* REMOVIBLE */
}

/* --- Login --- */
.beto-app.beto-login-wrapper {
    align-items: center;
    justify-content: center;
    padding: var(--space-m);
    background:
        radial-gradient(circle at 50% 0, rgba(203, 123, 55, 0.12), transparent 30%),
        radial-gradient(circle at 0 100%, rgba(186, 74, 120, 0.12), transparent 34%),
        var(--hub-bg);
}

.beto-login-box {
    width: min(100%, 430px);
    padding: var(--space-l);
    border: 1px solid var(--hub-border);
    border-radius: var(--hub-radius);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 44%),
        var(--hub-surface);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(203, 123, 55, 0.08);
}

.beto-login-brand {
    margin-bottom: var(--space-m);
    padding-bottom: var(--space-m);
    border-bottom: 1px solid var(--hub-border);
    font-family: var(--beto-font);
    text-align: left;
}

.beto-login-desc {
    margin: 0 0 var(--space-m);
    color: var(--hub-text-muted);
    font-size: var(--hub-text-body);
    line-height: var(--hub-leading-normal);
}

.beto-login-box form {
    display: grid;
    gap: var(--space-s);
    margin: 0;
}

.beto-login-box p {
    margin: 0;
}

.beto-login-box label {
    display: grid;
    gap: 7px;
    color: var(--hub-text-muted);
    font-size: var(--hub-text-label);
    font-weight: var(--hub-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.beto-login-box input[type="text"],
.beto-login-box input[type="password"] {
    width: 100%;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--hub-border-strong);
    border-radius: var(--hub-radius);
    outline: none;
    background: var(--hub-input-bg);
    color: var(--hub-text);
    font-family: var(--beto-font);
    font-size: var(--hub-text-card-title);
}

.beto-login-box input[type="text"]:focus,
.beto-login-box input[type="password"]:focus {
    border-color: rgba(203, 123, 55, 0.72);
    box-shadow: 0 0 0 3px rgba(203, 123, 55, 0.16);
}

.beto-login-box .login-remember label {
    display: flex;
    align-items: center;
    gap: 9px;
    text-transform: none;
    letter-spacing: 0;
    font-size: var(--hub-text-table);
    font-weight: var(--hub-weight-semibold);
}

.beto-login-box input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--hub-primary);
}

.beto-login-box .login-submit {
    margin-top: var(--space-xs);
}

.beto-login-box input[type="submit"] {
    width: 100%;
    min-height: 42px;
    border: 1px solid rgba(203, 123, 55, 0.55);
    border-radius: var(--hub-radius);
    background: linear-gradient(180deg, var(--hub-primary-hover), var(--hub-primary));
    color: var(--hub-text-on-primary);
    cursor: pointer;
    font-family: var(--beto-font);
    font-size: var(--hub-text-body);
    font-weight: var(--hub-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.beto-login-box input[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(203, 123, 55, 0.18);
}

/* --- SPA Shell --- */
.beto-app {
    position: fixed !important; /* FSE */
    top: 0 !important; /* FSE */
    left: 0 !important; /* FSE */
    width: 100vw !important; /* FSE */
    height: 100vh !important; /* FSE */
    max-width: none !important; /* FSE */
    max-height: none !important; /* FSE */
    z-index: 9999 !important; /* FSE */
    display: flex;
    overflow: hidden;
    margin: 0 !important; /* FSE */
    border-radius: 0 !important; /* FSE */
    background:
        radial-gradient(circle at 0 100%, rgba(186, 74, 120, 0.12), transparent 34%),
        linear-gradient(135deg, var(--hub-input-bg) 0%, var(--hub-bg) 52%, #0f0f0f 100%);
    color: var(--hub-text);
    font-family: var(--beto-font);
    font-weight: var(--hub-weight-extralight);
    line-height: var(--hub-leading-snug);
    letter-spacing: 0;
}

/* --- Tipografia Universal (Hub Design System §2) --- */
.beto-app,
.beto-app *,
.beto-app *::before,
.beto-app *::after {
    font-family: var(--beto-font);
}

/* --- Rail (Navegação Principal) --- */
.beto-rail {
    flex: 0 0 var(--beto-rail-width);
    width: var(--beto-rail-width);
    min-width: var(--beto-rail-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-l);
    padding: var(--space-s) 0;
    overflow: visible;
    border-right: 1px solid rgba(255, 255, 255, 0.07);
    background:
        linear-gradient(180deg, rgba(203, 123, 55, 0.2), transparent 18%),
        radial-gradient(circle at 50% 100%, rgba(186, 74, 120, 0.16), transparent 44%),
        #0f0f0f;
}

.beto-rail__brand {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
    text-decoration: none;
}

.beto-rail__brand img {
    width: 26px;
    height: 26px;
    display: block;
    object-fit: contain;
}

.beto-rail .beto-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin: 0;
    padding-top: var(--space-s);
}

.beto-rail .beto-tab {
    min-height: 68px;
    display: grid;
    place-items: center;
    gap: 6px;
    padding: 8px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.48);
}

.beto-rail .beto-tab::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 3px;
    background: transparent;
}

.beto-rail .beto-tab:hover {
    background: rgba(255, 255, 255, 0.035);
    color: var(--hub-text);
}

.beto-rail__icon {
    width: 30px;
    height: 30px;
    display: grid !important; /* REMOVIBLE */
    place-items: center;
    border-radius: 8px;
    background: transparent;
    color: currentColor;
    line-height: 1;
}

.beto-rail__icon svg {
    width: 22px;
    height: 22px;
    display: block;
    fill: currentColor;
}

.beto-rail__label {
    max-width: 100%;
    color: currentColor;
    font-size: var(--hub-text-eyebrow);
    line-height: 1.05;
    font-weight: var(--hub-weight-medium);
    letter-spacing: 0;
    text-transform: none;
}

.beto-rail .beto-notification-badge {
    top: 7px;
    right: 8px;
}

.beto-rail .beto-system-menu {
    position: relative;
    right: auto;
    bottom: auto;
    z-index: 2;
    margin-top: auto;
}

.beto-rail .beto-system-menu__panel {
    right: auto;
    bottom: 0;
    left: calc(100% + var(--space-xs));
}

/* --- Sidebar (Painel Contextual) --- */
.beto-sidebar {
    flex: 0 0 var(--beto-sidebar-width);
    width: var(--beto-sidebar-width);
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-s);
    padding: var(--space-s);
    overflow-y: auto;
    overflow-x: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 34%),
        radial-gradient(circle at 0 100%, rgba(186, 74, 120, 0.13), transparent 34%),
        var(--hub-bg);
    border-right: 1px solid var(--hub-border);
    transition: flex-basis 220ms ease, width 220ms ease, padding 220ms ease, border-color 220ms ease;
}

.beto-app.is-context-collapsed .beto-sidebar {
    flex-basis: 0;
    width: 0;
    padding-right: 0;
    padding-left: 0;
    border-right-color: transparent;
}

.beto-context-toggle {
    position: fixed;
    top: 50%;
    left: calc(var(--beto-rail-width) + var(--beto-sidebar-width) - 15px);
    z-index: 100040;
    width: 30px;
    height: 54px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(203, 123, 55, 0.38);
    border-radius: 999px;
    background:
        linear-gradient(180deg, rgba(203, 123, 55, 0.15), rgba(255, 255, 255, 0.025)),
        var(--hub-bg);
    color: var(--hub-primary-hover);
    cursor: pointer;
    transform: translateY(-50%);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.48);
    transition: left 220ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

@media (min-width: 861px) {
    .beto-context-toggle {
        display: none;
    }

    .beto-app:not([data-view="estrategia"]):not([data-view="simulador"]) .beto-sidebar {
        flex-basis: 0;
        width: 0;
        padding-right: 0;
        padding-left: 0;
        border-right-color: transparent;
    }

    .beto-app[data-view="estrategia"] .beto-sidebar,
    .beto-app[data-view="simulador"] .beto-sidebar,
    .beto-app.is-context-collapsed[data-view="estrategia"] .beto-sidebar,
    .beto-app.is-context-collapsed[data-view="simulador"] .beto-sidebar {
        flex-basis: 0;
        width: 0;
        padding-right: 0;
        padding-left: 0;
        border-right-color: transparent;
    }
}

.beto-app[data-view="estrategia"] .beto-sidebar,
.beto-app[data-view="simulador"] .beto-sidebar,
.beto-app[data-view="estrategia"] .beto-context-toggle,
.beto-app[data-view="simulador"] .beto-context-toggle {
    display: none;
}

.beto-context-toggle span {
    display: block;
    font-size: var(--hub-text-page);
    line-height: 1;
    transform: translateX(-1px);
}

.beto-context-toggle:hover {
    border-color: rgba(203, 123, 55, 0.72);
    background: rgba(203, 123, 55, 0.18);
    color: var(--hub-text);
}

.beto-app.is-context-collapsed .beto-context-toggle {
    left: calc(var(--beto-rail-width) + 6px);
}

.beto-app.is-context-collapsed .beto-context-toggle span {
    transform: translateX(1px) rotate(180deg);
}

.beto-sidebar-divider {
    margin: var(--space-xs) 0 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--hub-border);
    color: var(--hub-text-muted);
    font-size: var(--hub-text-eyebrow);
    line-height: 1.2;
    font-weight: var(--hub-weight-semibold);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

/* --- Main Content Area --- */
.beto-app .beto-main {
    flex: 1 !important; /* FSE */
    min-width: 0 !important; /* FSE */
    height: 100vh !important; /* FSE */
    overflow-y: auto !important; /* FSE */
    overflow-x: hidden !important; /* FSE */
    padding: var(--hub-view-section-gap) !important; /* FSE */
    background: transparent !important; /* FSE */
    max-width: none !important; /* FSE */
    margin: 0 !important; /* FSE */
    width: auto !important; /* FSE */
}


/* ==========================================
   Hub Details List — Canônico de Chave-Valor
   ========================================== */
.hub-details-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hub-details-list div,
.hub-details-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed var(--hub-border);
}

.hub-details-list div:last-child,
.hub-details-list li:last-child {
    border-bottom: none;
}

.hub-details-list dt,
.hub-details-list .hub-details-label {
    color: var(--hub-text-muted);
    font-size: var(--hub-text-label);
    margin: 0;
}

.hub-details-list dd,
.hub-details-list .hub-details-value {
    color: var(--hub-text);
    font-weight: var(--hub-weight-extralight);
    font-size: var(--hub-text-table);
    margin: 0;
}

.beto-muted-note {
    color: var(--hub-text-muted);
    font-size: var(--hub-text-body);
    font-weight: var(--hub-weight-extralight);
    line-height: var(--hub-leading-snug);
    margin: var(--space-xs) 0;
}
