/**
 * FIGA - Mobile-Optimized Snipcart Checkout
 * 
 * This CSS file customizes Snipcart's checkout to be:
 * - Mobile-first and thumb-friendly
 * - One-page experience
 * - Touch-optimized
 * - Italian design aesthetic
 * 
 * Add this AFTER Snipcart's default CSS in your HTML:
 * <link rel="stylesheet" href="snipcart-mobile-optimization.css">
 */

/* ========================================
   MOBILE-FIRST: LARGER TOUCH TARGETS
   ======================================== */

/* Increase touch target size for all interactive elements */
.snipcart-checkout .snipcart__actions--link,
.snipcart-checkout button,
.snipcart-checkout input[type="submit"],
.snipcart-checkout input[type="button"],
.snipcart-checkout .snipcart-button-primary,
.snipcart-checkout .snipcart-button-secondary {
    min-height: 48px !important;
    padding: 14px 24px !important;
    font-size: 16px !important;
    border-radius: 2px !important;
    margin: 8px 0 !important;
}

/* Input fields - thumb-friendly */
.snipcart-checkout input[type="text"],
.snipcart-checkout input[type="email"],
.snipcart-checkout input[type="tel"],
.snipcart-checkout input[type="number"],
.snipcart-checkout select,
.snipcart-checkout textarea {
    min-height: 48px !important;
    padding: 14px 16px !important;
    font-size: 16px !important; /* Prevents iOS zoom */
    border-radius: 2px !important;
    margin: 8px 0 !important;
}

/* Checkbox and radio buttons - larger tap areas */
.snipcart-checkout input[type="checkbox"],
.snipcart-checkout input[type="radio"] {
    min-width: 24px !important;
    min-height: 24px !important;
    margin: 12px !important;
}

.snipcart-checkout label {
    padding: 12px 8px !important;
    cursor: pointer;
}

/* ========================================
   ONE-PAGE CHECKOUT EXPERIENCE
   ======================================== */

/* Hide step indicators if using one-page flow */
.snipcart-checkout__content--steps {
    display: none !important;
}

