html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    height: 100%;
    margin: 0;
}

a, .btn-link {
    color: #006bb7;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

/* ── Layout principal ───────────────────────────────────────────── */

.page {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
}

main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.top-row {
    background-color: #f7f7f7;
    border-bottom: 1px solid #d6d5d5;
    justify-content: flex-end;
    height: 3.5rem;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 1;
}

.top-row a, .top-row .btn-link {
    white-space: nowrap;
    margin-left: 1.5rem;
    text-decoration: none;
}

.top-row a:hover, .top-row .btn-link:hover {
    text-decoration: underline;
}

article.content {
    flex: 1;
    padding: 1.5rem 2rem;
}

/* ── Sidebar ────────────────────────────────────────────────────── */

.sidebar {
    width: 250px;
    min-height: 100vh;
    background: linear-gradient(180deg, #1a2f5e 0%, #2d0a47 100%);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

.sidebar .navbar-brand {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.75rem 1rem;
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.75);
    padding: 0.6rem 1rem;
    border-radius: 0.375rem;
    margin: 0.1rem 0.5rem;
    transition: background 0.15s, color 0.15s;
}

.sidebar .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.12);
}

.sidebar .nav-link.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 500;
}

.nav-scrollable {
    flex: 1;
    min-height: 0;
    padding: 0.5rem 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.nav-scrollable::-webkit-scrollbar {
    width: 6px;
}

.nav-scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.nav-scrollable::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.nav-scrollable::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.35);
}

.top-row-unidade {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1a2f5e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.sidebar .nav-link-toggle {
    color: rgba(255, 255, 255, 0.75);
    padding: 0.6rem 1rem;
    border-radius: 0.375rem;
    margin: 0.1rem 0.5rem;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
}

.sidebar .nav-link-toggle:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.12);
}

.nav-section-separator {
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    margin: 0.4rem 0.5rem;
}

.sidebar .nav-sublink {
    padding-left: 2.25rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    margin-left: 1.5rem !important;
    border-left: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 0 0.375rem 0.375rem 0;
}

.sidebar .nav-sublink:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-unidade-selector .form-select {
    background-color: rgba(255, 255, 255, 0.1);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='rgba(255,255,255,0.75)' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    color: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 100%;
    max-width: 100% !important;
}

.sidebar-unidade-selector .form-select:focus {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 0.15rem rgba(255, 255, 255, 0.15);
    color: #fff;
}

.sidebar-unidade-selector .form-select option {
    background-color: #1a2f5e;
    color: #fff;
}

/* ── Toggle sidebar ─────────────────────────────────────────────── */

.sidebar-toggle-chk {
    display: none;
}

.sidebar-toggle-btn {
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    color: #555;
    user-select: none;
    transition: background 0.15s;
}

.sidebar-toggle-btn:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

.sidebar {
    transition: width 0.2s ease, min-width 0.2s ease;
    overflow: hidden;
}

.sidebar-toggle-chk:checked ~ .page .sidebar {
    width: 0;
    min-width: 0;
}

/* ── Mobile ─────────────────────────────────────────────────────── */

/* O checkbox fica escondido; o <label> é o botão visível */
.navbar-toggler {
    display: none;
}

.navbar-toggler-label {
    cursor: pointer;
    width: 3.5rem;
    height: 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.25rem;
    background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem 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-height: unset;
        height: auto;
        position: relative;
    }

    .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;
    }
}

@media (min-width: 641px) {
    .navbar-toggler-label {
        display: none;
    }
}

/* ── Blazor error UI ─────────────────────────────────────────────── */

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 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: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "Ocorreu um erro.";
}
