/**
 * Results Page - Figma Screen 5: Product Recommendations Carousel
 * Mobile-first design: 393px (iPhone 14 Pro)
 */

/* Reset & Base */
body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #FFFFFF;
    overflow-x: hidden;
}

/* Sticky Header (61px) */
.results-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 61px;
    background: rgba(255, 255, 255, 0.93);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #E0E5EB;
    box-shadow: 0px 4px 8px -4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.results-header .logo {
    text-decoration: none;
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    justify-content: space-between;
}

.back-button {
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    color: #011928;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-content {
    flex: 1;
}

.desktop-chat-button {
    display: none; /* Hidden on mobile */
    align-items: center;
    gap: 8px;
    background: #3E8EF4;
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.desktop-chat-button:hover {
    background: #2563EB;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(62, 142, 244, 0.3);
}

.desktop-chat-button svg {
    width: 20px;
    height: 20px;
}

.results-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #011928;
    margin: 0;
    line-height: 24px;
}

.results-header p {
    font-size: 13px;
    color: #6A7282;
    margin: 0;
    line-height: 18px;
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Horizontal Scroll Carousel */
.carousel-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 61px - 86px); /* Full height minus header and bottom nav */
    overflow-x: auto;
    overflow-y: auto; /* Changed: Now scrolls vertically together */
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
}

.carousel-track {
    display: flex;
    gap: 2px;
    min-height: 100%; /* Changed: Allow content to be taller than viewport */
    padding: 0 45px; /* Show 1.5 cards: (393 - 303) / 2 = 45px */
}

/* Product Card (303px × auto height) */
.product-card {
    flex-shrink: 0;
    width: 303px;
    min-height: 100%; /* Changed: Removed fixed height, removed overflow-y */
    background: #FFFFFF;
    scroll-snap-align: start;
    padding: 16px;
}

/* 1. Product Image (240px) */
.product-image-container {
    position: relative;
    height: 240px;
    border: 1px solid #E2E8F0;
    border-radius: 16px;
    box-shadow:
        0px 4px 8px 0px rgba(28, 25, 23, 0.03),
        0px 8px 16px 0px rgba(28, 25, 23, 0.02);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #F9FAFB;
    margin-bottom: 16px;
}

.product-image-container img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.favorite-button {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.favorite-button svg {
    width: 20px;
    height: 20px;
    stroke: #011928;
    fill: none;
}

/* 2. Product Title & Meta (68px) */
.product-meta {
    margin-bottom: 16px;
}

.product-name {
    font-size: 15px;
    font-weight: 600;
    color: #101828;
    line-height: 32px;
    margin: 0 0 4px 0;
}

.product-category {
    font-size: 15px;
    font-weight: 400;
    color: #011928;
    margin: 0 0 8px 0;
}

.product-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
}

.star-icon {
    color: #FFA500;
    font-size: 20px;
}

.rating-number {
    font-weight: 600;
    color: #101828;
}

.review-count {
    color: #6A7282;
}

/* 3. Tab Switcher (43px) */
.tab-container {
    background: #F0F2F5;
    border-radius: 8px;
    padding: 4px;
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.tab-button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 4px;
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    color: #19213D;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-button.active {
    background: white;
    border: 1px solid #F0F2F5;
    box-shadow: 0px 1px 3px rgba(25, 33, 61, 0.1);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 4. Purchase Options (50px) */
.purchase-section {
    border: 1.333px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    padding: 2px 7px 17px;
    margin-bottom: 16px;
}

.purchase-buttons {
    display: flex;
    gap: 10px;
}

.purchase-button {
    flex: 1;
    height: 46px;
    border-radius: 999px;
    border: 1.173px solid #DBEAFE;
    font-size: 11px;
    font-weight: 600;
    color: #090814;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.3;
    text-decoration: none;
}

.purchase-button-1 {
    background: #FDC700;
}

.purchase-button-2 {
    background: rgba(253, 199, 0, 0.52);
}

.purchase-button-3 {
    background: rgba(255, 201, 5, 0.25);
}

/* 5. Recommendation Section */
.recommendation-box {
    border: 1.333px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    padding: 11px 16px;
    margin-bottom: 16px;
}

.recommendation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.recommendation-title {
    font-size: 14px;
    font-weight: 600;
    color: #090814;
    margin: 0;
}

.average-score {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 50px;
    display: inline-block;
}

/* ≥85% — excellent match */
.average-score.score-high {
    color: #065F46;
    background: #D1FAE5;
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.3), 0 0 10px rgba(16, 185, 129, 0.25);
}

/* 70–84% — good match */
.average-score.score-mid {
    color: #1E40AF;
    background: #DBEAFE;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.3), 0 0 10px rgba(59, 130, 246, 0.25);
}

