/**
 * Restaurant Menu Widgets - Main Styles
 * Mobile-first responsive design
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */
:root {
    /* ── ACF brand tokens — fallbacks; overridden at runtime by inline <style> ── */
    --color-primary:   #333333;
    --color-secondary: #666666;
    --color-accent:    #8B4513;

    /* ── Map brand tokens to plugin variables ── */
    --rmw-primary-color:   var(--color-primary);
    --rmw-secondary-color: var(--color-secondary);
    --rmw-accent-color:    var(--color-accent);

    /* ── Neutral / structural — unchanged ── */
    --rmw-background:      #ffffff;
    --rmw-card-background: #ffffff;
    --rmw-border-color:    #e5e5e5;
    --rmw-button-bg:       #ffffff;
    --rmw-button-hover-bg: #f5f5f5;
    --rmw-shadow:          0 2px 8px rgba(0, 0, 0, 0.1);
    --rmw-shadow-hover:    0 4px 16px rgba(0, 0, 0, 0.15);
    --rmw-transition:      0.3s ease;
    --rmw-border-radius:   12px;
}

/* ==========================================================================
   Base Widget Styles
   ========================================================================== */
.rmw-carousel-widget {
    position: relative;
    width: 100%;
    margin-bottom: 2rem;
}

.rmw-section-title,
.rmw-category-title {
    font-size: 1.5rem;
    font-weight: 600;
    color:var(--rmw-primary-color) !important;
    margin: 0 0 1rem 0;
    line-height: 1.3;
}

/* ==========================================================================
   Category Header
   ========================================================================== */
.rmw-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.rmw-category-title {
    margin: 0;
}

.rmw-product-count {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--rmw-secondary-color);
}

.rmw-see-all {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--rmw-secondary-color);
    text-decoration: none;
    transition: color var(--rmw-transition);
}

.rmw-see-all:hover {
    color: var(--rmw-primary-color);
}

.rmw-see-all svg {
    transition: transform var(--rmw-transition);
}

.rmw-see-all:hover svg {
    transform: translateX(3px);
}

/* ==========================================================================
   Carousel Container
   ========================================================================== */
.rmw-carousel-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rmw-swiper {
    width: 100%;
    overflow: hidden;
    padding: 0.5rem 0;
}

/* Enable touch scrolling on mobile; stretch so all slides in a row share the same height */
.rmw-swiper .swiper-wrapper {
    display: flex;
    align-items: stretch;
    touch-action: pan-y;
}

.rmw-swiper .swiper-slide {
    height: auto;
}

/* ==========================================================================
   Navigation Buttons
   ========================================================================== */
.rmw-nav-btn {
    display: none; /* Hidden on mobile by default */
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--rmw-button-bg);
    border: 1px solid var(--rmw-border-color);
    cursor: pointer;
    transition: all var(--rmw-transition);
    box-shadow: var(--rmw-shadow);
    padding: 0;
    align-items: center;
    justify-content: center;
    color: var(--rmw-primary-color);
}

.rmw-nav-btn:hover {
    background-color: var(--rmw-button-hover-bg);
    box-shadow: var(--rmw-shadow-hover);
}

.rmw-nav-btn:disabled,
.rmw-nav-btn.swiper-button-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.rmw-nav-prev {
    left: -20px;
}

.rmw-nav-next {
    right: -20px;
}

/* ==========================================================================
   Pagination
   ========================================================================== */
.rmw-swiper .swiper-pagination {
    position: relative;
    margin-top: 1rem;
    bottom: auto;
}

.rmw-swiper .swiper-pagination-bullet {
    width: 8px;
    height: 8px;
    background-color: var(--rmw-border-color);
    opacity: 1;
    transition: all var(--rmw-transition);
}

.rmw-swiper .swiper-pagination-bullet-active {
    background-color: var(--rmw-primary-color);
    width: 24px;
    border-radius: 4px;
}

/* ==========================================================================
   Product Card
   ========================================================================== */
.rmw-product-card {
    background-color: var(--rmw-card-background);
    border-radius: var(--rmw-border-radius);
    overflow: hidden;
    transition: all var(--rmw-transition);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.rmw-product-card:hover {
    box-shadow: var(--rmw-shadow-hover);
}

/* ==========================================================================
   Product Image
   ========================================================================== */
.rmw-product-image {
    position: relative;
    overflow: hidden;
    border-radius: var(--rmw-border-radius) var(--rmw-border-radius) 0 0;
}

.rmw-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--rmw-transition);
}

