/* ============================================================
   Restaurante — Mobile-first (smartphone)
   ============================================================ */

:root {
    --rest-topbar-height:    3.25rem;
    --rest-bottom-nav-height: 4.25rem;
    --rest-touch-min:        48px;
    --rest-safe-bottom:      env(safe-area-inset-bottom, 0px);
    --rest-safe-top:         env(safe-area-inset-top, 0px);
}

.app-layout.has-mobile-nav .app-main {
    padding-bottom: calc(var(--rest-bottom-nav-height) + var(--rest-safe-bottom) + 0.5rem);
}

.app-layout.page-pedido .app-main {
    padding-bottom: calc(var(--rest-bottom-nav-height) + var(--rest-pedido-bar-height, 4.5rem) + var(--rest-safe-bottom));
}

/* Topbar compacta */
.topbar-rest {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: linear-gradient(135deg, var(--rest-primary-dark), var(--rest-primary));
    padding: calc(0.5rem + var(--rest-safe-top) * 0.25) 0 0.5rem;
    box-shadow: var(--rest-shadow);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--rest-topbar-height);
}

.topbar-brand {
    color: #fff;
    font-family: var(--rest-font);
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-nome {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.875rem;
    max-width: 8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-topbar-logout {
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    min-width: var(--rest-touch-min);
    min-height: var(--rest-touch-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.btn-topbar-logout:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.5);
}

/* Bottom navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    display: flex;
    background: var(--rest-surface);
    border-top: 1px solid var(--rest-border);
    box-shadow: 0 -4px 16px rgba(61, 41, 20, 0.1);
    padding-bottom: var(--rest-safe-bottom);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: var(--rest-bottom-nav-height);
    padding: 0.35rem 0.25rem;
    color: var(--rest-text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item i {
    font-size: 1.35rem;
    line-height: 1;
}

.bottom-nav-item.active {
    color: var(--rest-primary);
}

.bottom-nav-item.active i {
    color: var(--rest-primary);
}

.bottom-nav-item:active {
    background: var(--rest-primary-soft);
}

/* Page headers mobile */
.page-header h1 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.page-header-compact .subtitle {
    font-size: 0.875rem;
}

/* Touch-friendly controls */
.btn,
.form-control,
.form-select {
    min-height: var(--rest-touch-min);
    font-family: var(--rest-font);
    font-size: 1rem;
}

input.form-control,
select.form-select,
textarea.form-control {
    font-size: 16px;
}

.btn-sm {
    min-height: 2.5rem;
}

.btn-lg-touch {
    min-height: 3.25rem;
    font-size: 1.05rem;
}

/* Categoria — segmento full width */
.cat-segment {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.cat-segment .btn {
    min-height: 3.25rem;
    font-size: 0.9rem;
    padding: 0.5rem 0.35rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
}

.cat-segment .btn i {
    font-size: 1.25rem;
}

/* Produtos — grelha touch */
.produto-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

@media (min-width: 576px) {
    .produto-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.produto-btn {
    min-height: 4.25rem;
    border: 2px solid #B7CDB7;
    border-radius: var(--bs-border-radius-lg);
    background: #E8F0E8;
    color: var(--rest-text);
}

.produto-btn:active {
    transform: scale(0.98);
    background: #D4E2D4;
    border-color: var(--rest-primary);
}

/* Mesas — grelha optimizada telemovel */
.mesas-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
}

@media (min-width: 768px) {
    .mesas-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 992px) {
    .mesas-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

.mesa-card {
    min-height: 5.5rem;
    padding: 0.85rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.mesa-card:active {
    transform: scale(0.97);
}

.mesa-numero {
    font-size: 1.75rem;
}

.mesa-legenda {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.8rem;
}

/* Itens do pedido — cartoes mobile */
.item-card {
    border-bottom: 1px solid var(--rest-border);
    padding: 0.85rem 1rem;
}

.item-card:last-child {
    border-bottom: none;
}

.item-card.devolvido {
    opacity: 0.65;
}

.item-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.item-card-total {
    font-weight: 700;
    color: var(--rest-primary);
    white-space: nowrap;
}

.devolucao-form {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--rest-border);
}

.devolucao-form .form-control {
    font-size: 1rem;
}

/* Barra fixa pedido (mobile) */
.pedido-mobile-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--rest-bottom-nav-height) + var(--rest-safe-bottom));
    z-index: 1035;
    background: var(--rest-surface);
    border-top: 2px solid var(--rest-primary-soft);
    box-shadow: 0 -4px 20px rgba(61, 41, 20, 0.15);
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pedido-mobile-bar .bar-total {
    flex: 1;
    min-width: 0;
}

.pedido-mobile-bar .bar-label {
    font-size: 0.7rem;
    color: var(--rest-text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.pedido-mobile-bar .bar-valor {
    font-family: var(--rest-font);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--rest-success);
    line-height: 1.1;
}

.pedido-mobile-bar .btn-fechar {
    min-height: 3rem;
    min-width: 7rem;
    font-weight: 700;
}

/* Stats compactas */
.stat-card {
    padding: 0.85rem;
}

.stat-card .stat-value {
    font-size: 1.35rem;
}

/* Tabelas — scroll horizontal suave */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* Lista pedidos mobile */
.pedido-list-card {
    border: 1px solid var(--rest-border);
    border-radius: var(--bs-border-radius-lg);
    background: var(--rest-surface);
    padding: 1rem;
    margin-bottom: 0.65rem;
    text-decoration: none;
    color: inherit;
    display: block;
}

.pedido-list-card:active {
    background: var(--rest-primary-soft);
}

.pedido-list-card .mesa-badge {
    font-family: var(--rest-font);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--rest-primary-dark);
}

/* Offcanvas fecho */
.offcanvas-rest .offcanvas-header {
    background: var(--rest-primary-soft);
}

.offcanvas-rest .form-control,
.offcanvas-rest .btn {
    font-size: 1rem;
}

/* Login fullscreen mobile */
@media (max-width: 575.98px) {
    .login-wrap {
        min-height: calc(100dvh - var(--rest-topbar-height));
        display: flex;
        align-items: center;
    }

    .login-card {
        border: none;
        box-shadow: none;
        max-width: 100%;
    }
}

/* Desktop extras */
@media (min-width: 992px) {
    .app-layout.has-mobile-nav .app-main {
        padding-bottom: 2rem;
    }

    .page-header h1 {
        font-size: 1.75rem;
    }

    .carrinho-sticky {
        position: sticky;
        top: 1rem;
    }
}

@media (max-width: 991.98px) {
    .carrinho-sticky {
        position: static;
    }

    .desktop-only-table {
        display: none !important;
    }
}

@media (min-width: 992px) {
    .mobile-only-cards {
        display: none !important;
    }

    .pedido-mobile-bar {
        display: none !important;
    }
}
