/* ============================================================================
 * SHOPPING AGENT - GLOBAL STYLES
 * ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;900&display=swap');

/* ============================================================================
 * LAYOUT & TYPOGRAPHY
 * ============================================================================ */

:root {
    --color-primary: #18181b;
    --color-secondary: #a1a1aa;
    --color-success: #22c55e;
    --color-error: #ef4444;
    --color-bg-light: #f4f4f5;
    --color-bg-muted: #ffffff;
    --color-border: #e4e4e7;
    --color-text: #18181b;
    --color-text-muted: #71717a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #ffffff;
    color: #1a1a1a;
    line-height: 1.6;
}

/* ============================================================================
 * CHAT CONTAINER LAYOUT
 * ============================================================================ */

.chat-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 1100px;
    margin: 0 auto;
}

/* ============================================================================
 * HEADER
 * ============================================================================ */

.header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #f4f4f5;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 50;
}

.sa-avatar {
    width: 36px;
    height: 36px;
    background: #18181b;
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: bold;
    flex-shrink: 0;
    margin-right: 0.75rem;
}

.header-title {
    font-weight: 900;
    font-size: 1.25rem;
    letter-spacing: -0.025em;
}

/* ============================================================================
 * MESSAGES AREA
 * ============================================================================ */

.messages-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll */
    padding: 2rem;
    scrollbar-width: none;
    width: 100%; /* Ensure it doesn't expand beyond parent */
}

.messages-area::-webkit-scrollbar {
    display: none;
}

/* Message Block Styles */
.message {
    margin-bottom: 3rem;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.4s ease-out;
    position: relative;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-items: flex-end;
}

.message.agent {
    align-items: flex-start;
}

.bubble {
    max-width: 85%;
    padding: 1.25rem 1.5rem;
    border-radius: 1.5rem;
    font-size: 1rem;
    line-height: 1.6;
}

.message.user .bubble {
    background-color: #f4f4f5;
    color: #18181b;
    border-bottom-right-radius: 0.25rem;
}

.message.agent .bubble {
    background-color: transparent;
    color: #18181b;
    padding-left: 0;
    padding-bottom: 0.5rem;
}

.agent-avatar {
    margin-bottom: 0.75rem;
}

/* Message Feedback Area */
.message-feedback {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.1s ease-in-out;
}

.message:hover .message-feedback,
.message-feedback.has-active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease-in-out;
}

.feedback-btn {
    font-size: 0.8rem;
    color: #a1a1aa;
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: none;
    cursor: pointer;
}

.feedback-btn:hover {
    background: #f4f4f5;
    color: #18181b;
}

.feedback-btn:focus-visible {
    outline: 2px solid #18181b;
    outline-offset: 2px;
}

.feedback-btn.active-up {
    color: #22c55e !important;
    background: rgba(34, 197, 94, 0.05);
}

.feedback-btn.active-down {
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.05);
}

/* ============================================================================
 * PRODUCT GRID & CARDS
 * ============================================================================ */

.product-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    width: 100%;
    max-width: 100%; /* Prevent overflow */
    margin-top: 2rem;
    margin-bottom: 3rem;
}

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

@media (min-width: 600px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 900px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.product-card {
    background: white;
    border-radius: 32px;
    overflow: hidden;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    border: 1px solid #f3f4f6;
    display: flex;
    flex-direction: column;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
    border-color: rgba(0, 0, 0, 0.05);
}

.product-image-container {
    position: relative;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: #f9fafb;
    cursor: pointer;
}

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

.product-image-container:hover .product-image {
    transform: scale(1.05);
}

.product-actions {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    gap: 1rem;
    pointer-events: auto;
    z-index: 10;
}

.thumb-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.3));
    outline: none !important;
    border: none !important;
    background: transparent !important;
    -webkit-tap-highlight-color: transparent;
    box-shadow: none !important;
    appearance: none;
    -webkit-appearance: none;
    padding: 0 !important;
    margin: 0 !important;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 1.5rem;
}

.thumb-btn:hover {
    transform: scale(1.25);
}

.thumb-btn:focus-visible {
    outline: 2px solid white !important;
    outline-offset: 2px;
}

.thumb-up:hover,
.thumb-btn.active-up {
    color: #22c55e !important;
    filter: drop-shadow(0 4px 12px rgba(34, 197, 94, 0.4));
}

.thumb-down:hover,
.thumb-btn.active-down {
    color: #ef4444 !important;
    filter: drop-shadow(0 4px 12px rgba(239, 68, 68, 0.4));
}