/* <70% — partial match */
.average-score.score-low {
    color: #92400E;
    background: #FEF3C7;
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.3), 0 0 10px rgba(245, 158, 11, 0.25);
}

.recommendation-text {
    font-size: 12px;
    font-weight: 400;
    color: #4A5565;
    line-height: 18px;
    margin-bottom: 16px;
}

.strengths-section,
.weaknesses-section {
    margin-bottom: 16px;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: #090814;
    margin: 0 0 8px 0;
}

.section-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.section-list li {
    font-size: 12px;
    font-weight: 400;
    color: #4A5565;
    line-height: 18px;
    margin-bottom: 4px;
}

/* 6. Reviews Header (30px) */
.reviews-header {
    border: 1.333px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    height: 30px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.reviews-header-text {
    font-size: 12px;
    font-weight: 600;
    color: #090814;
    margin: 0;
}

/* 7. Review Boxes (71px each) */
.review-box {
    border: 1.333px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    height: 71px;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.review-left {
    flex: 1;
}

.review-logo {
    height: 24px;
    margin-bottom: 6px;
}

.review-link {
    font-size: 10px;
    font-weight: 400;
    color: #4A5565;
    text-decoration: underline;
    display: block;
}

.review-rating {
    font-size: 12px;
    font-weight: 600;
    color: #090814;
}

/* 8. Reddit Box (59px) */
.reddit-box {
    border: 1.333px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    height: 59px;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.reddit-logo {
    width: 32px;
    height: 32px;
}

.reddit-text {
    font-size: 10px;
    font-weight: 400;
    color: #4A5565;
    text-decoration: underline;
    flex: 1;
}

/* 9. YouTube Box (50px) */
.youtube-box {
    border: 1.333px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    height: 50px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.youtube-logo {
    height: 28px;
}

.youtube-text {
    font-size: 10px;
    font-weight: 400;
    color: #4A5565;
    flex: 1;
}

/* 10. Amazon Ratings Box (138px) */
.amazon-box {
    border: 1.333px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    height: 138px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.amazon-rating-graphic {
    width: 165px;
    height: 80px;
    margin-bottom: 12px;
}

.amazon-link {
    font-size: 10px;
    font-weight: 400;
    color: #4A5565;
    text-decoration: underline;
}

/* Bottom Navigation (86px) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 86px;
    background: #FFFFFF;
    border-top: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding-bottom: 20px; /* Safe area for home indicator */
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: #6A7282;
    cursor: pointer;
    padding: 8px 16px;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

.nav-item span {
    font-size: 11px;
    font-weight: 500;
}

.nav-item.active {
    color: #3E8EF4;
}

.nav-item.active svg {
    fill: #3E8EF4;
    stroke: #3E8EF4;
}

/* Responsive - Tablet */
@media (min-width: 768px) {
    /* Show 2 cards side by side on tablet */
    .carousel-track {
        padding: 0 calc((100vw - 303px * 2 - 2px) / 2);
    }

    .product-card {
        width: 400px; /* Wider cards on tablet */
    }
}

/* Responsive - Desktop */
@media (min-width: 1024px) {
    /* Disable scroll snap on desktop for smoother experience */
    .carousel-container {
        scroll-snap-type: none;
        max-width: 1400px;
        margin: 0 auto;
        height: calc(100vh - 61px); /* No bottom nav on desktop */
    }

    .carousel-track {
        padding: 20px 40px;
        gap: 20px;
        justify-content: flex-start; /* Align to left, allow scrolling */
    }

    .product-card {
        width: 500px; /* Even wider on desktop */
        scroll-snap-align: none; /* Remove snap on desktop */
    }

    /* Hide bottom nav on desktop, add more vertical space */
    .bottom-nav {
        display: none;
    }

    /* Show desktop chat button */
    .desktop-chat-button {
        display: flex;
    }

    /* Center header content to match carousel on desktop */
    .results-header {
        padding: 0 40px;
    }

    .header-inner {
        max-width: 1400px;
        padding: 0 0;
    }
}

/* Responsive - Large Desktop */
@media (min-width: 1440px) {
    .carousel-container {
        max-width: 1600px;
    }

    .product-card {
        width: 650px; /* Maximum width for very large screens */
    }

    .carousel-track {
        gap: 40px;
        padding: 30px 60px;
    }

    /* If only 2 products, center them */
    .carousel-track:has(.product-card:nth-child(2):last-child) {
        justify-content: center;
    }

    /* Update header margins for larger max-width */
    .back-button {
        margin-left: max(60px, calc((100vw - 1600px) / 2 + 60px));
    }

    .desktop-chat-button {
        margin-right: max(60px, calc((100vw - 1600px) / 2 + 60px));
    }
}

/* Floating Chat Button (Mobile & Desktop) */
.floating-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-blue, #3B82F6);
    border: none;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: all 0.3s ease;
}

.floating-chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5);
}

.floating-chat-btn:active {
    transform: scale(0.95);
}

.floating-chat-btn svg {
    fill: white;
}

/* Desktop: Slightly larger and better positioned */
@media (min-width: 769px) {
    .floating-chat-btn {
        width: 64px;
        height: 64px;
        bottom: 32px;
        right: 32px;
    }
}

/* Chat Widget Panel */
#chatWidget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.chat-widget-panel {
    display: none;
    flex-direction: column;
    width: 340px;
    height: 440px;
    background: var(--white, #FFFFFF);
    border-radius: var(--radius-md, 16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.06);
    overflow: hidden;
    font-family: var(--font-primary, 'DM Sans', sans-serif);
}

.chat-widget-panel.open {
    display: flex;
}

.chat-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px var(--spacing-base, 16px);
    background: var(--primary-blue, #3B82F6);
    color: white;
    flex-shrink: 0;
}

.chat-widget-title {
    font-size: var(--font-size-sm, 0.9rem);
    font-weight: var(--font-weight-semibold, 600);
    font-family: var(--font-primary, 'DM Sans', sans-serif);
}

.chat-widget-actions {
    display: flex;
    gap: var(--spacing-sm, 8px);
    align-items: center;
}

.chat-widget-action-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    text-decoration: none;
    transition: opacity 0.2s;
}

.chat-widget-action-btn:hover {
    opacity: 1;
}

.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-base, 16px);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm, 8px);
    background: linear-gradient(135deg, var(--bg-gradient-start, #F8FAFC) 0%, var(--bg-gradient-end, #EFF6FF) 100%);
}

.chat-widget-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-widget-messages::-webkit-scrollbar-track {
    background: var(--light-gray, #F1F5F9);
    border-radius: 3px;
}

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: var(--gray, #94A3B8);
    border-radius: 3px;
}

.chat-widget-msg {
    max-width: 85%;
    padding: var(--spacing-sm, 8px) var(--spacing-base, 16px);
    border-radius: var(--radius-md, 16px);
    font-size: var(--font-size-sm, 0.9rem);
    line-height: var(--line-height-normal, 1.6);
    font-family: var(--font-primary, 'DM Sans', sans-serif);
    word-wrap: break-word;
    box-shadow: var(--shadow-card, 0 2px 12px rgba(0,0,0,0.06));
    animation: slideUp 0.3s ease-out;
}

.chat-widget-msg.assistant {
    background: var(--light-gray, #F1F5F9);
    color: var(--dark, #0F172A);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-widget-msg.user {
    background: var(--primary-blue, #3B82F6);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-widget-msg.loading {
    background: var(--light-gray, #F1F5F9);
    color: var(--gray, #94A3B8);
    align-self: flex-start;
    font-style: italic;
    box-shadow: none;
}

.chat-widget-input-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm, 8px);
    padding: var(--spacing-sm, 8px) var(--spacing-base, 16px);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    background: var(--white, #FFFFFF);
}

.chat-widget-input-row input {
    flex: 1;
    border: 2px solid var(--light-gray, #F1F5F9);
    border-radius: 24px;
    padding: var(--spacing-sm, 8px) var(--spacing-base, 16px);
    font-size: var(--font-size-sm, 0.9rem);
    font-family: var(--font-primary, 'DM Sans', sans-serif);
    outline: none;
    color: var(--dark, #0F172A);
    background: var(--light-gray, #F1F5F9);
    transition: border-color 0.2s, background 0.2s;
}

.chat-widget-input-row input:focus {
    border-color: var(--primary-blue, #3B82F6);
    background: var(--white, #FFFFFF);
}

.chat-widget-input-row button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-blue, #3B82F6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
    transition: background 0.2s, transform 0.1s;
}

.chat-widget-input-row button:hover {
    background: #2563EB;
    transform: scale(1.05);
}

.chat-widget-input-row button:active {
    transform: scale(0.95);
}

.chat-widget-input-row button:disabled {
    background: var(--light-gray, #F1F5F9);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.chat-widget-input-row button svg {
    fill: white;
}

.chat-widget-input-row button:disabled svg {
    fill: var(--gray, #94A3B8);
}

@media (min-width: 769px) {
    #chatWidget {
        bottom: 32px;
        right: 32px;
    }

    .chat-widget-panel {
        width: 380px;
        height: 500px;
    }
}

