/* =============================================================================
   GUIDED SELLING POPUP ENHANCEMENTS
   ============================================================================= */

/* CSS VARIABLES */
:root {
    --gs-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --gs-green: #124734;
    --gs-green-hover: #0d2f22;
}

/* =============================================================================
   TYPING INDICATOR
   ============================================================================= */

.gs-typing-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 0;
}

.gs-typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--gs-green);
    border-radius: 50%;
    animation: gs-typing-bounce 1.4s infinite ease-in-out;
}

.gs-typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.gs-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.gs-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes gs-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* =============================================================================
   DESKTOP STYLES (DEFAULT)
   ============================================================================= */

/* Wrapper container for popup + carousel */
.gs-popup-wrapper {
    position: fixed;
    z-index: 9998;
    pointer-events: auto;
    width: 500px;
    max-width: calc(100vw - 40px);
    bottom: 70px;
    right: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column-reverse;
    gap: 16px;
}

/* Standalone carousel mode (no popup box) */
.gs-carousel-floating.gs-standalone {
    position: relative;
    z-index: 2;
    background: transparent;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 1 !important;
    transform: translateY(0) !important;
    visibility: visible !important;
    pointer-events: auto;
    justify-content: flex-end;
    align-self: flex-end;
}

/* Guided Selling Popup Container */
.guided-selling-popup {
    position: relative;
    z-index: 1;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    cursor: pointer;
    font-family: var(--gs-font-family);
}

.guided-selling-popup.gs-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Dynamic close button - floats above popup or carousel */
.gs-dynamic-close-button {
    position: absolute;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gs-green);
    color: white;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(18, 71, 52, 0.4);
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    top: -10px;
    right: -10px;
}

.gs-dynamic-close-button.gs-visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.gs-dynamic-close-button:hover {
    background: var(--gs-green-hover);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(18, 71, 52, 0.6);
}