.rmw-product-card:hover .rmw-product-image img {
    transform: scale(1.05);
}

/* Aspect Ratios */
.rmw-aspect-1-1 {
    aspect-ratio: 1 / 1;
}

.rmw-aspect-4-3 {
    aspect-ratio: 4 / 3;
}

.rmw-aspect-16-9 {
    aspect-ratio: 16 / 9;
}

.rmw-aspect-3-4 {
    aspect-ratio: 3 / 4;
}

/* Fallback for browsers without aspect-ratio support */
@supports not (aspect-ratio: 1 / 1) {
    .rmw-aspect-1-1 {
        padding-bottom: 100%;
        height: 0;
    }

    .rmw-aspect-4-3 {
        padding-bottom: 75%;
        height: 0;
    }

    .rmw-aspect-16-9 {
        padding-bottom: 56.25%;
        height: 0;
    }

    .rmw-aspect-3-4 {
        padding-bottom: 133.33%;
        height: 0;
    }

    .rmw-aspect-1-1 img,
    .rmw-aspect-4-3 img,
    .rmw-aspect-16-9 img,
    .rmw-aspect-3-4 img {
        position: absolute;
        top: 0;
        left: 0;
    }
}

/* ==========================================================================
   Action Buttons (Quick View & Add to Cart)
   ========================================================================== */
.rmw-action-buttons {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity var(--rmw-transition);
    z-index: 5;
}

/* Show action buttons on hover (desktop) and always on touch devices */
.rmw-product-card:hover .rmw-action-buttons {
    opacity: 1;
}

.rmw-action-btn {
    width: 44px; /* Touch-friendly minimum size */
    height: 44px;
    border-radius: 8px;
    background-color: var(--rmw-button-bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--rmw-transition);
    box-shadow: var(--rmw-shadow);
    color: var(--rmw-primary-color);
    padding: 0;
}

.rmw-action-btn:hover {
    background-color: var(--rmw-button-hover-bg);
    transform: translateY(-2px);
    box-shadow: var(--rmw-shadow-hover);
}

.rmw-action-btn:active {
    transform: translateY(0);
}

.rmw-action-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* Loading state for add to cart */
.rmw-action-btn.rmw-loading {
    pointer-events: none;
}

.rmw-action-btn.rmw-loading svg {
    animation: rmw-spin 1s linear infinite;
}

@keyframes rmw-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Success state */
.rmw-action-btn.rmw-success {
    background-color: #4CAF50;
    color: white;
}

/* ==========================================================================
   Product Info
   ========================================================================== */
.rmw-product-info {
    padding: 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.rmw-category-badge {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--rmw-accent-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    display: block;
}

.rmw-product-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--rmw-primary-color);
    margin: 0 0 0.5rem 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rmw-product-title a {
    color: inherit;
    text-decoration: none;
    transition: color var(--rmw-transition);
}

.rmw-product-title a:hover {
    color: var(--rmw-accent-color);
}

.rmw-product-price {
    font-size: 1rem;
    font-weight: 600;
    color: var(--rmw-secondary-color);
    margin-top: auto;
}

.rmw-product-price del {
    font-weight: 400;
    color: var(--rmw-secondary-color);
    margin-right: 0.5rem;
}

.rmw-product-price ins {
    text-decoration: none;
}

/* ==========================================================================
   Time Indicator
   ========================================================================== */
.rmw-time-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background-color: var(--rmw-accent-color);
    color: white;
    border-radius: 50px;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.rmw-time-indicator-label {
    font-weight: 400;
}

.rmw-time-indicator-period {
    font-weight: 600;
}

/* ==========================================================================
   Category Block Spacing
   ========================================================================== */
.rmw-category-block {
    margin-bottom: 2.5rem;
}

.rmw-category-block:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   Corner Add to Cart Button (Mobile-friendly persistent button)
   ========================================================================== */
.rmw-corner-cart-btn {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 85px;
    height: 32px;
    background-color: var(--rmw-accent-color)!important;
    border: none;
    border-radius: 20px 0 var(--rmw-border-radius) 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    font-weight: 600;
    z-index: 10;
    transition: background-color var(--rmw-transition), transform var(--rmw-transition), filter var(--rmw-transition);
}

