/**
 * Product Banner Styles
 * Displays WooCommerce products in responsive layouts:
 * - Desktop (1200px+): Vertical sidebar on right
 * - Tablet (769-1199px): Horizontal row at bottom
 * - Mobile (768px-): Horizontal carousel at bottom
 */

/* ========================================
   Base Styles
   ======================================== */

.product-banner {
    --banner-bg: #f8f9fa;
    --banner-border: #e9ecef;
    --banner-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --product-bg: #ffffff;
    --product-border: #dee2e6;
    --price-color: #28a745;
    --sale-color: #dc3545;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    /* Hidden by default - JS will show when ready */
    display: none;
    /* Default: part of content flow */
    position: relative;
    background: var(--banner-bg);
    padding: 20px;
    margin: 20px auto;
    max-width: 900px;
    border-radius: 12px;
    box-shadow: var(--banner-shadow);
}

.product-banner-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--banner-border);
}

.product-banner-header a {
    color: var(--text-secondary);
    text-decoration: none;
}

.product-banner-header a:hover {
    color: var(--text-primary);
}

/* ========================================
   Product Card Styles
   ======================================== */

.product-card {
    background: var(--product-bg);
    border: 1px solid var(--product-border);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
    display: block;
    color: inherit;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--banner-shadow);
    text-decoration: none;
    color: inherit;
}

.product-card-image {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    background: #f0f0f0;
}

.product-card-body {
    padding: 10px;
}

.product-card-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 6px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--price-color);
}

.product-card-price .regular-price {
    text-decoration: line-through;
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 12px;
    margin-right: 6px;
}

.product-card-price .sale-badge {
    background: var(--sale-color);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    font-weight: 500;
}

/* ========================================
   Desktop: Vertical Sidebar (1200px+)
   ======================================== */

@media (min-width: 1200px) {
    .product-banner {
        position: fixed;
        top: 120px;
        right: 20px;
        width: 200px;
        max-height: calc(100vh - 140px);
        overflow-y: auto;
        background: var(--banner-bg);
        border-radius: 12px;
        padding: 15px;
        padding-top: 35px; /* Space for fold button */
        box-shadow: var(--banner-shadow);
        z-index: 100;
    }

    .product-banner .product-banner-close {
        position: absolute;
        top: 8px;
        right: 8px;
    }

    .product-banner::-webkit-scrollbar {
        width: 4px;
    }

    .product-banner::-webkit-scrollbar-track {
        background: transparent;
    }

    .product-banner::-webkit-scrollbar-thumb {
        background: var(--banner-border);
        border-radius: 2px;
    }

    .product-banner-container {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .product-card {
        width: 100%;
    }

    .product-card-image {
        aspect-ratio: 16/10;
    }

    /* Hide carousel controls on desktop */
    .carousel-controls {
        display: none;
    }

    /* Folded state on desktop - moves to content flow like tablet */
    .product-banner.product-banner-folded {
        position: relative;
        top: auto;
        right: auto;
        width: auto;
        max-width: 900px;
        max-height: none;
        overflow-y: visible;
        margin: 20px auto;
        padding: 20px;
    }

    .product-banner.product-banner-folded .product-banner-close {
        display: none;
    }

    .product-banner.product-banner-folded .product-banner-header {
        text-align: center;
        margin-bottom: 15px;
    }

    .product-banner.product-banner-folded .product-banner-container {
        flex-direction: row;
        justify-content: center;
        gap: 15px;
    }

    .product-banner.product-banner-folded .product-card {
        flex: 0 0 calc(33.333% - 10px);
        max-width: 250px;
        width: auto;
    }

    .product-banner.product-banner-folded .product-card-image {
        aspect-ratio: 4/3;
    }
}

/* ========================================
   Tablet: Horizontal Row (769-1199px)
   ======================================== */

@media (min-width: 769px) and (max-width: 1199px) {
    .product-banner {
        position: relative;
        background: var(--banner-bg);
        padding: 20px;
        margin: 20px auto;
        max-width: 900px;
        border-radius: 12px;
        box-shadow: var(--banner-shadow);
    }

    .product-banner-header {
        display: block;
        margin-bottom: 15px;
        text-align: center;
    }

    .product-banner-container {
        display: flex;
        flex-direction: row;
        gap: 15px;
        justify-content: center;
        flex-wrap: wrap;
    }

    .product-card {
        flex: 0 0 calc(33.333% - 10px);
        max-width: 250px;
    }

    .product-card-image {
        aspect-ratio: 4/3;
    }

    .product-card-body {
        padding: 10px;
    }

    .product-card-title {
        font-size: 13px;
        -webkit-line-clamp: 2;
    }

    .product-card-price {
        font-size: 14px;
    }

    /* Hide carousel controls on tablet */
    .carousel-controls {
        display: none;
    }
}

/* ========================================
   Mobile: Horizontal Carousel (768px-)
   ======================================== */

@media (max-width: 768px) {
    .product-banner {
        position: relative;
        background: var(--banner-bg);
        padding: 15px;
        margin: 20px 10px;
        border-radius: 12px;
        box-shadow: var(--banner-shadow);
    }

    .product-banner-header {
        font-size: 12px;
        margin-bottom: 12px;
        text-align: center;
    }

    .product-banner-container {
        display: flex;
        flex-direction: row;
        gap: 10px;
        justify-content: center;
    }

    .product-card {
        flex: 1 1 0;
        max-width: 200px;
        min-width: 100px;
    }

    .product-card-image {
        aspect-ratio: 1;
    }

    .product-card-body {
        padding: 8px;
    }

    .product-card-title {
        font-size: 11px;
        -webkit-line-clamp: 2;
    }

    .product-card-price {
        font-size: 12px;
    }

    .product-card-price .regular-price {
        display: none;
    }

    .product-card-price .sale-badge {
        font-size: 9px;
        padding: 1px 4px;
    }

    /* Hide carousel controls on wider mobile */
    .carousel-controls {
        display: none;
    }
}

/* ========================================
   Narrow Mobile: Carousel (480px-)
   ======================================== */

@media (max-width: 480px) {
    .product-banner-container {
        display: flex;
        flex-direction: row;
        gap: 10px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        justify-content: flex-start;
        padding-bottom: 5px;
    }

    .product-banner-container::-webkit-scrollbar {
        display: none;
    }

    .product-card {
        flex: 0 0 140px;
        min-width: 140px;
        max-width: 140px;
        scroll-snap-align: start;
    }

    /* Show carousel dots on narrow screens */
    .carousel-controls {
        display: flex;
        justify-content: center;
        gap: 6px;
        margin-top: 8px;
    }

    .carousel-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--banner-border);
        border: none;
        padding: 0;
        cursor: pointer;
        transition: background 0.2s ease;
    }

    .carousel-dot.active {
        background: var(--text-secondary);
    }
}

/* ========================================
   Loading & Error States
   ======================================== */

.product-banner-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 13px;
}

.product-banner-loading .spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--banner-border);
    border-top-color: var(--text-secondary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 10px;
}

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

.product-banner-error {
    text-align: center;
    padding: 15px;
    color: var(--text-secondary);
    font-size: 12px;
}

.product-banner-empty {
    display: none;
}

/* ========================================
   Fold Button (Desktop only)
   ======================================== */

.product-banner-close {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.product-banner-close:hover {
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
}

/* Hide on mobile/tablet - no fold button needed */
@media (max-width: 1199px) {
    .product-banner-close {
        display: none;
    }
}
