:root {
    --app-safe-top: env(safe-area-inset-top, 0px);
    --app-safe-bottom: env(safe-area-inset-bottom, 0px);
    --app-safe-left: env(safe-area-inset-left, 0px);
    --app-safe-right: env(safe-area-inset-right, 0px);
}

html, body {
    overflow-x: hidden;
}

body {
    padding-bottom: var(--app-safe-bottom);
    color: var(--vb-text);
    background: var(--vb-gradient-champagne);
}

.layout-page-container {
    width: 100%;
}

.main-shell-content {
    padding-left: max(8px, var(--app-safe-left));
    padding-right: max(8px, var(--app-safe-right));
}

/* Menu AppBar (MudMenu): destaque da rota atual */
.app-shell-menuitem--active {
    font-weight: 600;
    background-color: rgba(196, 165, 134, 0.14);
}

.app-shell-mudmenu .mud-popover-paper {
    min-width: min(280px, calc(100vw - 24px));
}

/* Menu nativo em rotas Account/* (SSR estático): mesmo padrão visual aproximado do NavMenu */
.account-static-menu {
    position: relative;
}

.account-static-menu summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.account-static-menu summary::-webkit-details-marker {
    display: none;
}

.account-static-menu__items {
    position: absolute;
    top: 44px;
    left: 0;
    min-width: min(280px, calc(100vw - 24px));
    background: var(--vb-ivory);
    border: 1px solid var(--vb-border-gold);
    box-shadow: 0 12px 26px var(--vb-shadow-gold);
    z-index: 1300;
    display: flex;
    flex-direction: column;
    padding-bottom: 4px;
}

.account-static-menu__caption {
    padding: 8px 12px 4px;
    font-size: 0.75rem;
    color: rgba(0, 0, 0, 0.54);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.account-static-menu__caption--section {
    padding-top: 12px;
}

.account-static-menu__divider {
    height: 1px;
    margin: 4px 0;
    background: rgba(0, 0, 0, 0.08);
}

.account-static-menu__row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 0.9375rem;
}

.account-static-menu__row:last-child {
    border-bottom: 0;
}

.account-static-menu__row:hover {
    background: rgba(196, 165, 134, 0.12);
}

.mud-appbar {
    padding-top: var(--app-safe-top);
    background: var(--vb-gradient-appbar) !important;
    color: var(--vb-text) !important;
    border-bottom: 1px solid var(--vb-border-gold);
    backdrop-filter: blur(8px);
}

.brand-logo {
    border-radius: 50%;
    border: 1px solid var(--vb-border-gold);
    box-shadow: 0 2px 8px var(--vb-shadow);
}

.mud-main-content {
    min-height: calc(100vh - 64px);
    background-image: radial-gradient(circle at 3% 5%, rgba(217, 196, 171, 0.18) 0, transparent 26%);
}

/* Links da AppBar em telas estreitas */
.appbar-nav-link {
    min-width: 0;
    flex-shrink: 1;
    border-radius: 999px !important;
}

.mud-paper {
    border: 1px solid var(--vb-border-gold);
    box-shadow: 0 8px 26px var(--vb-shadow) !important;
}

.mud-button-filled.mud-button-filled-primary {
    background: var(--vb-gradient-gold);
    color: #fff !important;
}

.mud-button-filled.mud-button-filled-primary:hover {
    filter: brightness(1.05);
}

.mud-button-filled.mud-button-filled-secondary {
    background: linear-gradient(135deg, var(--vb-noir-soft) 0%, var(--vb-noir) 100%);
}

@media (max-width: 959.98px) {
    .mud-main-content {
        min-height: calc(100vh - 56px);
    }

    .mud-button {
        min-height: 44px;
    }
}

/* === Celulares (ex.: Samsung A54 ~360–412px) === */
@media (max-width: 600px) {
    .main-shell-content .mud-container {
        padding-left: max(12px, var(--app-safe-left)) !important;
        padding-right: max(12px, var(--app-safe-right)) !important;
    }

    .mud-dialog {
        margin: 12px;
        width: calc(100% - 24px);
    }

    /* Botões: menos “esticados”, texto pode quebrar, área de toque ≥ 44px */
    .mud-button-root {
        letter-spacing: 0.03em !important;
        white-space: normal;
        line-height: 1.25;
        max-width: 100%;
    }

    .mud-button-root.mud-button-full-width {
        width: 100%;
    }

    .mud-button-filled-size-large,
    .mud-button-outlined-size-large {
        font-size: 0.9375rem !important;
        padding-left: 14px !important;
        padding-right: 14px !important;
    }

    /* Tabelas admin: rolagem horizontal sem estourar a viewport */
    .mud-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    /* Papers com muito padding (ex.: admin) */
    .mud-paper.pa-8 {
        padding: 1rem !important;
    }

    .mud-paper.pa-6 {
        padding: 0.875rem !important;
    }

    /* Títulos grandes em conteúdo principal */
    .main-shell-content .mud-typography-h3 {
        font-size: 1.5rem !important;
        line-height: 1.2 !important;
    }

    .main-shell-content .mud-typography-h4 {
        font-size: 1.2rem !important;
    }

    .main-shell-content .mud-typography-h5 {
        font-size: 1.05rem !important;
    }
}

