/**
 * Mobile UX Enhancements for Legacy jQuery Seating Chart
 * Addresses 50% lower mobile conversion rate (19.3% vs 38.1% desktop)
 *
 * Target: /reserve/vtcPostPerformance.php (legacy image-swap chart)
 * Simplified version - minimal overflow risk
 */

/* ========================================
   MOBILE-SPECIFIC ENHANCEMENTS
   ======================================== */

@media (max-width: 768px) {

    /* ===== FIX 1: Tap Target Enhancement ===== */
    /* Add invisible padding for easier tapping without changing visual size */
    /* All seats stay at 20px to match sold buttons */
    #seatingChartTable [class^="img-swap"],
    #seatingChartTable [class*=" img-swap"] {
        padding: 4px;
        margin: -4px;
        display: inline-block;
        cursor: pointer;
        box-sizing: content-box;
        /* No min-width/min-height - keep native 20px size */
    }

    /* ===== FIX 3: Prevent Page Overflow ===== */
    body {
        overflow-x: hidden;
    }

    .pageContainer {
        max-width: 100% !important;
        overflow-x: auto;
    }

    /* ===== FIX 4: Seating Chart Table Scrollable ===== */
    #seatingChartTable {
        width: auto;
        max-width: 100%;
    }

    /* ===== FIX 5: Cart Display Area (mobile-specific positioning is handled globally below) ===== */

    /* ===== FIX 6: Seat Count Badge (only when seats selected) ===== */
    .seat-count-badge {
        position: fixed;
        top: 80px;
        right: 15px;
        background: #2196F3;
        color: white;
        width: 45px;
        height: 45px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        font-weight: bold;
        box-shadow: 0 3px 10px rgba(33, 150, 243, 0.5);
        z-index: 999;
        pointer-events: none;
    }

    /* Hide badge when empty */
    .seat-count-badge.empty,
    .seat-count-badge:empty {
        display: none;
    }

    /* ===== FIX 7: Prevent Accidental Zoom ===== */
    table {
        touch-action: manipulation;
    }

    /* ===== FIX 8: Better Stage Label ===== */
    .bottom {
        font-size: 14px;
        padding: 8px;
    }

    /* ===== FIX 9: Section Title ===== */
    .description {
        font-size: 16px;
        padding: 10px;
    }
}

/* ========================================
   SMALL MOBILE DEVICES (< 480px)
   ======================================== */

@media (max-width: 480px) {

    /* Slightly larger invisible tap area for small phones */
    #seatingChartTable [class^="img-swap"],
    #seatingChartTable [class*=" img-swap"] {
        padding: 6px;
        margin: -6px;
        /* No min-width/min-height - keep native 20px size */
    }

    /* More compact text */
    .bottom {
        font-size: 12px;
        padding: 6px;
    }

    .description {
        font-size: 14px;
        padding: 8px;
    }
}

/* ========================================
   ACCESSIBILITY ENHANCEMENTS
   ======================================== */

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* ========================================
   STICKY CART BAR — pins #cart to viewport bottom when seats are selected.
   ======================================== */
#cart:not(:empty) {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    padding: 6px 12px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 35vh;
    overflow-y: auto;
    border-top: 2px solid #4CAF50;
    text-align: center;
    animation: cart-slide-up 0.2s ease-out;
}

/* Strip default margins from any tags vb_cart.inc injects (html, body, form) */
#cart:not(:empty) html,
#cart:not(:empty) body,
#cart:not(:empty) form {
    margin: 0;
    padding: 0;
}

#cart:not(:empty) br {
    display: none;
}

#cart:not(:empty) button[type='submit'],
#cart:not(:empty) .btn-primary-green {
    font-size: 15px;
    padding: 8px 20px;
    border-radius: 6px;
    margin: 4px 0 !important;
}

#cart:not(:empty) #clear {
    font-size: 11px;
    color: #888;
}

@keyframes cart-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Pad the page so the last row of seats isn't covered by the sticky bar */
body:has(#cart:not(:empty)) {
    padding-bottom: 110px;
}
