/**
 * Maestro Menu Display Styles
 * MOBILE-FIRST Design - 95% users on mobile
 */

/* Ensure all elements use border-box sizing */
.maestro-menu-wrapper *,
.maestro-menu-wrapper *::before,
.maestro-menu-wrapper *::after {
    box-sizing: border-box;
}

/* Menu Wrapper */
.maestro-menu-wrapper {
    max-width: 100%;
    margin: 0;
    padding: 15px;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Category Tabs - Mobile First */
.maestro-menu-tabs {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
    padding: 10px 0;
    margin: 0 -15px 15px;
    border-bottom: 2px solid #eee;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.menu-tabs-container {
    position: relative;
    display: flex;
    align-items: center;
}

.menu-tabs-scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: #c41e3a;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    -webkit-tap-highlight-color: transparent;
}

.menu-tabs-scroll-btn:active {
    background: #a01830;
    transform: translateY(-50%) scale(0.95);
}

.menu-tabs-scroll-btn.scroll-left {
    left: 2px;
}

.menu-tabs-scroll-btn.scroll-right {
    right: 2px;
}

.menu-tabs-scroll-btn.hidden {
    display: none;
}

.menu-tabs-list {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0 35px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}

.menu-tabs-list::-webkit-scrollbar {
    display: none;
}

.menu-tab-item {
    margin: 0;
}

.menu-tab-link {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    background: #f5f5f5;
    color: #333;
    text-decoration: none;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    white-space: nowrap;
}

.menu-tab-link:hover,
.menu-tab-link:active {
    background: #fff5f5;
    border-color: #c41e3a;
    color: #c41e3a;
}

.menu-tab-link.active {
    background: #c41e3a;
    color: #fff;
    border-color: #c41e3a;
}

.tab-icon {
    font-size: 16px;
}

.tab-label {
    white-space: nowrap;
}

/* Tab Panels */
.maestro-menu-content {
    min-height: 300px;
}

.menu-tab-panel {
    display: none;
    animation: fadeIn 0.2s ease;
}

.menu-tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Category Header */
.category-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 3px solid #c41e3a;
}

.category-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 22px;
    margin: 0 0 8px;
    color: #333;
}

.category-icon {
    font-size: 26px;
}

.category-description {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* Products Grid - Mobile First (Single Column) */
.products-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Product Card - Mobile Optimized */
.menu-product-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: row;
    border: 1px solid #eee;
}

.menu-product-card .product-image {
    width: 100px;
    min-width: 100px;
    height: 100px;
    overflow: hidden;
    flex-shrink: 0;
}

.menu-product-card .product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.menu-product-card .product-image a {
    display: block;
    width: 100%;
    height: 100%;
}

.menu-product-card .product-info {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.menu-product-card .product-title {
    margin: 0 0 5px;
    font-size: 15px;
    line-height: 1.3;
}

.menu-product-card .product-title a {
    color: #333;
    text-decoration: none;
}

.menu-product-card .product-description {
    display: none;
}

.menu-product-card .product-price {
    font-size: 16px;
    font-weight: bold;
    color: #c41e3a;
    margin-bottom: 10px;
}

.menu-product-card .product-price .woocommerce-Price-amount {
    color: #c41e3a;
}

.menu-product-card .product-actions {
    margin-top: auto;
}

/* Add to Cart Buttons - Large Touch Targets */
.btn-add-to-cart {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: #c41e3a;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn-add-to-cart:hover,
.btn-add-to-cart:active {
    background: #a01830;
    color: #fff;
}

.btn-add-to-cart.btn-customize {
    background: #2c5282;
}

.btn-add-to-cart.btn-customize:hover,
.btn-add-to-cart.btn-customize:active {
    background: #1a365d;
}

.btn-add-to-cart.btn-variation-popup {
    background: #c41e3a;
}

.btn-add-to-cart:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-add-to-cart.loading {
    position: relative;
    color: transparent;
}

.btn-add-to-cart.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.btn-add-to-cart.added {
    background: #28a745;
}

/* No Products Message */
.no-products {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
}

/* Variation Modal - Full Screen on Mobile */
.maestro-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: flex;
    align-items: flex-end;
}

.maestro-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
}

.maestro-modal-content {
    position: relative;
    background: #fff;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.maestro-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
}

.maestro-modal-close:active {
    background: #e0e0e0;
}