.rmw-corner-cart-btn:hover {
    background-color: var(--rmw-accent-color);
    filter: brightness(0.85);
    transform: scale(1.05);
}

.rmw-corner-cart-btn:active {
    filter: none;
    transform: scale(0.98);
}

.rmw-corner-cart-btn.rmw-loading {
    pointer-events: none;
}

.rmw-corner-cart-btn.rmw-loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: rmw-spin 0.8s linear infinite;
}

.rmw-corner-cart-btn.rmw-loading span {
    display: none;
}

.rmw-corner-cart-btn.rmw-success {
    background-color: #4CAF50;
}

.rmw-corner-cart-btn.rmw-success span {
    display: none;
}

.rmw-corner-cart-btn.rmw-success::after {
    content: '✓';
    font-size: 18px;
}

/* ==========================================================================
   Mobile Styles (Default - Mobile First)
   ========================================================================== */

/* Mobile: 2 cards per row */
@media (max-width: 639px) {
    .rmw-swiper .swiper-wrapper {
        display: flex;
    }

    .rmw-swiper .swiper-slide {
        width: calc(50% - 8px) !important;
        flex-shrink: 0;
    }

    .rmw-product-card {
        font-size: 0.875rem;
    }

    .rmw-product-info {
        padding: 0.75rem;
    }

    .rmw-product-title {
        font-size: 0.875rem;
        line-height: 1.3;
        margin-bottom: 0.25rem;
    }

    .rmw-product-price {
        font-size: 0.875rem;
    }

    .rmw-category-badge {
        font-size: 0.625rem;
        margin-bottom: 0.25rem;
    }

    /* Smaller corner button on mobile */
    .rmw-corner-cart-btn {
        width: 65px;
        height: 28px;
        font-size: 16px;
        border-radius: 16px 0 var(--rmw-border-radius) 0;
    }

    /* Hide hover action buttons on mobile, show corner button instead */
    .rmw-action-buttons {
        opacity: 0;
        pointer-events: none; /* Allow clicks to pass through to links underneath */
    }

    .rmw-product-card:hover .rmw-action-buttons {
        opacity: 0;
        pointer-events: none;
    }

    /* Mobile-friendly See All link - larger touch target */
    .rmw-see-all {
        min-height: 44px;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        font-weight: 500;
        background-color: var(--rmw-button-hover-bg, #f5f5f5);
        border-radius: 6px;
        margin: 0.25rem 0;
    }

    .rmw-see-all:active {
        background-color: var(--rmw-border-color, #e5e5e5);
    }

    /* Ensure category header wraps properly on mobile */
    .rmw-category-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .rmw-category-title {
        flex: 1 1 100%;
        font-size: 1.25rem;
    }
}

/* Touch-friendly: Always show action buttons on mobile */
@media (hover: none) and (pointer: coarse) {
    .rmw-action-buttons {
        opacity: 1;
        pointer-events: auto;
    }

    /* On touch devices below tablet, hide hover buttons and allow clicks through */
    @media (max-width: 639px) {
        .rmw-action-buttons {
            opacity: 0 !important;
            pointer-events: none !important; /* Allow clicks to pass through to product links */
        }
    }
}

/* Swipe indicator on mobile */
.rmw-swipe-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    color: var(--rmw-secondary-color);
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.rmw-swipe-indicator svg {
    animation: rmw-swipe-hint 1.5s ease-in-out infinite;
}

@keyframes rmw-swipe-hint {
    0%, 100% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(5px);
    }
}

/* ==========================================================================
   Tablet Styles (640px and up)
   ========================================================================== */
@media (min-width: 640px) {
    .rmw-section-title,
    .rmw-category-title {
        font-size: 1.75rem;
    }

    .rmw-product-info {
        padding: 1.25rem;
    }

    .rmw-product-title {
        font-size: 1.125rem;
    }

    .rmw-category-block {
        margin-bottom: 3rem;
    }
}

/* ==========================================================================
   Desktop Styles (1024px and up)
   ========================================================================== */
@media (min-width: 1024px) {
    .rmw-nav-btn {
        display: flex;
    }

    .rmw-carousel-container {
        padding: 0 2rem;
    }

    .rmw-nav-prev {
        left: 0;
    }

    .rmw-nav-next {
        right: 0;
    }

    .rmw-section-title,
    .rmw-category-title {
        font-size: 2rem;
    }

    .rmw-category-header {
        margin-bottom: 1.5rem;
    }

    .rmw-see-all {
        font-size: 1rem;
    }

    .rmw-swipe-indicator {
        display: none;
    }

    .rmw-category-block {
        margin-bottom: 3.5rem;
    }
}

/* ==========================================================================
   Large Desktop (1280px and up)
   ========================================================================== */
@media (min-width: 1280px) {
    .rmw-carousel-container {
        padding: 0 3rem;
    }

    .rmw-nav-btn {
        width: 48px;
        height: 48px;
    }
}

/* ==========================================================================
   Quick View Modal (Basic Structure)
   ========================================================================== */
.rmw-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--rmw-transition), visibility var(--rmw-transition);
}

