/* RAWA — product finish
 * Passagem final de navegação, responsividade, feedback e consistência.
 * Não altera autenticação, regras de negócio, API ou identidade oficial.
 */

#app-view {
    --rawa-topbar-h: 72px;
    --rawa-surface-hover: color-mix(in srgb, #3182f6 5%, var(--v3-card));
    --rawa-outline-soft: color-mix(in srgb, #3182f6 24%, var(--v3-border));
}

/* Shell e navegação */
#app-view .topbar {
    min-height: var(--rawa-topbar-h) !important;
    padding: 10px 24px !important;
    border-bottom: 1px solid var(--v3-border) !important;
    background: color-mix(in srgb, var(--v3-topbar) 96%, transparent) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,.025);
    backdrop-filter: blur(16px) saturate(1.04);
    -webkit-backdrop-filter: blur(16px) saturate(1.04);
}

#app-view .topbar-left {
    min-width: 0;
    gap: 12px !important;
}

#app-view #page-eyebrow {
    display: block;
    margin-bottom: 3px;
    color: var(--v3-muted) !important;
    font-size: 8.5px !important;
    font-weight: 850 !important;
    letter-spacing: .14em !important;
}

#app-view #page-title {
    margin: 0;
    color: var(--v3-text) !important;
    font-size: 18px !important;
    line-height: 1.1;
    letter-spacing: -.025em;
}

#app-view .v11-global-search-trigger {
    height: 40px;
    border-radius: 10px;
    box-shadow: none;
}

#app-view .notification-button,
#app-view .user-chip {
    border-color: var(--v3-border) !important;
    background: var(--v3-card) !important;
    box-shadow: 0 3px 10px rgba(0,0,0,.025);
}

#app-view .notification-button:hover,
#app-view .user-chip:hover {
    border-color: var(--rawa-outline-soft) !important;
    background: var(--rawa-surface-hover) !important;
}

#app-view .main-menu {
    padding-top: 10px !important;
}

#app-view .menu-section-title {
    padding-top: 14px !important;
    padding-bottom: 6px !important;
}

#app-view .menu-item {
    position: relative;
    min-height: 42px !important;
    margin: 2px 0 !important;
    border-radius: 10px !important;
}

#app-view .menu-item.active {
    border-color: rgba(49,130,246,.24) !important;
    background: color-mix(in srgb, #3182f6 15%, var(--v3-card-2)) !important;
    color: var(--v3-text) !important;
    box-shadow: none !important;
}

#app-view .menu-item.active::before {
    content: "";
    position: absolute;
    inset: 9px auto 9px 0;
    width: 3px;
    border-radius: 999px;
    background: #3182f6;
}

#app-view .menu-item:hover {
    transform: none !important;
}

#app-view .menu-icon {
    width: 30px !important;
    height: 30px !important;
    border-radius: 9px !important;
}

#app-view .sidebar-footer {
    border-radius: 12px !important;
    box-shadow: none !important;
}

/* Sidebar compacta: mantém apenas ícones e marca já aprovada. */
#app-view.v11-sidebar-collapsed .menu-item.active::before {
    inset: 10px auto 10px 0;
}

#app-view.v11-sidebar-collapsed .menu-item {
    width: 46px !important;
    min-width: 46px !important;
    height: 46px;
}

#app-view.v11-sidebar-collapsed .menu-icon {
    width: 32px !important;
    height: 32px !important;
}

/* Estados globais */
#app-view .page-loading {
    min-height: min(52vh, 460px) !important;
    place-content: center;
    gap: 12px;
    border: 1px dashed var(--v3-border);
    border-radius: 16px;
    background: color-mix(in srgb, var(--v3-card) 72%, transparent);
}

#app-view .page-loading.compact {
    min-height: 140px !important;
}

#app-view .page-loading .spinner {
    width: 28px !important;
    height: 28px !important;
}

#app-view .page-loading span {
    color: var(--v3-muted) !important;
    font-size: 11px;
    font-weight: 650;
}

#app-view .table-empty {
    min-height: 120px;
    display: grid;
    place-items: center;
    padding: 28px 18px !important;
    color: var(--v3-muted) !important;
    font-size: 11px !important;
    text-align: center;
}

#app-view .empty-state {
    min-height: min(48vh, 420px) !important;
    display: grid !important;
    place-items: center !important;
}

#app-view .empty-state-box {
    width: min(560px, 100%);
    display: grid;
    justify-items: center;
    text-align: center;
}

#app-view .empty-state p {
    max-width: 520px;
    line-height: 1.6 !important;
}

.toast-container {
    display: grid;
    gap: 8px;
}

.toast-container .toast {
    min-width: min(360px, calc(100vw - 32px));
    max-width: 440px;
    padding: 11px 13px !important;
    border: 1px solid rgba(148,163,184,.15);
    font-size: 11px !important;
    line-height: 1.45;
}

/* Modal polish */
.modal-backdrop .modal,
.modal-backdrop .modal-card,
.modal-backdrop .modal-content {
    border: 1px solid var(--v3-border) !important;
    background: var(--v3-card) !important;
}

.modal-backdrop .modal-header {
    border-bottom: 1px solid var(--v3-border) !important;
    background: color-mix(in srgb, var(--v3-card) 94%, var(--v3-card-2)) !important;
}