.product-content {
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

.product-name {
    font-weight: 500;
    font-size: 1rem;
    color: #111827;
    line-height: 1.4;
    min-width: 0; /* Allow flex item to shrink below content size */
    overflow-wrap: break-word;
}

.product-price {
    font-weight: 900;
    font-size: 1.25rem;
    color: #111827;
    white-space: nowrap;
    flex-shrink: 0;
}

.product-rating-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.product-stars {
    display: inline-block;
    vertical-align: middle;
}

.stars-outer {
    position: relative;
    display: inline-block;
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: #e5e7eb;
    font-size: 0.75rem;
    letter-spacing: 0.125rem;
}

.stars-outer::before {
    content: "\f005 \f005 \f005 \f005 \f005";
}

.stars-inner {
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    overflow: hidden;
    width: 0;
    color: #fbbf24;
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}

.stars-inner::before {
    content: "\f005 \f005 \f005 \f005 \f005";
}

.product-rating-text {
    font-size: 0.6875rem;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.product-description {
    font-size: 0.9375rem;
    color: #6b7280;
    margin-bottom: 2rem;
    line-height: 1.55;
    flex: 1;
}

.product-open-link {
    width: 100%;
    padding: 1rem;
    background-color: #fafafa;
    color: #18181b;
    border: none;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    text-decoration: none;
    display: block;
}

.product-open-link:hover {
    background-color: #18181b;
    color: white;
}

.product-open-link:focus-visible {
    outline: 2px solid #18181b;
    outline-offset: 2px;
}

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

/* .typing-indicator removed/not used as wrapper anymore, using .message.agent structure */

.typing-bubble {
    background-color: #f4f4f5;
    padding: 0.75rem 1.25rem;
    border-radius: 1.25rem;
    border-top-left-radius: 0.25rem; /* Align with agent avatar side */
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #71717a;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: -0.5rem; /* Pull closer to avatar if needed, or adjust */
}

/* Hide helper */
.hidden {
    display: none !important;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background-color: #a1a1aa;
    border-radius: 50%;
    animation: typing 1.4s infinite both;
}

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

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

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ============================================================================
 * INPUT AREA & FOOTER
 * ============================================================================ */

.input-area {
    padding: 2rem;
    border-top: 1px solid #f4f4f5;
    background: white;
    position: sticky;
    bottom: 0;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: #f4f4f5;
    border-radius: 1.5rem;
    padding: 0.75rem 1rem;
    transition: all 0.2s;
    border: 1px solid transparent;
    max-width: 800px;
    margin: 0 auto 1rem;
}

.input-wrapper:focus-within {
    background: white;
    border-color: #e4e4e7;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.75rem;
    outline: none;
    font-size: 1rem;
    font-family: inherit;
}

.send-btn {
    background: #18181b;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.send-btn:hover {
    opacity: 0.9;
}

.send-btn:focus-visible {
    outline: 2px solid #18181b;
    outline-offset: 2px;
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.footer-text {
    font-size: 10px;
    text-align: center;
    color: #9ca3af;
    margin-top: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    font-weight: 900;
}

/* ============================================================================
 * MODAL STYLES
 * ============================================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 3.5rem;
    border-radius: 3rem;
    width: 95%;
    max-width: 700px;
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.3);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 2.5rem;
    right: 3rem;
    color: #a1a1aa;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: transparent;
    font-size: 1.5rem;
}

.modal-close:hover {
    color: #18181b;
    transform: rotate(90deg);
}

.modal-close:focus-visible {
    outline: 2px solid #18181b;
    outline-offset: 2px;
}

.modal-title {
    font-size: 1.875rem;
    font-weight: 900;
    margin-bottom: 0.5rem;
}

.modal-subtitle {
    color: #a1a1aa;
    margin-bottom: 2rem;
    font-weight: 500;
}

.modal-textarea {
    width: 100%;
    height: 16rem;
    padding: 2rem;
    background: #fafafa;
    border: 1px solid #f4f4f5;
    border-radius: 2.5rem;
    outline: none;
    font-family: inherit;
    font-size: 1.125rem;
    line-height: 1.625;
    resize: none;
    transition: all 0.2s;
    margin-bottom: 2.5rem;
}

.modal-textarea:focus {
    border-color: #18181b;
    background: white;
}

.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-photo-upload {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    color: #71717a;
    transition: all 0.2s;
    border: none;
    background: transparent;
    font-size: 1.125rem;
    font-weight: 700;
}

.modal-photo-upload:hover {
    color: #18181b;
}

.modal-photo-icon {
    width: 56px;
    height: 56px;
    background: #f4f4f5;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.modal-photo-preview {
    width: 56px;
    height: 56px;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid #e4e4e7;
    display: none;
}

.modal-photo-preview.active {
    display: block;
}

.modal-photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-submit-btn {
    padding: 1.25rem 3rem;
    background: #18181b;
    color: white;
    border: none;
    border-radius: 1.5rem;
    font-weight: 900;
    font-size: 1.125rem;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-submit-btn:hover {
    background: #000;
}

.modal-submit-btn:focus-visible {
    outline: 2px solid #18181b;
    outline-offset: 2px;
}

/* ============================================================================
 * TOAST NOTIFICATIONS
 * ============================================================================ */

.toast-container {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: #18181b;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
}

.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ============================================================================
 * LIGHTBOX
 * ============================================================================ */

.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(9, 9, 11, 0.95);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    cursor: zoom-out;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-image {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: 1rem;
}

/* ============================================================================
 * RESPONSIVE DESIGN
 * ============================================================================ */

@media (max-width: 640px) {
    /* .product-grid handled by main media queries now */

    .modal-content {
        padding: 2rem;
        border-radius: 2rem;
    }

    .product-content {
        padding: 1.25rem;
    }

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

    .message-feedback {
        opacity: 1 !important;
        visibility: visible !important;
    }

    .chat-container {
        max-width: 100%;
    }

    .header {
        padding: 1rem 1.5rem;
    }

    .messages-area {
        padding: 1rem;
    }

    .input-area {
        padding: 1.5rem;
    }

    .modal-photo-upload {
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-actions {
        flex-direction: column;
        gap: 1rem;
    }

    .modal-submit-btn {
        width: 100%;
    }
}
