/**
 * AI Landing Page - Base Styles
 * Common styles shared across all templates
 */

/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Initially show desktop, hide mobile - JavaScript will adjust */
.ai-landing-page-desktop {
    display: block;
}

.ai-landing-page-mobile {
    display: none;
}

/* When JavaScript detects mobile */
body.is-mobile .ai-landing-page-desktop {
    display: none !important;
}

body.is-mobile .ai-landing-page-mobile {
    display: block !important;
}

/* Common utility classes */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mt-5 { margin-top: 3rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mb-5 { margin-bottom: 3rem; }

/* RTL Support for Arabic */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .container {
    text-align: right;
}

/* Common form elements */
.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Common button styles */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Prevent flash of unstyled content */
.ai-landing-page {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

.ai-landing-page.loaded {
    opacity: 1;
}

/* ═══════════════════════════════════════
   Amazon-style Image Gallery (matches offer landing page)
═══════════════════════════════════════ */
.al-gallery-wrapper {
    display: flex;
    gap: 12px;
    position: relative;
}

/* Vertical thumbnail strip */
.al-thumbnail-strip {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 60px;
    flex-shrink: 0;
    max-height: 480px;
    overflow-y: auto;
    scrollbar-width: none;
}
.al-thumbnail-strip::-webkit-scrollbar { display: none; }

.thumbnail-item {
    width: 60px;
    height: 60px;
    border: 2px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}
.thumbnail-item:hover,
.thumbnail-item.active {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102,126,234,0.4);
}
.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Main image container */
.al-main-image-container {
    flex: 1;
    position: relative;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
}
.al-main-product-image {
    max-width: 100%;
    max-height: 460px;
    object-fit: contain;
    cursor: zoom-in;
    border-radius: 4px;
}

/* Up/down navigation arrows */
.image-nav-btn {
    position: absolute;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.92);
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s, box-shadow 0.2s;
    font-size: 1.2rem;
}
.image-nav-btn:hover { background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.18); }
.image-nav-btn.prev-btn { top: 10px; }
.image-nav-btn.next-btn { bottom: 10px; }

/* Image counter badge */
.mobile-image-counter {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    pointer-events: none;
}

