/**
 * STW AOV Boost - Frontend Styles
 *
 * Mobile-first responsive design with horizontal scrolling product rows.
 * Leverages Bootstrap utilities where available.
 */

/* Main container */
#stw-aov-boost-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header */
.stw-aov-header {
    margin-bottom: 2rem;
}

.stw-aov-title {
    font-weight: 700;
    color: #333;
}

.stw-aov-subtitle {
    color: #666;
}

/* Section styling */
.stw-aov-section {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.stw-aov-section:last-child {
    border-bottom: none;
}

.stw-aov-section-header {
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.stw-aov-section-title {
    font-weight: 600;
    margin: 0;
}

.stw-aov-section-discount {
    font-size: 0.875rem;
    padding: 0.25rem 0.75rem;
}

/* Horizontal scroll container */
.stw-aov-section-products {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 1rem;
    padding-bottom: 1rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.stw-aov-section-products::-webkit-scrollbar {
    height: 6px;
}

.stw-aov-section-products::-webkit-scrollbar-track {
    background: transparent;
}

.stw-aov-section-products::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 3px;
}

/* Product card */
.stw-aov-product-card {
    flex: 0 0 auto;
    width: 160px;
    scroll-snap-align: start;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.stw-aov-product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Tablet and up */
@media (min-width: 768px) {
    .stw-aov-product-card {
        width: 200px;
    }
}

/* Desktop */
@media (min-width: 992px) {
    .stw-aov-product-card {
        width: 220px;
    }
}

/* Product image */
.stw-aov-product-image-wrapper {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f8f8f8;
}

.stw-aov-product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.stw-aov-product-card:hover .stw-aov-product-image {
    transform: scale(1.05);
}

.stw-aov-product-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    z-index: 1;
}

/* Product info */
.stw-aov-product-info {
    padding: 0.75rem;
}

.stw-aov-product-title {
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
}

.stw-aov-product-title a {
    color: #333;
    text-decoration: none;
}

.stw-aov-product-title a:hover {
    color: #000;
}

/* Pricing */
.stw-aov-product-price {
    font-size: 0.9375rem;
    margin-bottom: 0.5rem;
}

.stw-aov-price-original {
    color: #999;
    font-size: 0.8125rem;
    margin-right: 0.25rem;
}

.stw-aov-price-discounted {
    color: #dc3545;
    font-weight: 700;
    text-decoration: none;
}

.stw-aov-price-regular {
    font-weight: 600;
    color: #333;
}

/* Product action */
.stw-aov-product-action {
    padding: 0 0.75rem 0.75rem;
}

.stw-aov-add-btn {
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
    transition: all 0.2s ease;
}

.stw-aov-add-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.stw-aov-add-btn.added {
    background-color: #28a745;
    border-color: #28a745;
}

/* Quantity selector */
.stw-aov-qty-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

/* The control inside is WooCommerce's own .quantity / input.qty markup, styled entirely by the theme. */

.stw-aov-qty-wrapper.updating {
    opacity: 0.6;
    pointer-events: none;
}

.stw-aov-added-label {
    text-align: center;
    font-size: 0.75rem;
    color: #28a745;
    font-weight: 600;
    margin-top: 0.375rem;
}

.stw-aov-product-card.in-cart,
.stw-aov-surface-card.in-cart {
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

/* Action buttons - sticky footer */
.stw-aov-actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: #fff;
    padding: 1rem;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    border-top: 1px solid #dee2e6;
}

.stw-aov-actions-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* Add bottom padding to page to prevent content being hidden */
#stw-aov-boost-page {
    padding-bottom: 100px;
}

.stw-aov-skip-link {
    color: #666;
    text-decoration: underline;
    font-size: 0.9375rem;
    transition: color 0.2s ease;
}

.stw-aov-skip-link:hover {
    color: #333;
}

.stw-aov-continue-btn {
    font-size: 1.125rem;
    padding: 1rem 2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.stw-aov-arrow {
    transition: transform 0.2s ease;
}

.stw-aov-continue-btn:hover .stw-aov-arrow {
    transform: translateX(4px);
}

/* Empty cart */
.stw-aov-empty-cart {
    padding: 3rem 1rem;
}

/* Cart item discount styles (for cart page) */
.stw-aov-boost-item {
    background-color: rgba(220, 53, 69, 0.05);
}

.stw-aov-original-price {
    color: #999;
    font-size: 0.875em;
    margin-right: 0.25rem;
}

.stw-aov-discounted-price {
    color: #dc3545;
    font-weight: 600;
    text-decoration: none;
}

.stw-aov-discount-badge {
    display: inline-block;
    background-color: #dc3545;
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* EP (EatProtein) specific overrides */
body.ep #stw-aov-boost-page .stw-aov-product-badge,
body.ep #stw-aov-boost-page .stw-aov-section-discount,
body.ep .stw-aov-discount-badge {
    background-color: #7a488e;
}

body.ep #stw-aov-boost-page .stw-aov-price-discounted,
body.ep .stw-aov-discounted-price {
    color: #7a488e;
}

body.ep #stw-aov-boost-page .stw-aov-add-btn.added {
    background-color: #7a488e;
    border-color: #7a488e;
}

body.ep #stw-aov-boost-page .stw-aov-continue-btn {
    background-color: #7a488e;
    border-color: #7a488e;
}

body.ep #stw-aov-boost-page .stw-aov-continue-btn:hover {
    background-color: #643a74;
    border-color: #643a74;
}