.rmw-modal-overlay.rmw-active {
    opacity: 1;
    visibility: visible;
}

.rmw-modal {
    background-color: var(--rmw-background);
    border-radius: var(--rmw-border-radius);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform var(--rmw-transition);
    -webkit-overflow-scrolling: touch;
}

.rmw-modal-overlay.rmw-active .rmw-modal {
    transform: translateY(0);
}

.rmw-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--rmw-button-bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all var(--rmw-transition);
}

.rmw-modal-close:hover {
    background-color: var(--rmw-button-hover-bg);
}

.rmw-modal-content {
    position: relative;
    padding: 1.5rem;
}

/* Quick View Modal Specific Styles */
.rmw-quickview-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (min-width: 640px) {
    .rmw-quickview-content {
        flex-direction: row;
    }
}

.rmw-quickview-image {
    flex: 0 0 auto;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
}

@media (min-width: 640px) {
    .rmw-quickview-image {
        width: 45%;
        max-width: none;
    }
}

.rmw-quickview-image img {
    width: 100%;
    height: auto;
    border-radius: var(--rmw-border-radius);
    object-fit: cover;
}

.rmw-quickview-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rmw-quickview-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--rmw-primary-color);
    margin: 0;
}

.rmw-quickview-price {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--rmw-primary-color);
}

.rmw-quickview-price del {
    color: var(--rmw-secondary-color);
    font-weight: 400;
    margin-right: 0.5rem;
}

.rmw-quickview-description {
    color: var(--rmw-secondary-color);
    line-height: 1.6;
    font-size: 0.9375rem;
}

.rmw-quickview-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--rmw-secondary-color);
}

.rmw-quickview-category {
    background: var(--rmw-border-color);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
}

.rmw-quickview-actions {
    display: flex;
    gap: 1rem;
    margin-top: auto;
    padding-top: 1rem;
}

.rmw-quickview-add-btn {
    flex: 1;
    padding: 0.875rem 1.5rem;
    background-color: var(--rmw-primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--rmw-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.rmw-quickview-add-btn:hover {
    background-color: var(--rmw-primary-color);
    filter: brightness(0.75);
    transform: translateY(-1px);
}

.rmw-quickview-add-btn.rmw-loading {
    pointer-events: none;
    opacity: 0.7;
}

.rmw-quickview-view-btn {
    padding: 0.875rem 1.5rem;
    background-color: transparent;
    color: var(--rmw-primary-color);
    border: 1px solid var(--rmw-border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--rmw-transition);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rmw-quickview-view-btn:hover {
    border-color: var(--rmw-primary-color);
    background-color: var(--rmw-button-hover-bg);
}

.rmw-quickview-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.rmw-quickview-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--rmw-border-color);
    border-top-color: var(--rmw-primary-color);
    border-radius: 50%;
    animation: rmw-spin 0.8s linear infinite;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */
.rmw-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--rmw-primary-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    z-index: 100000;
    opacity: 0;
    transition: all var(--rmw-transition);
    box-shadow: var(--rmw-shadow-hover);
}

.rmw-toast.rmw-active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.rmw-toast.rmw-success {
    background-color: #4CAF50;
}

.rmw-toast.rmw-error {
    background-color: #f44336;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */
.rmw-action-btn:focus,
.rmw-nav-btn:focus,
.rmw-modal-close:focus {
    outline: 2px solid var(--rmw-accent-color);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .rmw-nav-btn,
    .rmw-action-buttons,
    .rmw-swipe-indicator {
        display: none !important;
    }
}