/* Mobile horizontal thumbnail row */
.al-mobile-thumbs {
    display: none; /* shown only on mobile via media query */
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.al-mobile-thumbs::-webkit-scrollbar { display: none; }
.al-mobile-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.2s;
}
.al-mobile-thumb.active { border-color: #667eea; }

@media (max-width: 600px) {
    .al-gallery-wrapper { flex-direction: column; gap: 8px; }
    .al-thumbnail-strip { display: none; } /* hide vertical strip on mobile */
    .al-mobile-thumbs { display: flex; } /* show horizontal strip on mobile */
    .al-main-image-container { min-height: 200px; padding: 10px; }
    .al-main-product-image { max-height: 300px; }
    .image-nav-btn { display: none; } /* use swipe on mobile */
}

/* ═══════════════════════════════════════
   Payment Method Items
═══════════════════════════════════════ */
.payment-method-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.payment-method-item:hover { border-color: #667eea; background: #f8f8ff; }
.payment-method-item input[type="radio"] {
    margin-top: 3px;
    accent-color: #667eea;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
}
.payment-method-item label {
    flex: 1;
    cursor: pointer;
    margin: 0;
}
.payment-method-item label strong { display: block; font-size: 0.95rem; color: #333; }
.payment-method-description { font-size: 0.82rem; color: #777; margin-top: 2px; }

/* Highlight selected payment method */
.payment-method-item input[type="radio"]:checked ~ label,
.payment-method-item:has(input:checked) {
    color: #667eea;
}
.payment-method-item:has(input:checked) {
    border-color: #667eea;
    background: #f0f4ff;
}

/* Product Variant Selection Styles */
.al-variants-section {
    margin-bottom: 20px;
}

.al-variant-group {
    margin-bottom: 16px;
}

.al-variant-attr-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #444;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.al-variant-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.al-variant-option {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.al-variant-radio {
    display: none;
}

.al-variant-label {
    display: inline-block;
    padding: 8px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #555;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.al-variant-label:hover {
    border-color: #667eea;
    color: #667eea;
    background: #f8f9ff;
}

.al-variant-option.selected .al-variant-label {
    border-color: #667eea;
    background: #667eea;
    color: #fff;
}

.al-variant-error {
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: 8px;
    padding: 8px 12px;
    background: #fdf2f2;
    border-radius: 4px;
    border-left: 3px solid #e74c3c;
}

/* RTL variant styles */
[dir="rtl"] .al-variant-attr-name {
    text-align: right;
}

[dir="rtl"] .al-variant-error {
    border-left: none;
    border-right: 3px solid #e74c3c;
}

/* Shipping Methods Styles */
.shipping-methods-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.shipping-method-option {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.shipping-method-option:hover {
    border-color: #667eea;
    background-color: #f8f9ff;
}

.shipping-method-option input[type="radio"] {
    display: none;
}

.shipping-method-option input[type="radio"]:checked + .shipping-method-label {
    border-color: #667eea;
    background-color: #f0f4ff;
}

.shipping-method-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.shipping-method-info {
    flex: 1;
}

.shipping-method-name {
    font-weight: 600;
    font-size: 1rem;
    color: #333;
    margin-bottom: 4px;
}

.shipping-method-courier {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 4px;
}

.shipping-center-name {
    font-size: 0.85rem;
    color: #888;
    margin-top: 4px;
}

.shipping-method-price {
    font-weight: 700;
    font-size: 1.1rem;
    color: #667eea;
    white-space: nowrap;
    margin-left: 16px;
}

.no-shipping-methods {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
    background: #f8f9fa;
    border-radius: 8px;
}

.shipping-method-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 6px;
    margin-right: 12px;
    flex-shrink: 0;
}

/* Price Summary Styles */
.price-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    border: 1px solid #e0e0e0;
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
}

.price-row:last-child {
    border-bottom: none;
}

.price-row.price-total {
    font-weight: 700;
    font-size: 1.2rem;
    color: #333;
    border-top: 2px solid #667eea;
    margin-top: 8px;
    padding-top: 12px;
}

.price-label {
    color: #666;
}

.price-value {
    font-weight: 600;
    color: #333;
}

.price-row.price-total .price-value {
    color: #667eea;
}

/* RTL Support for Shipping */
[dir="rtl"] .shipping-method-label {
    flex-direction: row-reverse;
}

[dir="rtl"] .shipping-method-price {
    margin-left: 0;
    margin-right: 16px;
}

[dir="rtl"] .price-row {
    flex-direction: row-reverse;
}

/* ═══════════════════════════════════════
   Product Image Carousel
═══════════════════════════════════════ */
.al-carousel-wrapper {
    position: relative;
}

.al-carousel-main-container {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: #f8f9fa;
    cursor: zoom-in;
}

.al-carousel-main-image {
    width: 100%;
    max-height: 480px;
    object-fit: contain;
    display: block;
    border-radius: 12px;
    transition: opacity 0.2s ease;
}

.al-carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 2;
}
.al-carousel-nav:hover { background: rgba(0,0,0,0.75); }
.al-carousel-prev { left: 8px; }
.al-carousel-next { right: 8px; }

.al-carousel-counter {
    position: absolute;
    bottom: 10px;
    right: 12px;
    background: rgba(0,0,0,0.5);
    color: white;
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 12px;
}

/* Thumbnail Strip */
.al-carousel-thumbnails {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    overflow-x: auto;
    padding: 4px 0 8px;
    scrollbar-width: thin;
}

.al-thumb {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    transition: border-color 0.2s;
}
.al-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.al-thumb.active { border-color: #667eea; }
.al-thumb:hover { border-color: #667eea; }

/* Attribute Filter Buttons */
.al-carousel-attr-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.al-attr-btn {
    padding: 5px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    background: white;
    color: #555;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.al-attr-btn:hover { border-color: #667eea; color: #667eea; }
.al-attr-btn.active { border-color: #667eea; background: #667eea; color: white; }

/* ═══════════════════════════════════════
   Page Transition Overlay (order confirmation)
═══════════════════════════════════════ */
#al-page-transition {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.97);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;
    gap: 16px;
}

.al-transition-spinner {
    width: 52px;
    height: 52px;
    border: 5px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: al-spin 0.8s linear infinite;
}
@keyframes al-spin { to { transform: rotate(360deg); } }

.al-transition-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}
.al-transition-sub {
    color: #888;
    font-size: 0.95rem;
}

/* ═══════════════════════════════════════
   Full-Screen Video Overlay (TikTok-style scroll-snap feed)
═══════════════════════════════════════ */
.al-video-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9998;
    flex-direction: column;
    /* display toggled by JS (none / flex) */
}

/* Scrollable feed — each slide snaps into view */
.al-video-feed {
    position: absolute;
    inset: 0;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
}

/* One full-screen slide per video */
.al-video-slide {
    position: relative;
    width: 100%;
    height: 100vh;
    scroll-snap-align: start;
    flex-shrink: 0;
    background: #000;
}

/* Video fills the slide, object-fit contain */
.al-video-player {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Top bar: price + mute + close — floats above the feed */
.al-video-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
    pointer-events: none; /* let touches pass through to the feed */
}

/* Re-enable pointer events on interactive elements inside top bar */
.al-video-top-bar .al-video-price-badge,
.al-video-top-bar .al-video-top-right,
.al-video-top-bar button {
    pointer-events: auto;
}

.al-video-price-badge {
    background: rgba(102,126,234,0.9);
    color: #fff;
    font-size: 1.2rem;
    font-weight: 800;
    padding: 6px 18px;
    border-radius: 50px;
    letter-spacing: 0.5px;
}

.al-video-top-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.al-video-icon-btn {
    background: rgba(0,0,0,0.5);
    border: none;
    color: #fff;
    font-size: 1.3rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.al-video-icon-btn:hover { background: rgba(0,0,0,0.8); }

.al-video-close-btn { font-size: 1.5rem; }

/* Bottom overlay: product info + CTA button (inside each slide) */
.al-video-bottom-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9;
    padding: 24px 20px 32px;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.al-video-product-info {
    flex: 1;
    min-width: 0;
}

.al-video-product-name {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.al-video-seller-name {
    color: rgba(255,255,255,0.75);
    font-size: 0.95rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

.al-video-order-btn {
    display: inline-block;
    padding: 14px 32px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 800;
    border-radius: 50px;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(102,126,234,0.5);
    transition: transform 0.2s, box-shadow 0.2s;
}
.al-video-order-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(102,126,234,0.7);
    color: #fff;
    text-decoration: none;
}

/* Responsive: on narrow screens stack vertically */
@media (max-width: 480px) {
    .al-video-bottom-overlay {
        flex-direction: column;
        align-items: stretch;
    }
    .al-video-order-btn {
        text-align: center;
        padding: 16px;
        font-size: 1.2rem;
    }
    .al-video-price-badge { font-size: 1rem; }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    a {
        text-decoration: underline;
    }
}
