:root {
    --primary-color: #111827;
    /* Slate 900 */
    --secondary-color: #6b7280;
    /* Slate 500 */
    --accent-color: #2563eb;
    /* Blue 600 */
    --background-color: #f3f4f6;
    /* Gray 100 */
    --chat-bg: #ffffff;
    --user-msg-bg: #111827;
    --ai-msg-bg: #f9fafb;
    /* Gray 50 */
    --border-color: #e5e7eb;
    /* Gray 200 */
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--background-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll */
}

/* Split Layout */
.app-container {
    display: grid;
    grid-template-columns: 450px 1fr;
    height: 100vh;
    width: 100vw;
}

/* Left Panel: Chat */
.chat-panel {
    display: flex;
    flex-direction: column;
    height: 100vh;
    border-right: 1px solid var(--border-color);
    background: white;
    overflow: hidden;
}

.chat-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: white;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.brand span {
    color: var(--primary-color);
}

.new-chat-btn {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.new-chat-btn:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.new-chat-btn svg {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.new-chat-btn:hover svg {
    transform: rotate(180deg);
}

/* Chat Messages - Scrollable */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
    min-height: 0;
}

.message {
    display: flex;
    gap: 1rem;
    max-width: 90%;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* Tip Messages */
.tip-message {
    align-self: center;
    background: #f0f9ff;
    /* Light blue background */
    border: 1px solid #e0f2fe;
    color: #0369a1;
    padding: 0.6rem 1rem;
    border-radius: 9999px;
    /* Pill shape */
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 90%;
    margin: 1rem auto;
    /* Center with margin */
    animation: fadeIn 0.5s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tip-icon {
    flex-shrink: 0;
    color: #0284c7;
    display: flex;
    align-items: center;
    background: #e0f2fe;
    padding: 4px;
    border-radius: 50%;
}

.tip-content {
    line-height: 1.4;
    font-weight: 500;
}

.tip-content strong {
    font-weight: 700;
    color: #0c4a6e;
}

/* Message Avatars */
.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.user-message .message-avatar {
    background: #f1f5f9;
    color: #64748b;
    /* Removed order: 2 to keep it on the right (due to row-reverse) */
    /* Removed extra margin */
}

.assistant-message .message-avatar {
    background: linear-gradient(135deg, #4f46e5, #0ea5e9);
    /* Brand gradient */
    color: white;
    /* Removed extra margin */
}

.message-content {
    background: var(--ai-msg-bg);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border-top-left-radius: 4px;
    line-height: 1.6;
    font-size: 0.95rem;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.user-message .message-content {
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius);
    border-top-right-radius: 4px;
    border: none;
    box-shadow: var(--shadow-md);
}

/* Suggestion Chips */
.suggestion-chips {
    display: flex;
    flex-direction: column;
    /* Vertical stack */
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    overflow-y: auto;
    max-height: 300px;
    /* Increased height for vertical list */
    flex-shrink: 0;
}

.suggestion-chip {
    background: white;
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    /* Slightly less rounded for list items */
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: normal;
    /* Allow text wrapping */
    text-align: left;
    width: 100%;
    /* Full width */
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.suggestion-chip:after {
    content: '→';
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.2s;
    color: var(--accent-color);
    font-weight: bold;
}

.suggestion-chip:hover {
    background: var(--background-color);
    border-color: var(--primary-color);
    transform: translateX(2px);
    /* Slight nudge right */
}

.suggestion-chip:hover:after {
    opacity: 1;
    transform: translateX(0);
}

/* Input Area - Fixed at Bottom */
.chat-input-container {
    margin-bottom: 1rem;
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-color);
    background: white;
    flex-shrink: 0;
}

.chat-input-wrapper {
    position: relative;
    max-width: 100%;
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    background: var(--background-color);
    padding: 0.75rem 1rem;
    border-radius: 16px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.chat-input-wrapper:focus-within {
    background: white;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    max-height: 120px;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    padding: 0.25rem 0;
    outline: none;
    color: var(--text-primary);
}

.send-button {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.send-button:hover {
    transform: scale(1.05);
    background: black;
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Right Panel: Results */
.results-panel {
    background: var(--background-color);
    overflow-y: auto;
    padding: 2rem;
    height: 100%;
}

.results-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--secondary-color);
    text-align: center;
    opacity: 0.7;
}

.placeholder-icon {
    margin-bottom: 1rem;
    color: var(--border-color);
    background: white;
    padding: 2rem;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    width: 100%;
    padding-bottom: 2rem;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.product-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-color);
}

.product-image {
    width: 100%;
    aspect-ratio: 3/4;
    /* Portrait for rugs */
    object-fit: cover;
    background: #f3f4f6;
}

.product-info {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    line-height: 1.4;
}

.detail-label {
    font-weight: 600;
    color: var(--text-primary);
}

.product-price {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1.25rem;
    margin-bottom: 1rem;
    margin-top: auto;
}

.product-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.btn {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #000000;
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--background-color);
    border-color: #d1d5db;
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 0.5rem 0;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--secondary-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

.carousel-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.2s;
}

.carousel-dot.active {
    background: white;
    transform: scale(1.2);
}

/* Variant Table */
.variant-table {
    margin: 0.5rem 0 1rem 0;
    border: none;
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.9rem;
    background: #f9fafb;
}

.variant-header {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: transparent;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.variant-row {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.variant-row:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

.variant-row:last-child {
    border-bottom: none;
}

.variant-size {
    font-weight: 500;
    color: var(--text-primary);
}

.variant-price {
    font-weight: 600;
    color: #10b981;
    /* Green color from image */
}

.variant-more {
    padding: 0.5rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.02);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.85rem;
}

/* Badges (Material & Features) */
.badge-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.info-badge {
    background: #f3f4f6;
    color: var(--text-secondary);
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Grid Layout Override */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* Force 2 columns */
    gap: 1.5rem;
    padding: 1rem;
}

@media (max-width: 1200px) {
    .product-grid {
        grid-template-columns: 1fr;
        /* 1 column on smaller screens */
    }
}

/* Carousel */
.carousel-container {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    overflow: hidden;
    background: #f3f4f6;
}

.carousel-slide {
    width: 100%;
    height: 100%;
    display: none;
}

.carousel-slide.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.8);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 2;
}

.carousel-container:hover .carousel-btn {
    opacity: 1;
}

.carousel-btn:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
}

.carousel-btn.prev {
    left: 10px;
}

.carousel-btn.next {
    right: 10px;
}

.carousel-dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 2;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Responsive */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 350px 1fr;
    }
}

.btn.disabled {
    background-color: #ccc;
    border-color: #ccc;
    color: #666;
    cursor: not-allowed;
    opacity: 0.7;
    pointer-events: none;
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .chat-panel {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}

/* Debug Info */
.debug-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    cursor: pointer;
    opacity: 0.3;
    vertical-align: middle;
    color: var(--text-secondary);
    transition: opacity 0.2s;
}

.debug-icon:hover {
    opacity: 1;
    color: var(--primary-color);
}

.debug-content {
    font-size: 11px;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    margin-top: 8px;
    overflow-x: auto;
    white-space: pre-wrap;
    color: #4b5563;
    border: 1px solid #e5e7eb;
    font-family: monospace;
}

.debug-content.hidden {
    display: none;
}