/* BWS AI Product Finder - Frontend Styles */

/* ==========================================================================
   AI Search Widget
   ========================================================================== */

.bws-ai-search-widget {
    margin: 40px 0;
}

.bws-ai-search-header {
    margin-bottom: 30px;
}

.bws-ai-search-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0 0 15px 0;
    line-height: 1.2;
}

.bws-ai-search-subtitle {
    font-size: 1.1rem;
    margin: 0;
    opacity: 0.8;
}

.bws-ai-search-box {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    transition: all 0.3s ease;
}

.bws-ai-search-box:hover {
    border-color: #0073e6;
    box-shadow: 0 4px 12px rgba(0, 115, 230, 0.1);
}

.bws-search-form {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.bws-search-input {
    flex: 1;
    min-width: 300px;
    padding: 15px 20px;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.bws-search-input:focus {
    outline: none;
    border-color: #0073e6;
}

.bws-ai-search-button {
    padding: 15px 40px;
    background: #0073e6;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.bws-ai-search-button:hover {
    background: #005bb5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 115, 230, 0.3);
}

.bws-ai-search-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.bws-ai-search-button .button-loader {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* AI Understanding */
.bws-ai-understanding {
    background: #e8f4fd;
    border-left: 4px solid #0073e6;
    padding: 15px 20px;
    margin-bottom: 30px;
    border-radius: 8px;
}

.bws-ai-understanding p {
    margin: 0;
    color: #0066cc;
    font-size: 0.95rem;
}

.bws-ai-understanding strong {
    color: #004080;
}

/* Search Results */
.bws-ai-search-results {
    margin-top: 40px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* When categories exist, display as flex column to stack them */
.bws-ai-search-results:has(.bws-category-section) {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Grid display only when NO categories (fallback view) */
.bws-ai-search-results:not(:has(.bws-category-section)) {
    display: grid;
    gap: 20px;
}
/* Category Sections - stack vertically, full width */
.bws-category-section {
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
    position: relative;
    padding: 0 50px;
    box-sizing: border-box;
    overflow: hidden;
}

@media (max-width: 768px) {
    .bws-category-section {
        padding: 0 10px;
    }
}

.bws-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 3px solid #0073e6;
}

.bws-category-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #333333;
    margin: 0;
}

.bws-category-count {
    font-size: 0.95rem;
    color: #666666;
    background: #f0f0f0;
    padding: 6px 15px;
    border-radius: 20px;
}

.bws-category-section .swiper {
    padding-bottom: 10px;
    overflow: hidden;
    position: relative;
    width: 100%;
    max-width: 100%;
}

.bws-category-section .swiper-button-next,
.bws-category-section .swiper-button-prev {
    background: #ffffff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.bws-category-section .swiper-button-next:after,
.bws-category-section .swiper-button-prev:after {
    font-size: 20px;
    font-weight: 700;
    color: #333333;
}

.bws-category-section .swiper-button-next:hover,
.bws-category-section .swiper-button-prev:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

/* Grid columns for fallback view */
.bws-ai-search-results[data-columns="2"] {
    grid-template-columns: repeat(2, 1fr);
}

.bws-ai-search-results[data-columns="3"] {
    grid-template-columns: repeat(3, 1fr);
}

.bws-ai-search-results[data-columns="4"] {
    grid-template-columns: repeat(4, 1fr);
}

.bws-ai-search-results[data-columns="5"] {
    grid-template-columns: repeat(5, 1fr);
}

.bws-ai-search-results[data-columns="6"] {
    grid-template-columns: repeat(6, 1fr);
}

@media (max-width: 1200px) {
    .bws-ai-search-results[data-columns="5"],
    .bws-ai-search-results[data-columns="6"] {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 992px) {
    .bws-ai-search-results[data-columns="4"],
    .bws-ai-search-results[data-columns="5"],
    .bws-ai-search-results[data-columns="6"] {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .bws-ai-search-results[data-columns="3"],
    .bws-ai-search-results[data-columns="4"],
    .bws-ai-search-results[data-columns="5"],
    .bws-ai-search-results[data-columns="6"] {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .bws-search-form {
        flex-direction: column;
    }
    
    .bws-search-input {
        min-width: 100%;
    }
    
    .bws-ai-search-button {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .bws-ai-search-results {
        grid-template-columns: 1fr !important;
    }
    
    .bws-ai-search-title {
        font-size: 1.8rem;
    }
}

/* Product Cards */
.bws-product-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.bws-product-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
    border-color: #0073e6;
}

.bws-product-card .product-image {
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
    aspect-ratio: 1;
}

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

.bws-product-card:hover .product-image img {
    transform: scale(1.05);
}

/* Brand Badge - works for all brands */
.bws-product-card .brand-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: linear-gradient(135deg, #0073e6, #00a8ff);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 115, 230, 0.3);
}

.bws-offer-product-card .brand-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: linear-gradient(135deg, #0073e6, #00a8ff);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 115, 230, 0.3);
}

.bws-product-card .product-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.bws-product-card .product-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.bws-product-card .product-title a {
    color: #333333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.bws-product-card .product-title a:hover {
    color: #0073e6;
}

.bws-product-card .product-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: #0073e6;
    margin: 10px 0;
}

.bws-product-card .product-price del {
    opacity: 0.6;
    font-size: 0.9rem;
    margin-right: 8px;
}

.bws-product-card .product-price ins {
    text-decoration: none;
    color: #e74c3c;
}

.bws-product-card .product-description {
    font-size: 0.9rem;
    color: #666666;
    line-height: 1.6;
    margin: 10px 0;
    flex: 1;
}

.bws-product-card .product-button {
    display: inline-block;
    padding: 12px 24px;
    background: #0073e6;
    color: #ffffff;
    text-decoration: none;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: auto;
}

.bws-product-card .product-button:hover {
    background: #005bb5;
    transform: translateY(-2px);
}

/* Pagination */
.bws-ai-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.bws-ai-pagination button {
    padding: 10px 20px;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.bws-ai-pagination button:hover:not(:disabled) {
    border-color: #0073e6;
    color: #0073e6;
}

.bws-ai-pagination button.active {
    background: #0073e6;
    color: #ffffff;
    border-color: #0073e6;
}

.bws-ai-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.bws-ai-pagination .page-info {
    color: #666666;
    font-size: 0.95rem;
}

/* Loading State */
.bws-loading {
    text-align: center;
    padding: 60px 20px;
}

.bws-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top-color: #0073e6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.bws-loading-text {
    color: #666666;
    font-size: 1.1rem;
}

/* No Results */
.bws-no-results {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: 12px;
    margin-top: 30px;
}

.bws-no-results h3 {
    font-size: 1.5rem;
    color: #333333;
    margin: 0 0 10px 0;
}

.bws-no-results p {
    color: #666666;
    margin: 0;
}

/* Rate Limit Notice */
.bws-rate-limit-notice {
    background: #fff3cd;
    border: 2px solid #ffc107;
}

.bws-rate-limit-notice h3 {
    color: #856404;
}

.bws-rate-limit-notice p {
    color: #856404;
}

/* ==========================================================================
   Special Offers Widget
   ========================================================================== */

.bws-special-offers-widget {
    margin: 40px 0;
    position: relative;
}

.bws-special-offers-header {
    margin-bottom: 30px;
}

.bws-offers-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0 0 15px 0;
    line-height: 1.2;
}

.bws-offers-subtitle {
    font-size: 1.1rem;
    margin: 0;
    opacity: 0.8;
}

/* Carousel Container */
.swiper {
    width: 100%;
    padding-bottom: 50px;
}

.swiper-slide {
    height: auto;
}

/* Product Cards in Carousel */
.bws-offer-product-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.bws-offer-product-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
    border-color: #0073e6;
}

.bws-offer-product-card .product-image {
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
    aspect-ratio: 1;
}

.bws-offer-product-card .product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.bws-offer-product-card:hover .product-image img {
    transform: scale(1.05);
}

.bws-offer-product-card .sale-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #e74c3c;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    z-index: 1;
}

.bws-offer-product-card .product-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.bws-offer-product-card .product-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.bws-offer-product-card .product-title a {
    color: #333333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.bws-offer-product-card .product-title a:hover {
    color: #0073e6;
}

.bws-offer-product-card .product-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: #0073e6;
    margin: 10px 0;
}

.bws-offer-product-card .product-price del {
    opacity: 0.6;
    font-size: 0.9rem;
    margin-right: 8px;
}

.bws-offer-product-card .product-price ins {
    text-decoration: none;
    color: #e74c3c;
}

.bws-offer-product-card .product-description {
    font-size: 0.9rem;
    color: #666666;
    line-height: 1.6;
    margin: 10px 0;
    flex: 1;
}

.bws-offer-product-card .product-button {
    display: inline-block;
    padding: 12px 24px;
    background: #0073e6;
    color: #ffffff;
    text-decoration: none;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: auto;
}

.bws-offer-product-card .product-button:hover {
    background: #005bb5;
    transform: translateY(-2px);
}

/* Swiper Navigation */
.swiper-button-next,
.swiper-button-prev {
    background: #ffffff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.swiper-button-next:after,
.swiper-button-prev:after {
    font-size: 20px;
    font-weight: 700;
}

.swiper-button-next:hover,
.swiper-button-prev:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

/* Swiper Pagination */
.swiper-pagination-bullet {
    width: 12px;
    height: 12px;
    background: #cccccc;
    opacity: 1;
    transition: all 0.3s ease;
}

.swiper-pagination-bullet-active {
    background: #0073e6;
    width: 30px;
    border-radius: 6px;
}

/* Responsive */
@media (max-width: 768px) {
    .bws-offers-title {
        font-size: 1.8rem;
    }
    
    .swiper-button-next,
    .swiper-button-prev {
        display: none;
    }
}

/* Fix for giant products before Swiper loads */
.bws-category-section .swiper-slide {
    width: auto !important;
    max-width: 300px;
    flex-shrink: 0;
}

/* Grid fallback when Swiper fails */
.swiper-fallback-grid .swiper-slide {
    width: 100% !important;
    max-width: none;
}

.swiper-fallback-grid .swiper-wrapper {
    display: grid !important;
}

/* Product Brand */
.product-brand {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #0073e6;
    margin-bottom: 5px;
    letter-spacing: 0.5px;
}

/* Product Rating */
.product-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 8px 0;
}

.product-rating .stars {
    display: flex;
    gap: 2px;
}

.product-rating .star {
    font-size: 16px;
    line-height: 1;
}

.product-rating .star.full {
    color: #FFB800;
}

.product-rating .star.half {
    color: #FFB800;
    opacity: 0.6;
}

.product-rating .star.empty {
    color: #ddd;
}

.product-rating .rating-count {
    font-size: 0.8rem;
    color: #666;
}

/* Fix carousel overflow - prevent items disappearing off screen */
.bws-category-section .swiper {
    overflow: visible !important;
}

.bws-category-section .swiper-wrapper {
    display: flex !important;
}

/* Ensure slides are visible and don't disappear */
.bws-category-section .swiper-slide {
    flex-shrink: 0;
    width: 100%;
    max-width: 280px;
    margin-right: 15px;
}

/* Additional carousel fixes */
.bws-category-section .swiper-button-next {
    right: 0;
}

.bws-category-section .swiper-button-prev {
    left: 0;
}

/* Ensure slides are properly sized */
.bws-category-section .swiper-slide {
    box-sizing: border-box;
}

/* Make sure product cards fit properly in slides */
.bws-category-section .bws-product-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Brand Logo */
.product-brand-logo {
    margin-bottom: 8px;
    height: 30px;
    display: flex;
    align-items: center;
}

.product-brand-logo img {
    max-height: 30px;
    max-width: 100px;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Improve mobile carousel snapping */
@media (max-width: 767px) {
    .bws-category-section .swiper-wrapper {
        scroll-snap-type: x mandatory;
    }
    
    .bws-category-section .swiper-slide {
        scroll-snap-align: start;
        scroll-snap-stop: always;
    }
}

/* Better touch handling for carousel */
.bws-category-section .swiper {
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

/* CRITICAL: Prevent categories from going off screen */
body .bws-ai-search-results {
    overflow-x: hidden !important;
    max-width: 100% !important;
}

body .bws-category-section {
    overflow-x: hidden !important;
    max-width: 100% !important;
}

/* Ensure swiper wrapper doesn't overflow */
.bws-category-section .swiper-wrapper {
    max-width: 100%;
}
