/**
 * Cardapio Base Styles
 * Base styles for the public cardapio layout
 * Used in: layouts/cardapio.blade.php
 */

/* CSS Variables are set inline in Blade (dynamic from settings) */

* {
    -webkit-tap-highlight-color: transparent;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    padding-bottom: calc(var(--cart-height) + env(safe-area-inset-bottom));
    overscroll-behavior-y: none; /* Disable pull-to-refresh */
}

/* Header */
.cardapio-header {
    background: var(--primary-color);
    color: white;
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.cardapio-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.cardapio-header .subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* Categories Navigation */
.categories-nav {
    background: white;
    position: sticky;
    top: 60px; /* header height */
    z-index: 998;
    border-bottom: 1px solid var(--border-color);
    /* CRITICAL: Prevent nav from expanding beyond viewport */
    max-width: 100vw;
    overflow-x: hidden;
}

/* When cardápio is closed, reserve space for banner */
.cardapio-fechado .categories-nav {
    padding-top: 36px;
}

.nav-scroll-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain; /* Prevent scroll chaining to parent */
}

.nav-scroll-container::-webkit-scrollbar {
    display: none;
}

.categories-nav .nav {
    flex-wrap: nowrap;
    padding: 0.5rem;
}

.categories-nav .nav-link {
    white-space: nowrap;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.categories-nav .nav-link.active {
    background: var(--primary-color);
    color: white;
}

/* Menu Content */
.menu-content {
    padding: 1rem;
    padding-bottom: calc(var(--cart-height) + 2rem);
}

/* Category Section */
.category-section {
    margin-bottom: 2rem;
    scroll-margin-top: 115px; /* header (60px) + nav (44px) + padding */
}

.category-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

/* Item Card */
.item-card {
    position: relative;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    min-height: 120px;
}

.item-card:active {
    transform: scale(0.98);
}

.item-card-img-wrapper {
    width: 100px;
    min-height: 100px;
    flex-shrink: 0;
    align-self: stretch;
    position: relative;
}

.item-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.item-card-img-placeholder {
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-card-body {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
    min-width: 0;
}

.item-card-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    color: var(--text-color);
}

.item-card-detail {
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.item-card-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.item-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-price {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1rem;
}

.item-price-original {
    text-decoration: line-through;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: normal;
}

.item-add-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* Destaque Badge */
.badge-destaque {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--primary-color);
    color: white;
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* Tempo de Preparo Badge */
.badge-tempo-preparo {
    background: rgba(255, 255, 255, 0.9);
    color: #666;
    font-size: 0.65rem;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 3px;
    backdrop-filter: blur(4px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.badge-tempo-preparo i {
    font-size: 0.55rem;
    opacity: 0.7;
}

/* Info Row (alergênicos + tempo preparo) */
.badge-info-row {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    z-index: 1;
}

/* Alergênicos Badge */
.badge-alergenicos {
    background: rgba(255, 255, 255, 0.9);
    color: #495057;
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: flex;
    gap: 4px;
    backdrop-filter: blur(4px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.badge-alergenicos i {
    font-size: 0.65rem;
}

/* Sugestão Badge (combina com itens no carrinho) */
.badge-sugestao {
    position: absolute;
    top: 36px;
    left: 8px;
    background: linear-gradient(135deg, #ffd700 0%, #ffb300 100%);
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(255, 179, 0, 0.4);
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 2px 6px rgba(255, 179, 0, 0.4);
    }
    50% {
        box-shadow: 0 2px 12px rgba(255, 179, 0, 0.7);
    }
}

/* Cart Bar */
.cart-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--cart-height);
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1001;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.cart-bar.visible {
    transform: translateY(0);
}

.cart-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cart-count {
    background: var(--primary-color);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.cart-total {
    font-weight: 700;
    font-size: 1.1rem;
}

.cart-items-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.cart-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
}

.cart-btn:hover {
    color: white;
}

/* Cart Mismatch Banner */
.cart-mismatch-banner {
    position: fixed;
    bottom: calc(var(--cart-height) + 10px + env(safe-area-inset-bottom));
    left: 1rem;
    right: 1rem;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    display: none;
    justify-content: space-between;
    align-items: center;
    z-index: 1002;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    gap: 0.75rem;
}

.cart-mismatch-banner .mismatch-content {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: #664d03;
}

.cart-mismatch-banner .mismatch-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.cart-mismatch-banner .mismatch-actions .btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* Item Modal */
.item-modal .modal-content {
    border-radius: 20px 20px 0 0;
    border: none;
}

.item-modal .modal-dialog {
    margin: 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 100%;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.item-modal.show .modal-dialog {
    transform: translateY(0);
}

.item-modal-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.item-modal-body {
    padding: 1.25rem;
    max-height: 60vh;
    overflow-y: auto;
}

/* Quantity Controls */
.qty-control {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-color);
    padding: 0.5rem;
    border-radius: 10px;
}

.qty-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: white;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-value {
    font-size: 1.25rem;
    font-weight: 600;
    min-width: 30px;
    text-align: center;
}

/* Adicional Checkbox */
.adicional-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: 10px;
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.adicional-item.selected {
    background: var(--primary-rgba-light);
    border: 1px solid var(--primary-color);
}

.adicional-check {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 2px solid var(--border-color);
    margin-right: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.adicional-check i {
    display: none;
}

.adicional-item.selected .adicional-check {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.adicional-item.selected .adicional-check i {
    display: block;
}

.adicional-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Adicional Grupos */
.adicional-grupo {
    margin-bottom: 1.25rem;
}

.adicional-grupo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 0.75rem;
}

.adicional-grupo-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.adicional-grupo-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-color);
}

.adicional-grupo-badge {
    background: var(--primary-color);
    color: white;
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
}

.adicional-grupo-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.adicional-grupo-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-color);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.adicional-grupo.required {
    border-left: 3px solid var(--primary-color);
    padding-left: 0.75rem;
    margin-left: -0.75rem;
}

.adicional-grupo.error .adicional-grupo-header {
    border-bottom-color: #dc3545;
}

.adicional-grupo.error .adicional-grupo-title {
    color: #dc3545;
}

.adicional-grupo-error-msg {
    color: #dc3545;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: none;
}

.adicional-grupo.error .adicional-grupo-error-msg {
    display: block;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Search */
.search-bar {
    padding: 0.5rem 1rem;
    background: white;
}

.search-input {
    background: var(--bg-color);
    border: none;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    padding-left: 2.5rem;
    width: 100%;
    font-size: 0.95rem;
}

.search-icon {
    position: absolute;
    left: 1.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Closed Banner - Absolute positioned inside categories-nav */
.closed-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    color: white;
    padding: 0.5rem 1rem;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    z-index: 1;
}

/* Adjustments when cardápio is closed */
.cardapio-fechado .category-section {
    scroll-margin-top: 160px; /* header (60px) + nav with banner (~90px) + padding */
}

/* Back Button */
.btn-voltar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
    flex-shrink: 0;
}

.btn-voltar:hover {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.btn-voltar:active {
    transform: scale(0.95);
}

/* Cardapio Selector */
.cardapio-selector {
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.cardapio-selector::-webkit-scrollbar {
    display: none;
}

.cardapio-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    white-space: nowrap;
    text-decoration: none;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.cardapio-pill:hover {
    background: rgba(255,255,255,0.3);
    color: white;
}

.cardapio-pill.active {
    background: white;
    color: var(--pill-color, var(--primary-color));
    border-color: white;
    font-weight: 600;
}

.pill-badge {
    background: var(--success-color);
    color: white;
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 1rem;
}

.cardapio-pill.active .pill-badge {
    background: var(--success-color);
}

/* Cardápio Fechado - Grayscale Images */
.img-grayscale {
    filter: grayscale(100%);
    opacity: 0.7;
    transition: filter 0.3s, opacity 0.3s;
}

/* Quando clicar no modal, imagem fica colorida */
.item-modal .item-modal-img {
    filter: none !important;
    opacity: 1 !important;
}

/* Responsive */
@media (min-width: 768px) {
    body {
        padding-bottom: 0;
    }

    .menu-content {
        max-width: 800px;
        margin: 0 auto;
    }

    .cart-bar {
        max-width: 800px;
        left: 50%;
        transform: translateX(-50%) translateY(100%);
        border-radius: 20px 20px 0 0;
    }

    .cart-bar.visible {
        transform: translateX(-50%) translateY(0);
    }

    .cart-mismatch-banner {
        max-width: 800px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: calc(100% - 2rem);
    }
}
