/* ============================================
   BEASTSTORE MOBILE FIXES - v30
   Fix mobile checkout, language switcher, and close button issues
   ============================================ */

/* Force warm background on ALL mobile elements */
@media (max-width: 768px) {
    :root {
        --bg: #FDF8F3 !important;
        --bg-card: #FFF8F0 !important;
        --bg-warm: #FFF0E0 !important;
        --text: #3D2914 !important;
        --text-light: #5C4A3A !important;
        --text-muted: #8B7355 !important;
        --border: #FFD9B3 !important;
    }

    html, body {
        background: linear-gradient(180deg, #FDF8F3 0%, #FFF5EB 50%, #FFEDD5 100%) !important;
        background-attachment: fixed !important;
        color: #3D2914 !important;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* ALL white backgrounds become warm - EXCEPT images */
    *:not(img):not(svg):not(canvas) {
        background-color: transparent;
    }
    
    /* Ensure images are visible */
    img, .product-img {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .cart-sidebar,
    .cart-header,
    .cart-items,
    .cart-footer,
    .checkout-content,
    .checkout-header,
    .checkout-body,
    .product-modal-content,
    .modal-product-info {
        background: linear-gradient(180deg, #FFF8F0 0%, #FFF0E0 100%) !important;
    }

    /* Text colors - dark brown for readability */
    .cart-item-name,
    .cart-item-price,
    .cart-total-label,
    .cart-total-price,
    .checkout-content h2,
    .checkout-content h3,
    .form-group label,
    .modal-product-info h2,
    .modal-product-info p,
    .product-desc,
    .spec-item span,
    .product-personality,
    .product-name,
    .product-price,
    .nav-link,
    .hero-title,
    .hero-desc,
    .stat-label,
    .stat-num {
        color: #3D2914 !important;
    }

    /* Secondary text */
    .cart-empty p,
    .text-muted,
    .product-desc,
    .modal-desc,
    .spec-item small {
        color: #5C4A3A !important;
    }

    /* Fix cart - keep drawer style on mobile */
    .cart-sidebar {
        width: 85% !important;
        max-width: 400px !important;
        right: -85% !important;
        background: linear-gradient(180deg, #FFF8F0 0%, #FFEDD5 100%) !important;
        box-shadow: -5px 0 30px rgba(0,0,0,0.15) !important;
    }

    .cart-sidebar.open {
        right: 0 !important;
    }

    .cart-header {
        background: linear-gradient(90deg, #FFF0E0 0%, #FFE4CC 100%) !important;
        border-bottom: 2px solid #FFD9B3 !important;
    }

    .cart-footer {
        background: linear-gradient(180deg, #FFF5EB 0%, #FFE8D6 100%) !important;
        border-top: 2px solid #FFD9B3 !important;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.1) !important;
    }

    .cart-item {
        background: rgba(255,255,255,0.6) !important;
        border: 1px solid #FFD9B3 !important;
        border-radius: 12px !important;
        margin-bottom: 12px !important;
    }

    .cart-item:hover {
        background: rgba(255,255,255,0.8) !important;
    }

    /* Fix checkout visibility */
    .checkout-content {
        background: linear-gradient(180deg, #FFF8F0 0%, #FFEDD5 100%) !important;
    }

    .checkout-header {
        background: linear-gradient(90deg, #FFF0E0 0%, #FFE4CC 100%) !important;
        border-bottom: 2px solid #FFD9B3 !important;
    }

    .form-group input,
    .form-group textarea,
    .form-group select {
        background: #FFFDF9 !important;
        border: 2px solid #FFD9B3 !important;
        color: #3D2914 !important;
        font-size: 16px !important;
    }

    .form-group input::placeholder {
        color: #A08060 !important;
    }

    /* Product modal visibility */
    .product-modal-content {
        background: linear-gradient(180deg, #FFF8F0 0%, #FFF0E0 100%) !important;
    }

    .modal-product-info {
        background: linear-gradient(180deg, #FFF8F0 0%, #FFEDD5 100%) !important;
    }

    .modal-close {
        background: rgba(255,248,240,0.95) !important;
        color: #3D2914 !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
    }

    /* Modal actions sticky bar */
    .modal-actions {
        background: linear-gradient(180deg, transparent 0%, #FFF0E0 20%) !important;
        padding: 16px 0 !important;
    }

    /* Ensure all cards have warm backgrounds */
    .product-card,
    .ai-feature-card,
    .scenario-card,
    .feature-card {
        background: linear-gradient(145deg, #FFF8F0 0%, #FFEDD5 100%) !important;
        border: 1px solid #FFD9B3 !important;
    }

    /* Navbar */
    .navbar {
        background: linear-gradient(135deg, rgba(255,248,240,0.98) 0%, rgba(255,240,224,0.98) 100%) !important;
        border-bottom: 1px solid #FFD9B3 !important;
    }

    .nav-brand .brand-text {
        color: #E85A8A !important;
    }

    /* Hero section */
    .hero {
        background: linear-gradient(135deg, #FDF8F3 0%, #FFF0E0 50%, #FFE8D6 100%) !important;
    }

    /* Footer */
    .footer {
        background: linear-gradient(180deg, #3D2914 0%, #2A1C0E 100%) !important;
        color: #FFE4CC !important;
        padding: 40px 20px 30px !important;
    }

    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
        text-align: center !important;
    }

    .footer-brand {
        justify-content: center !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    .footer-links {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
        text-align: left !important;
    }

    .footer-col h4 {
        font-size: 0.9rem !important;
        margin-bottom: 12px !important;
    }

    .footer-col a {
        font-size: 0.8rem !important;
        margin-bottom: 8px !important;
        display: block !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .social-icons {
        display: flex !important;
        gap: 8px !important;
    }

    .social-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 16px !important;
    }

    .footer-col {
        min-width: 0 !important;
    }

    .footer a,
    .footer p,
    .footer h4 {
        color: #FFE4CC !important;
    }

    .footer-brand .brand-text {
        color: #FF8FB3 !important;
    }

    .footer-bottom {
        text-align: center !important;
        padding-top: 20px !important;
    }

    /* Empty states */
    .cart-empty {
        background: rgba(255,248,240,0.5) !important;
        border-radius: 16px !important;
        padding: 40px 20px !important;
    }

    .cart-empty p {
        color: #5C4A3A !important;
    }

    /* Scrollbar styling for mobile */
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }

    ::-webkit-scrollbar-track {
        background: #FFE4CC !important;
    }

    ::-webkit-scrollbar-thumb {
        background: #FFB347 !important;
        border-radius: 2px !important;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    :root {
        --text: #2D1F10 !important;
    }

    .product-card {
        background: linear-gradient(145deg, #FFF5EB 0%, #FFE8D6 100%) !important;
    }

    .product-name {
        font-size: 0.95rem !important;
        font-weight: 700 !important;
    }

    .product-price {
        font-size: 1.1rem !important;
        font-weight: 800 !important;
        color: #E85A8A !important;
    }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    .cart-item:active,
    .product-card:active {
        background: rgba(255,255,255,0.9) !important;
        transform: scale(0.98) !important;
    }

    .btn:active {
        transform: scale(0.95) !important;
    }
}

/* ============================================
   CRITICAL FIXES FOR MOBILE ISSUES
   ============================================ */

/* Fix 1: Ensure checkout modal is hidden by default on mobile */
@media (max-width: 768px) {
    .checkout-modal {
        display: none !important;
        align-items: flex-end !important;
        padding: 0 !important;
        z-index: 9999 !important;
    }
    
    .checkout-modal[style*="flex"] {
        display: flex !important;
    }

    .checkout-content {
        width: 100% !important;
        max-height: 90vh !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0 !important;
    }
    
    .checkout-content.animating {
        animation: slideUp 0.3s ease !important;
    }

    .checkout-close {
        font-size: 32px !important;
        padding: 10px 15px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        z-index: 10000 !important;
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation !important;
        cursor: pointer !important;
        background: rgba(255,240,224,0.9) !important;
        border-radius: 50% !important;
        width: 44px !important;
        height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    
    /* Fix 2: Language selector mobile fixes - compact like cart header */
    .lang-selector {
        position: relative !important;
    }
    
    .lang-dropdown {
        position: absolute !important;
        top: calc(100% + 8px) !important;
        right: 0 !important;
        left: auto !important;
        bottom: auto !important;
        margin-top: 0 !important;
        width: auto !important;
        min-width: 100px !important;
        max-width: 140px !important;
        height: auto !important;
        max-height: 200px !important;
        background: #FFF8F0 !important;
        border: 2px solid #FFD9B3 !important;
        border-radius: 12px !important;
        box-shadow: 0 8px 30px rgba(0,0,0,0.2) !important;
        z-index: 10000 !important;
        padding: 4px !important;
        overflow: visible !important;
    }
    
    .lang-option {
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
        background: transparent !important;
        border: none !important;
        border-radius: 6px !important;
        width: 100% !important;
        text-align: left !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation !important;
        margin-bottom: 2px !important;
        white-space: nowrap !important;
        line-height: 1.2 !important;
    }
    
    .lang-option:last-child {
        margin-bottom: 0 !important;
    }
    
    .lang-option:active,
    .lang-option.active {
        background: #FFE4CC !important;
    }
    
    /* Fix 3: Cart sidebar z-index fix */
    .cart-sidebar {
        z-index: 9998 !important;
    }
    
    .cart-overlay {
        z-index: 9997 !important;
    }
}

/* Prevent iOS double-tap zoom on buttons */
button, .btn, .lang-option, .checkout-close, .cart-close, .modal-close {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Ensure checkout modal doesn't auto-show */
.checkout-modal:not([style*="flex"]):not(.show) {
    display: none !important;
}