/* Barra de busca / toolbars horizontais (catálogo, filtros) */
.catalog-searchbar {
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.catalog-searchbar .mud-input-control,
.catalog-searchbar .mud-input-root {
    min-width: 0;
    flex: 1 1 140px;
}

@media (max-width: 600px) {
    .catalog-searchbar {
        border-radius: 16px !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .catalog-searchbar .mud-chip {
        width: 100%;
        justify-content: center;
    }
}

/* CTAs de produto (WhatsApp / compartilhar): confortável no toque sem altura excessiva */
.btn-cta-touch {
    min-height: 48px;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}

@media (min-width: 600px) {
    .btn-cta-touch {
        padding-top: 14px !important;
        padding-bottom: 14px !important;
    }
}

@media (max-width: 400px) {
    .mud-appbar .mud-toolbar-appbar {
        padding-left: 4px;
        padding-right: 4px;
    }
}

/* Admin: lista de produtos / estoque — toolbar da tabela no mobile */
.product-list-sticky-search {
    position: sticky;
    top: calc(56px + env(safe-area-inset-top));
    z-index: 11;
    margin-bottom: 0.75rem;
}

.product-list-sticky-search .mud-paper {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(2px);
}

.product-list-table .mud-table-toolbar {
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.75rem;
    padding-left: max(4px, var(--app-safe-left, 0px));
    padding-right: max(4px, var(--app-safe-right, 0px));
    padding-top: 0.5rem;
    padding-bottom: 0.75rem;
}

.product-list-table .mud-table-container {
    margin-top: 0.25rem;
}

.product-list-table .mud-table-toolbar > * {
    min-width: 0;
    max-width: 100%;
}

.product-list-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.product-list-toolbar__title {
    line-height: 1.3;
}

.product-list-toolbar__search {
    width: 100%;
}

.product-list-toolbar__actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    width: 100%;
}

.product-list-toolbar__new {
    white-space: nowrap;
    min-height: 42px;
    justify-content: center;
}

.product-list-toolbar__new--cash {
    background: #fff;
}

.product-list-mobile-actions {
    display: none;
}

@media (min-width: 600px) {
    .product-list-toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.75rem 1rem;
    }

    .product-list-toolbar__title {
        flex: 0 0 auto;
        margin-right: auto;
    }

    .product-list-toolbar__search {
        flex: 1 1 200px;
        min-width: 160px;
        max-width: 420px;
        width: auto;
    }

    .product-list-toolbar__actions {
        width: auto;
        grid-template-columns: repeat(2, auto);
        align-items: center;
    }

    .product-list-toolbar__new {
        flex: 0 0 auto;
        width: auto;
    }
}

@media (max-width: 599.98px) {
    .product-list-page {
        padding-bottom: 88px;
    }

    .product-list-sticky-search {
        top: calc(52px + env(safe-area-inset-top));
        margin-bottom: 0.5rem;
    }

    .product-list-page-title {
        font-size: 1.35rem !important;
        line-height: 1.25 !important;
    }

    .product-list-table .mud-table-toolbar {
        padding-bottom: 1rem;
    }

    .product-list-toolbar__new {
        width: 100%;
    }

    .product-list-toolbar__actions {
        display: none;
    }

    .product-list-mobile-actions {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: max(8px, env(safe-area-inset-bottom));
        z-index: 1200;
        pointer-events: none;
    }

    .product-list-mobile-actions__inner {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 12px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        pointer-events: auto;
    }
}

/* Conta: menu lateral fixo durante navegação/rolagem */
.account-manage-layout__nav {
    align-self: start;
}

.account-manage-layout__menu-sticky {
    position: sticky;
    top: calc(72px + env(safe-area-inset-top));
    z-index: 5;
    background: #fff;
}

@media (max-width: 959.98px) {
    .account-manage-layout__nav {
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        padding-bottom: 8px;
        margin-bottom: 8px;
    }

    .account-manage-layout__menu-sticky {
        top: calc(60px + env(safe-area-inset-top));
    }
}

/* Blazor circuit error banner (MudAlert) */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: max(12px, var(--app-safe-left));
    right: max(12px, var(--app-safe-right));
    bottom: max(12px, var(--app-safe-bottom));
    z-index: 2000;
}

#blazor-error-ui .blazor-error-ui__alert {
    box-shadow: 0 8px 24px var(--vb-shadow-gold);
}

/* Rodapé — créditos V Tech */
.site-footer {
    margin-top: 2.5rem;
    padding-bottom: max(1.5rem, var(--app-safe-bottom));
}

.site-footer__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.35rem;
    padding: 0 0.5rem 0.5rem;
}

.site-footer__divider {
    border-color: var(--vb-border) !important;
    opacity: 1;
}

.site-footer__brand {
    font-family: "Cormorant Garamond", "Playfair Display", serif;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--vb-gold-deep);
}

.site-footer__legal,
.site-footer__copy {
    line-height: 1.45;
    max-width: 36rem;
}