.maestro-modal-body {
    padding: 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* Variation Popup Content */
.popup-product-header {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.popup-product-image {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
}

.popup-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.popup-product-info {
    flex: 1;
    min-width: 0;
}

.popup-product-title {
    margin: 0 0 6px;
    font-size: 18px;
    color: #333;
    line-height: 1.3;
}

.popup-product-price {
    font-size: 18px;
    font-weight: bold;
    color: #c41e3a;
}

.popup-product-description {
    background: #f8f8f8;
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 13px;
    color: #555;
    line-height: 1.4;
}

/* Variation Options */
.variation-options {
    margin-bottom: 15px;
}

.variation-attribute {
    margin-bottom: 15px;
}

.variation-attribute > label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 14px;
    color: #333;
    text-transform: uppercase;
}

.variation-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.variation-btn {
    padding: 12px 16px;
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    flex: 1;
    min-width: calc(50% - 4px);
    text-align: center;
}

.variation-btn:active {
    transform: scale(0.98);
}

.variation-btn.selected {
    background: #c41e3a;
    border-color: #c41e3a;
    color: #fff;
}

.variation-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Quantity Control */
.variation-quantity {
    margin-bottom: 15px;
}

.variation-quantity > label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 14px;
    color: #333;
    text-transform: uppercase;
}

.quantity-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.qty-minus,
.qty-plus {
    width: 50px;
    height: 50px;
    background: #f5f5f5;
    border: 2px solid #ddd;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.qty-minus {
    border-radius: 10px 0 0 10px;
    border-right: none;
}

.qty-plus {
    border-radius: 0 10px 10px 0;
    border-left: none;
}

.qty-minus:active,
.qty-plus:active {
    background: #e0e0e0;
}

.qty-input {
    width: 70px;
    height: 50px;
    border: 2px solid #ddd;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Variation Notes */
.variation-notes {
    margin-bottom: 15px;
}

.variation-notes > label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.variation-notes textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
}

.variation-notes textarea:focus {
    outline: none;
    border-color: #c41e3a;
}

/* Variation Total */
.variation-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 10px;
    margin-bottom: 15px;
}

.total-label {
    font-size: 16px;
    color: #666;
}

.total-price {
    font-size: 24px;
    font-weight: bold;
    color: #c41e3a;
}

/* Add Variation to Cart Button */
.btn-add-variation-to-cart {
    display: block;
    width: 100%;
    padding: 16px 30px;
    background: #c41e3a;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-add-variation-to-cart:active:not(:disabled) {
    background: #a01830;
    transform: scale(0.99);
}

.btn-add-variation-to-cart:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Modal Loading State */
.maestro-modal-body.loading {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.maestro-modal-body.loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid #eee;
    border-top-color: #c41e3a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Desktop Styles */
@media (min-width: 768px) {
    .maestro-menu-wrapper {
        max-width: 1200px;
        margin: 0 auto;
        padding: 20px;
    }

    .maestro-menu-tabs {
        margin: 0 0 30px;
        padding: 15px 0;
    }

    /* Hide scroll buttons on desktop */
    .menu-tabs-scroll-btn {
        display: none !important;
    }

    .menu-tabs-list {
        justify-content: center;
        flex-wrap: wrap;
        padding: 0;
        overflow-x: visible;
    }

    .menu-tab-link {
        padding: 12px 20px;
        font-size: 14px;
    }

    .category-title {
        font-size: 28px;
    }

    .category-icon {
        font-size: 32px;
    }

    .products-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 25px;
    }

    .menu-product-card {
        flex-direction: column;
    }

    .menu-product-card .product-image {
        width: 100%;
        height: 180px;
        min-width: auto;
    }

    .menu-product-card .product-info {
        padding: 20px;
    }

    .menu-product-card .product-title {
        font-size: 18px;
    }

    .menu-product-card .product-description {
        display: block;
        margin: 0 0 15px;
        font-size: 14px;
        color: #666;
        line-height: 1.5;
    }

    .menu-product-card .product-price {
        font-size: 20px;
    }

    .maestro-modal {
        align-items: center;
        justify-content: center;
    }

    .maestro-modal-content {
        border-radius: 16px;
        max-width: 500px;
        max-height: 90vh;
    }

    @keyframes slideUp {
        from {
            opacity: 0;
            transform: translateY(-20px) scale(0.95);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }

    .variation-btn {
        flex: 0 0 auto;
        min-width: auto;
    }
}