/* Popup Content Layout */
.gs-content {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

/* Avatar in Popup */
.gs-avatar {
    flex-shrink: 0;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50%;
    object-fit: cover;
}

/* Message Content Area */
.gs-message-content {
    flex: 1;
    min-width: 0;
    position: relative;
}

/* Text and Buttons - Smooth Crossfade */
.gs-text {
    font-size: 16px;
    line-height: 1.5;
    color: #333;
    margin-bottom: 12px;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.gs-text.gs-loading {
    opacity: 0.6;
    background-color: transparent;
}

.gs-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Popup button styling - controlled via CSS class instead of inline styles */
.gs-popup-button {
    background-color: #124734 !important;
    color: #ffffff !important;
    padding: 12px 16px !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    cursor: pointer !important;
    transition: all 0.4s ease !important;
    white-space: normal !important;
    line-height: 1.3 !important;
    min-width: 0 !important;
    text-align: center !important;
    box-shadow: 0 2px 8px rgba(18, 71, 52, 0.2) !important;
}

.gs-popup-button:hover {
    background-color: #0d2f22 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(18, 71, 52, 0.3) !important;
}

/* =============================================================================
   CAROUSEL FLOATING OVERLAY - DESKTOP
   ============================================================================= */

.gs-carousel-floating {
    position: relative;
    z-index: 2;
    background: transparent;
    width: 100%;
    display: block;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}

.gs-carousel-floating.gs-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Horizontal container - Single row, expands to fill available width */
.gs-carousel-scroll {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    justify-content: flex-start;
    position: relative;
}

/* COMPACT MODE: Carousel-only (no text) - shows max 3 cards with scrolling */
.gs-carousel-compact .gs-carousel-scroll {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.gs-carousel-compact .gs-carousel-scroll::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.gs-carousel-compact .gs-carousel-scroll .gs-card {
    flex: 0 0 auto !important;
}

/* STANDARD MODE: Combined text + carousel - shows all cards */
.gs-carousel-standard .gs-carousel-scroll {
    overflow-x: visible !important;
}

.gs-carousel-standard .gs-carousel-scroll .gs-card {
    flex: 1 !important;
}

/* Card sizing - RESPONSIVE: adapts to container, shares space evenly */
.gs-carousel-scroll .gs-card {
    flex: 1;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    font-family: var(--gs-font-family);
    cursor: pointer;
    overflow: hidden;
    box-sizing: border-box !important;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Force all card children to stack vertically and contain content */
.gs-carousel-scroll .gs-card > * {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Ensure all nested elements respect card boundaries */
.gs-carousel-scroll .gs-card * {
    box-sizing: border-box !important;
    max-width: 100% !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

/* Card content styling */
.gs-carousel-scroll .gs-card-content {
    padding: 10px !important;
    flex: 1 !important;
    overflow: visible !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    gap: 5px !important;
}

/* Button wrapper - pinned to bottom */
.gs-carousel-scroll .gs-card-button-wrapper {
    padding: 0 !important;
}

/* Card header/title */
.gs-carousel-scroll .gs-card-header {
    font-size: 13px !important;
    font-weight: 600 !important;
    margin-bottom: 0px !important;
    line-height: 1.2 !important;
    font-family: var(--gs-font-family);
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    word-wrap: break-word !important;
}

/* Card description wrapper */
.gs-carousel-scroll .gs-card-description {
    font-size: 11px !important;
    line-height: 1.4 !important;
    color: #333 !important;
    font-family: var(--gs-font-family);
    flex: 1 !important;
    overflow: hidden !important;
    word-wrap: break-word !important;
    max-width: 100% !important;
}

/* Description paragraphs */
.gs-carousel-scroll .gs-card-paragraph {
    margin-bottom: 6px !important;
    font-size: inherit !important;
    line-height: inherit !important;
}

.gs-carousel-scroll .gs-card-paragraph:last-child {
    margin-bottom: 0 !important;
}

/* Price styling - using custom gs-card-price class */
.gs-carousel-scroll .gs-card-price {
    display: block !important;
    margin-top: 4px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    color: var(--gs-green) !important;
}

/* Stock status styling - green color for "I lager" etc */
.gs-carousel-scroll .gs-card-stock {
    display: block !important;
    margin-top: 4px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    color: #28a745 !important;
}

/* Card image - Floating carousel only with high specificity */
.gs-carousel-floating img.gs-floating-img {
    padding: 10px !important;
    height: 150px !important;
    width: 100% !important;
    min-width: 0 !important;
    object-fit: fit !important;
    border-radius: 16px !important;
}

/* Card button */
.gs-carousel-scroll .gs-card-button {
    width: 100% !important;
    min-width: 0 !important;
    background-color: var(--gs-green) !important;
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 8px 4px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    font-family: var(--gs-font-family);
    margin-top: auto !important;
}

.gs-carousel-scroll .gs-card-button:hover {
    background-color: var(--gs-green-hover) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(18, 71, 52, 0.3) !important;
}

/* Description containers */
.gs-carousel-scroll .gs-card-desc-container {
    width: 100% !important;
}

/* Links in description - HIDDEN (like VoiceFlow carousel) */
.gs-carousel-scroll .gs-card-link {
    display: none !important;
}

/* Carousel navigation arrows */
.gs-carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gs-green);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(18, 71, 52, 0.3);
    opacity: 1;
    pointer-events: auto;
}

.gs-carousel-arrow:hover {
    background: var(--gs-green-hover);
    transform: translateY(-50%) scale(1.1);
}

.gs-carousel-arrow-left {
    left: -15px;
}

.gs-carousel-arrow-right {
    right: -15px;
}

.gs-carousel-arrow svg {
    width: 20px;
    height: 20px;
}

/* =============================================================================
   Smaller screen STYLES (≤768px)
   ============================================================================= */

@media (max-width: 768px) {
    .gs-popup-wrapper {
        width: 400px;
        bottom: 80px !important;
        right: 10px !important;
        max-width: calc(100vw - 20px) !important;
        margin-left: 10px !important; /* Equal gap from left edge */
    }
    
    .guided-selling-popup {
        padding: 14px;
    }
    
    .gs-content {
        gap: 10px;
    }
    
    .gs-avatar {
        width: 32px !important;
        height: 32px !important;
    }
    
    .gs-text {
        font-size: 13px;
        line-height: 1.4;
        margin-bottom: 12px;
    }
    
    .gs-buttons {
        gap: 6px;
    }
    
    .gs-buttons button {
        font-size: 11px !important;
        padding: 10px 10px !important;
        min-width: 0 !important;
        white-space: normal !important;
        line-height: 1.3 !important;
        hyphens: auto !important;
        -webkit-hyphens: auto !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }

    .gs-carousel-scroll .gs-card-button {
        padding: 8px 6px !important;
    }
    
    /* MOBILE: Carousel adjustments - narrower width, right-aligned */
    .gs-carousel-floating {
        right: -5px !important;
        left: auto !important;
        width: 100% !important;
        padding: 0 !important;
        transform: translateX(0);
    }
    
    /* Carousel card description text - smaller on tablet/mobile */
    .gs-carousel-scroll .gs-card-description {
        font-size: 11px !important;
        line-height: 1.3 !important;
    }
    
    .gs-carousel-floating.gs-visible {
        transform: translateX(0) translateY(0);
    }
    
    .gs-carousel-scroll {
        max-width: 100%;
    }
    
    .gs-carousel-scroll .gs-card-content {
        
    }
    
}

/* =============================================================================
   Mobile STYLES (≤430px)
   ============================================================================= */

/* Compact mobile carousel */
@media (max-width: 430px) {
    .gs-popup-wrapper {
        width: calc(100vw - 40px);
    }
    
    /* Popup buttons - readable size on mobile with higher specificity */
    .gs-buttons .gs-popup-button {
        padding: 9px 13px !important;
        font-size: 11px !important;
    }
    
    .gs-carousel-floating {
        right: -5px !important;
        width: 100% !important;
    }
    
    .gs-carousel-scroll {
        max-width: 100%;
        padding: 5px 0;
        gap: 6px;
    }
    
    .gs-carousel-scroll .gs-card {
        flex: 1; /* Dynamic width - shares available space evenly */
        height: auto !important;
        border-radius: 8px !important;
    }
    
    /* Mobile: Floating carousel images with high specificity */
    .gs-carousel-floating img.gs-floating-img {
        padding: 0 !important;
        padding-top: 0 !important;
        object-fit: contain !important;
        height: 120px !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    
    .gs-carousel-scroll .gs-card-content {
        gap: 1px !important;
    }
    
    .gs-carousel-scroll .gs-card-header {
        font-size: 12px !important;
        font-weight: 700 !important;
        margin-bottom: -2px !important;
        line-height: 1.2 !important;
    }
    
    .gs-carousel-scroll .gs-card-description {
        font-size: 10px !important;
        line-height: 1.3 !important;
    }
    
    /* Red bold price text and labels - readable size */
    .gs-carousel-scroll .gs-card-price {
        font-size: 9px !important;
    }
    
    /* Green bold stock status - same size as price */
    .gs-carousel-scroll .gs-card-stock {
        font-size: 9px !important;
    }
    
    .gs-carousel-scroll .gs-card-button-wrapper {
        padding: 0 !important;
    }
    
    .gs-carousel-scroll .gs-card-button {
        font-size: 9px !important;
        padding: 7px 4px !important;
        line-height: 1.1 !important;
        hyphens: auto !important;
        -webkit-hyphens: auto !important;
        max-width: 100% !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
}
