/* Layout do frontend — desenhado sobre os tokens do tokens-acero.css.
   O tema dos componentes Bootstrap fica no acero-bootstrap.css; aqui só a
   moldura: sidebar, topo e área de conteúdo. */

html, body {
    font-family: var(--font);
    height: 100%;
    margin: 0;
    background: var(--app-bg);
    color: var(--text-body);
    -webkit-font-smoothing: antialiased;
}

/* ── Layout principal ───────────────────────────────────────────── */

.page {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
}

main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--app-bg);
}

.top-row {
    background-color: var(--app-bg);
    border-bottom: 1px solid var(--border);
    justify-content: flex-end;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 var(--sp-6);
    position: sticky;
    top: 0;
    z-index: 20;
}

.top-row a, .top-row .btn-link {
    white-space: nowrap;
    text-decoration: none;
}

.top-row a:hover, .top-row .btn-link:hover {
    color: var(--coral-700);
}

article.content {
    flex: 1;
    padding: var(--sp-6) var(--sp-8);
}

/* ── Sidebar ────────────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    transition: width 0.2s ease, min-width 0.2s ease;
}

.sidebar .navbar-brand {
    color: var(--text-strong);
    font-size: var(--fs-h2);
    font-weight: 600;
    padding: 0;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-brand-row {
    border-bottom: 1px solid var(--border);
}

.sidebar .nav-link {
    color: var(--text-body);
    font-size: var(--fs-label);
    padding: 9px var(--sp-4);
    border-radius: var(--radius-pill);
    margin: 2px var(--sp-3);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.sidebar .nav-link:hover {
    color: var(--text-strong);
    background-color: rgba(255, 255, 255, 0.75);
}

/* A pílula branca com sombra é a marca do item ativo na referência. */
.sidebar .nav-link.active {
    color: var(--text-strong);
    background-color: var(--white);
    font-weight: 500;
    box-shadow: var(--shadow-card);
}

.nav-scrollable {
    flex: 1;
    min-height: 0;
    padding: var(--sp-2) 0 var(--sp-4);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--navy-200) transparent;
}

.nav-scrollable::-webkit-scrollbar {
    width: 6px;
}

.nav-scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.nav-scrollable::-webkit-scrollbar-thumb {
    background-color: var(--navy-200);
    border-radius: 3px;
}

.nav-scrollable::-webkit-scrollbar-thumb:hover {
    background-color: var(--navy-400);
}

/* Ocupa todo o espaco que sobra no topo; min-width: 0 e o que permite o flex
   encolher abaixo do conteudo e a reticencia aparecer em nome muito longo. */
.top-row-unidade {
    flex: 1;
    min-width: 0;
    font-size: var(--fs-label);
    font-weight: 600;
    color: var(--text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-row-usuario {
    font-size: var(--fs-caption);
    color: var(--text-muted-strong);
    text-decoration: none;
}

.sidebar .nav-link-toggle {
    background: transparent;
    color: var(--text-strong);
    font-size: var(--fs-label);
    font-weight: 500;
    padding: 9px var(--sp-4);
    border-radius: var(--radius-pill);
    margin: 2px var(--sp-3);
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
}

.sidebar .nav-link-toggle:hover {
    color: var(--text-strong);
    background-color: rgba(255, 255, 255, 0.75);
}

.nav-section-separator {
    border-top: 1px solid var(--border);
    margin: var(--sp-2) var(--sp-4);
}

.sidebar .nav-sublink {
    padding-left: 2rem;
    font-size: var(--fs-caption);
    font-weight: 400;
    color: var(--text-muted-strong);
    margin-left: calc(var(--sp-3) + 12px) !important;
    border-left: 2px solid var(--border);
    border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
}

.sidebar .nav-sublink:hover {
    color: var(--text-strong);
    background-color: rgba(255, 255, 255, 0.75);
}

.sidebar .nav-sublink.active {
    border-left-color: var(--coral-400);
}

.sidebar-erro-menus {
    color: var(--danger);
    font-size: var(--fs-caption);
    word-break: break-all;
}

.sidebar-unidade-selector .form-select {
    background-color: var(--white);
    border: 1px solid var(--border);
    color: var(--text-strong);
    font-size: var(--fs-caption);
    border-radius: var(--radius-pill);
    width: 100%;
    max-width: 100% !important;
}

.sidebar-unidade-selector .form-select:focus {
    border-color: var(--coral-400);
    box-shadow: 0 0 0 3px rgba(229, 130, 79, 0.25);
}

/* ── Toggle sidebar ─────────────────────────────────────────────── */

.sidebar-toggle-chk {
    display: none;
}

.sidebar-toggle-btn {
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-muted-strong);
    user-select: none;
    transition: background 0.15s, color 0.15s;
}

.sidebar-toggle-btn:hover {
    background-color: var(--navy-50);
    color: var(--text-strong);
}

.sidebar-toggle-chk:checked ~ .page .sidebar {
    width: 0;
    min-width: 0;
    border-right-color: transparent;
}

/* ── Mobile ─────────────────────────────────────────────────────── */

/* O checkbox fica escondido; o <label> é o botão visível */
.navbar-toggler {
    display: none;
}

.navbar-toggler-label {
    cursor: pointer;
    width: 2.75rem;
    height: 2.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%233E4766' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.5rem transparent;
    display: none;
}

.navbar-toggler:checked ~ .nav-scrollable {
    display: block;
}

@media (max-width: 640px) {
    .sidebar-toggle-btn {
        display: none;
    }

    .page {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: 0;
        min-height: unset;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .navbar-toggler-label {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-scrollable {
        display: none;
    }

    .navbar-toggler:checked + div + .nav-scrollable {
        display: block;
    }

    .top-row {
        justify-content: space-between;
        height: auto;
        padding: var(--sp-3) var(--sp-4);
        flex-wrap: wrap;
        gap: var(--sp-2);
    }

    article.content {
        padding: var(--sp-4);
    }
}

@media (min-width: 641px) {
    .navbar-toggler-label {
        display: none;
    }
}

/* ── Blazor error UI ─────────────────────────────────────────────── */

#blazor-error-ui {
    background: var(--warning-bg);
    color: var(--text-strong);
    font-size: var(--fs-label);
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(62, 71, 102, 0.12);
    display: none;
    left: 0;
    padding: 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: var(--danger-solid);
    border-radius: var(--radius-md);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "Ocorreu um erro.";
}

/* ── Login ──────────────────────────────────────────────────────── */

.login-canvas {
    background: var(--canvas);
}