/* Show all sections at once on mobile */
@media (max-width: 768px) {
    .snipcart-checkout__content {
        display: block !important;
    }
    
    /* Remove collapsible sections - show everything */
    .snipcart-checkout__content--collapsible {
        display: block !important;
        max-height: none !important;
    }
    
    /* Make forms full width */
    .snipcart-checkout__content--form {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ========================================
   ITALIAN DESIGN AESTHETIC
   ======================================== */

/* Primary button - Italian flag colors */
.snipcart-checkout .snipcart-button-primary {
    background: #009246 !important; /* Italian green */
    color: #ffffff !important;
    border: none !important;
    font-weight: 400 !important;
    letter-spacing: 1px !important;
    text-transform: uppercase !important;
    transition: all 0.3s ease !important;
}

.snipcart-checkout .snipcart-button-primary:hover {
    background: #007a3a !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 146, 70, 0.3) !important;
}

/* Secondary button */
.snipcart-checkout .snipcart-button-secondary {
    background: transparent !important;
    border: 1px solid #1a1a1a !important;
    color: #1a1a1a !important;
    font-weight: 300 !important;
    letter-spacing: 1px !important;
    text-transform: uppercase !important;
}

/* Cart summary - Italian accent */
.snipcart-checkout .snipcart-cart-summary {
    border-top: 3px solid transparent !important;
    border-image: linear-gradient(to right, #009246 0%, #009246 33%, #ffffff 33%, #ffffff 66%, #ce2b37 66%, #ce2b37 100%) 1 !important;
}

/* Input focus states - Italian green */
.snipcart-checkout input:focus,
.snipcart-checkout select:focus,
.snipcart-checkout textarea:focus {
    border-color: #009246 !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(0, 146, 70, 0.1) !important;
}

/* ========================================
   MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 768px) {
    /* Full-screen modal on mobile */
    .snipcart-modal {
        max-width: 100% !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    
    .snipcart-modal__container {
        max-width: 100% !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
    }
    
    /* Add padding for thumb reach */
    .snipcart-checkout {
        padding: 16px !important;
        padding-bottom: 80px !important; /* Space for bottom CTA */
    }
    
    /* Stack form fields vertically */
    .snipcart-form__row {
        display: block !important;
    }
    
    .snipcart-form__field {
        width: 100% !important;
        margin-bottom: 16px !important;
    }
    
    /* Larger text for readability */
    .snipcart-checkout h2,
    .snipcart-checkout h3 {
        font-size: 22px !important;
        font-weight: 300 !important;
        letter-spacing: 1px !important;
        margin-bottom: 16px !important;
    }
    
    /* Order summary - collapsible on mobile */
    .snipcart-cart-summary {
        position: sticky !important;
        top: 0 !important;
        background: #ffffff !important;
        z-index: 100 !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
        padding: 16px !important;
        margin-bottom: 24px !important;
    }
    
    /* Sticky checkout button at bottom */
    .snipcart-checkout__actions {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: #ffffff !important;
        padding: 16px !important;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1) !important;
        z-index: 1000 !important;
    }
    
    .snipcart-checkout__actions button {
        width: 100% !important;
        min-height: 56px !important;
        font-size: 18px !important;
    }
}

/* ========================================
   THUMB-FRIENDLY QUANTITY CONTROLS
   ======================================== */

.snipcart-checkout .snipcart__item--quantity {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}

.snipcart-checkout .snipcart__item--quantity button {
    min-width: 48px !important;
    min-height: 48px !important;
    border-radius: 50% !important;
    font-size: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1px solid #e0e0e0 !important;
    background: #ffffff !important;
    color: #1a1a1a !important;
}

.snipcart-checkout .snipcart__item--quantity input {
    width: 60px !important;
    text-align: center !important;
    font-size: 18px !important;
    font-weight: 500 !important;
}

/* ========================================
   REMOVE ITEM - SAFER INTERACTION
   ======================================== */

.snipcart-checkout .snipcart__item--remove {
    min-width: 48px !important;
    min-height: 48px !important;
    padding: 12px !important;
    color: #ce2b37 !important; /* Italian red for delete */
}

.snipcart-checkout .snipcart__item--remove:hover {
    background: rgba(206, 43, 55, 0.1) !important;
    border-radius: 4px !important;
}

/* ========================================
   ACCORDION-STYLE SECTIONS (OPTIONAL)
   ======================================== */

/* If you want collapsible sections on mobile */
.snipcart-checkout__section {
    border: 1px solid #e0e0e0 !important;
    border-radius: 4px !important;
    margin-bottom: 16px !important;
    overflow: hidden !important;
}

.snipcart-checkout__section-header {
    padding: 16px !important;
    background: #f8f8f8 !important;
    cursor: pointer !important;
    user-select: none !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.snipcart-checkout__section-header:active {
    background: #f0f0f0 !important;
}

.snipcart-checkout__section-content {
    padding: 16px !important;
}

/* ========================================
   LOADING STATES
   ======================================== */

.snipcart-checkout button:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
}

.snipcart-checkout .snipcart-button-primary:disabled {
    background: #cccccc !important;
}

/* Loading spinner */
.snipcart__actions--loading::after {
    content: '' !important;
    width: 20px !important;
    height: 20px !important;
    border: 2px solid #ffffff !important;
    border-top-color: transparent !important;
    border-radius: 50% !important;
    animation: snipcart-spin 0.6s linear infinite !important;
    margin-left: 12px !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

@keyframes snipcart-spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   PAYMENT METHOD ICONS
   ======================================== */

.snipcart-checkout .snipcart-payment-methods {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 12px !important;
    margin: 16px 0 !important;
}

.snipcart-checkout .snipcart-payment-method {
    flex: 1 1 120px !important;
    min-height: 60px !important;
    padding: 12px !important;
    border: 2px solid #e0e0e0 !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

.snipcart-checkout .snipcart-payment-method:active {
    transform: scale(0.98) !important;
}

.snipcart-checkout .snipcart-payment-method--selected {
    border-color: #009246 !important;
    background: rgba(0, 146, 70, 0.05) !important;
}

/* ========================================
   ERROR MESSAGES - VISIBLE & CLEAR
   ======================================== */

.snipcart-checkout .snipcart-form__field--error input,
.snipcart-checkout .snipcart-form__field--error select {
    border-color: #ce2b37 !important;
    background: rgba(206, 43, 55, 0.05) !important;
}

.snipcart-checkout .snipcart-form__error {
    color: #ce2b37 !important;
    font-size: 14px !important;
    margin-top: 8px !important;
    font-weight: 400 !important;
}

/* ========================================
   AUTOCOMPLETE STYLING
   ======================================== */

.snipcart-checkout input:-webkit-autofill,
.snipcart-checkout input:-webkit-autofill:hover,
.snipcart-checkout input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px white inset !important;
    -webkit-text-fill-color: #1a1a1a !important;
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Focus indicators */
.snipcart-checkout *:focus-visible {
    outline: 3px solid #009246 !important;
    outline-offset: 2px !important;
}

/* Skip to main content */
.snipcart-checkout__skip-to-content {
    position: absolute !important;
    top: -40px !important;
    left: 0 !important;
    background: #009246 !important;
    color: white !important;
    padding: 8px 16px !important;
    text-decoration: none !important;
    z-index: 100 !important;
}

.snipcart-checkout__skip-to-content:focus {
    top: 0 !important;
}

/* ========================================
   DARK MODE SUPPORT (OPTIONAL)
   ======================================== */

@media (prefers-color-scheme: dark) {
    .snipcart-modal__container {
        background: #1a1a1a !important;
        color: #e8e8e8 !important;
    }
    
    .snipcart-checkout input,
    .snipcart-checkout select,
    .snipcart-checkout textarea {
        background: #2a2a2a !important;
        color: #e8e8e8 !important;
        border-color: #3a3a3a !important;
    }
    
    .snipcart-checkout .snipcart-button-secondary {
        border-color: #e8e8e8 !important;
        color: #e8e8e8 !important;
    }
}

/* ========================================
   ANIMATION & TRANSITIONS
   ======================================== */

.snipcart-checkout * {
    transition: background-color 0.3s ease, 
                border-color 0.3s ease, 
                color 0.3s ease !important;
}

/* Smooth modal entrance */
.snipcart-modal {
    animation: slideUp 0.3s cubic-bezier(0.23, 1, 0.32, 1) !important;
}

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

/* ========================================
   PRINT STYLES (for receipts)
   ======================================== */

@media print {
    .snipcart-checkout__actions,
    .snipcart-modal__close,
    .snipcart-checkout button {
        display: none !important;
    }
    
    .snipcart-modal {
        max-width: 100% !important;
        box-shadow: none !important;
    }
}

/* ========================================
   FINAL TOUCHES
   ======================================== */

/* Remove default webkit styling */
.snipcart-checkout input,
.snipcart-checkout select,
.snipcart-checkout textarea,
.snipcart-checkout button {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Smooth scrolling in modal */
.snipcart-modal__container {
    scroll-behavior: smooth !important;
}

/* Better text rendering */
.snipcart-checkout {
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    text-rendering: optimizeLegibility !important;
}