.modal-backdrop .modal-close {
    border: 1px solid var(--v3-border) !important;
    background: var(--v3-card-2) !important;
    color: var(--v3-muted) !important;
}

.modal-backdrop .modal-close:hover {
    border-color: var(--rawa-outline-soft) !important;
    background: var(--rawa-surface-hover) !important;
    color: var(--v3-text) !important;
}

/* Tabelas: leitura e estabilidade */
#app-view .data-table-wrap,
#app-view .report-table-wrap {
    scrollbar-gutter: stable;
}

#app-view .data-table tbody tr:focus-within,
#app-view .report-table tbody tr:focus-within {
    background: color-mix(in srgb, #3182f6 6%, transparent) !important;
}

#app-view .data-table td:last-child,
#app-view .data-table th:last-child {
    padding-right: 14px !important;
}

#app-view .row-actions {
    flex-wrap: nowrap;
}

#app-view .row-action:disabled,
#app-view .action-button:disabled,
#app-view .secondary-button:disabled {
    opacity: .48 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Busca global e menus flutuantes */
.v11-command-backdrop {
    background: rgba(2,8,18,.62) !important;
}

.v11-command {
    border-radius: 18px !important;
    box-shadow: 0 34px 100px rgba(0,0,0,.42) !important;
}

.v11-command-item {
    min-height: 54px;
}

.v11-command-item:focus-visible {
    outline: 2px solid rgba(83,158,255,.92);
    outline-offset: -2px;
}

.v11-version-card {
    background: var(--v3-card-2);
}

.v11-fab {
    width: 50px !important;
    height: 50px !important;
    border-radius: 15px !important;
    box-shadow: 0 14px 30px rgba(37,99,235,.26) !important;
}

/* Mobile product pass */
@media (max-width: 900px) {
    #app-view .topbar {
        min-height: 66px !important;
        padding: 9px 14px !important;
    }

    #app-view .mobile-menu-button {
        width: 40px !important;
        height: 40px !important;
        flex: 0 0 40px;
        border: 1px solid var(--v3-border) !important;
        border-radius: 10px !important;
        background: var(--v3-card) !important;
        color: var(--v3-text) !important;
    }

    #app-view #page-title {
        max-width: 42vw;
        overflow: hidden;
        font-size: 16px !important;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #app-view .topbar-actions {
        gap: 6px !important;
    }

    #app-view .notification-button,
    #app-view .v11-global-search-trigger {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
    }

    #app-view .user-chip {
        min-width: 40px !important;
        width: 40px !important;
        height: 40px !important;
        padding: 3px !important;
        justify-content: center;
        border-radius: 10px !important;
    }

    #app-view .user-chip-copy,
    #app-view .user-chip-chevron {
        display: none !important;
    }

    #app-view .user-chip .avatar {
        width: 32px !important;
        height: 32px !important;
    }

    .v11-mobile-nav {
        min-height: 62px;
        gap: 3px !important;
        padding: 5px !important;
        border-radius: 16px !important;
        background: color-mix(in srgb, var(--v3-card) 96%, transparent) !important;
        box-shadow: 0 14px 36px rgba(0,0,0,.20) !important;
    }

    .v11-mobile-nav button {
        min-height: 50px;
        border-radius: 11px !important;
        font-size: 8px !important;
    }

    .v11-mobile-nav button.active {
        background: rgba(49,130,246,.11) !important;
        color: #4b91f2 !important;
    }

    .v11-mobile-nav button.active::after {
        content: "";
        width: 16px;
        height: 2px;
        margin-top: -1px;
        border-radius: 999px;
        background: currentColor;
    }

    .v11-fab-wrap {
        right: 14px !important;
    }

    #app-view .data-table,
    #app-view .report-table {
        font-size: 11px;
    }

    #app-view .data-table th,
    #app-view .report-table th {
        height: 36px;
        padding-block: 8px !important;
    }

    #app-view .data-table td,
    #app-view .report-table td {
        padding-block: 10px !important;
    }
}

@media (max-width: 560px) {
    #app-view #page-eyebrow {
        display: none;
    }

    #app-view #page-title {
        max-width: 38vw;
    }

    #app-view .notification-button {
        display: none;
    }

    #app-view .hero-row p {
        font-size: 11.5px !important;
    }

    #app-view .module-statline {
        gap: 6px !important;
    }

    #app-view .module-stat {
        min-height: 26px;
        padding: 4px 8px !important;
        font-size: 9px !important;
    }

    #app-view .module-stat strong {
        font-size: 10px !important;
    }

    .toast-container .toast {
        min-width: 0;
        max-width: none;
    }
}

/* Tema claro: reduz contraste excessivo de sombras. */
html[data-theme="light"] #app-view .topbar,
html[data-theme="light"] #app-view .notification-button,
html[data-theme="light"] #app-view .user-chip,
html[data-theme="light"] .v11-mobile-nav {
    box-shadow: 0 8px 22px rgba(15,23,42,.055) !important;
}

@media (prefers-reduced-motion: reduce) {
    #app-view .menu-item,
    #app-view .notification-button,
    #app-view .user-chip,
    .v11-mobile-nav button,
    .v11-command-item,
    .v11-fab {
        transition: none !important;
        animation: none !important;
        transform: none !important;
    }
}
