:root {
    --primary-color: #000000;
    --primary-hover: #333333;
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-user: #000000;
    --bg-assistant: #f7f7f8;
    --text-primary: #000000;
    --text-secondary: #666666;
    --border-color: #e5e5e5;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: rgba(0, 0, 0, 0.5);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 2rem;
}

.modal-container {
    width: 100%;
    max-width: 1200px;
    height: 90vh;
    max-height: 900px;
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%);
    color: white;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.header-content h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.875rem;
    opacity: 0.9;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 0.5rem;
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    scroll-behavior: smooth;
    background: var(--bg-primary);
}

.chat-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.chat-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

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

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 600px;
    margin: 0 auto;
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.welcome-message h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.welcome-message > p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.example-questions {
    margin-top: 2rem;
}

.example-questions p {
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.example-btn {
    display: block;
    width: 100%;
    padding: 0.875rem 1.25rem;
    margin-bottom: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 500;
}

.example-btn:hover {
    background: #e5e5e5;
    border-color: #000000;
    transform: translateY(-1px);
}

/* Message Bubbles */
.message {
    display: flex;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s ease-in;
}

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

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 75%;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    position: relative;
}

.message.user .message-content {
    background: var(--bg-user);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.assistant .message-content {
    background: var(--bg-assistant);
    color: var(--text-primary);
    border-bottom-left-radius: 6px;
    border: 1px solid var(--border-color);
}

.message-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
}

/* Products Section - Topestetic Style */
.products {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.products-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.product-card {
    display: flex;
    align-items: flex-start;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s;
    cursor: pointer;
}

.product-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.product-image {
    width: 70px;
    height: 70px;
    background: var(--bg-secondary);
    border-radius: 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-right: 1rem;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-brand {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.product-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.product-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.75rem;
}

.product-price {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.product-confidence {
    color: #000000;
    font-weight: 600;
}

.product-link {
    color: #000000;
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.product-link:hover {
    text-decoration: underline;
}

/* Metadata */
.message-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.meta-badge.confidence-high {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.meta-badge.confidence-medium {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.meta-badge.confidence-low {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
}

.meta-badge.model {
    background: rgba(0, 0, 0, 0.1);
    color: #000000;
}

.meta-badge.needs-human {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
}

/* Loading Animation */
.message.loading .message-content {
    padding: 1.5rem 1.25rem;
}

.typing-indicator {
    display: flex;
    gap: 0.5rem;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 25%;
    animation: typing 1.4s infinite;
}

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

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

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

/* Input Area */
.input-container {
    padding: 1.5rem 2rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 2px;
    padding: 0.75rem 1rem;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: #000000;
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--text-primary);
    outline: none;
    max-height: 200px;
    line-height: 1.5;
}

#messageInput::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    background: #000000;
    border: none;
    color: white;
    padding: 0.625rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: #333333;
    transform: scale(1.05);
}

.send-btn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    opacity: 0.5;
}

.input-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.separator {
    color: var(--border-color);
}

/* Debug Panel (Bottom Bar) */
.debug-panel {
    background: #f9fafb;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.debug-toggle {
    padding: 0.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.debug-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.debug-toggle-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.debug-toggle-btn svg {
    width: 14px;
    height: 14px;
}

.debug-content {
    display: none;
    padding: 1rem 2rem;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.debug-content.active {
    display: flex;
}

.debug-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.debug-label {
    font-size: 0.625rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.debug-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 0;
    }

    .modal-container {
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .header {
        padding: 1rem 1.5rem;
    }

    .header-content h1 {
        font-size: 1.25rem;
    }

    .chat-container {
        padding: 1rem;
    }

    .message-content {
        max-width: 85%;
    }

    .input-container {
        padding: 1rem 1.5rem;
    }

    .welcome-message {
        padding: 2rem 1rem;
    }

    .debug-content {
        gap: 1rem;
    }

    .debug-toggle,
    .debug-content {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}