body.ep #stw-aov-boost-page .stw-aov-added-label {
    color: #7a488e;
}

body.ep #stw-aov-boost-page .stw-aov-product-card.in-cart {
    border-color: #7a488e;
    box-shadow: 0 0 0 2px rgba(122, 72, 142, 0.2);
}

/* Surface card (compact single-product upsell, e.g. product page) */

/* Themes that lay the product summary out as a flex column with explicit
   order values (stw2026: form.cart is 100) would otherwise sort the card
   first. No effect where the summary is not a flex container. */
.stw-aov-surface-pdp {
    order: 101;
}

.stw-aov-surface-image {
    width: 64px;
    height: 64px;
    object-fit: cover;
}

.stw-aov-surface-body {
    min-width: 0;
}

.stw-aov-surface-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stw-aov-surface-card .stw-aov-product-action {
    padding: 0;
}

.stw-aov-surface-card .stw-aov-added-label {
    margin-top: 0.25rem;
}

body.ep .stw-aov-surface-card .stw-aov-price-discounted,
body.ep .stw-aov-surface-card .stw-aov-added-label {
    color: #7a488e;
}

body.ep .stw-aov-surface-card .stw-aov-add-btn.added {
    background-color: #7a488e;
    border-color: #7a488e;
}

body.ep .stw-aov-surface-card.in-cart {
    border-color: #7a488e;
    box-shadow: 0 0 0 2px rgba(122, 72, 142, 0.2);
}

/* Loading state */
.stw-aov-loading {
    position: relative;
    pointer-events: none;
}

.stw-aov-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: stw-aov-spin 0.8s linear infinite;
}

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

/* Responsive adjustments */
@media (max-width: 575.98px) {
    #stw-aov-boost-page {
        padding: 0.75rem;
        padding-bottom: 140px;
    }

    .stw-aov-actions-inner {
        flex-direction: column;
        gap: 0.75rem;
    }

    .stw-aov-continue-wrapper {
        width: 100%;
    }

    .stw-aov-continue-btn {
        width: 100%;
    }

    .stw-aov-title {
        font-size: 1.5rem;
    }

    .stw-aov-subtitle {
        font-size: 1rem;
    }

    .stw-aov-product-card {
        width: 140px;
    }

    .stw-aov-product-info {
        padding: 0.5rem;
    }

    .stw-aov-product-title {
        font-size: 0.8125rem;
    }

    .stw-aov-product-price {
        font-size: 0.875rem;
    }

    .stw-aov-product-action {
        padding: 0 0.5rem 0.5rem;
    }

    .stw-aov-add-btn {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }

    .stw-aov-continue-btn {
        font-size: 1rem;
        padding: 0.875rem 1.5rem;
    }
}
