/* Reset & Variables */

:root {
    --vp-primary-start: #7c3aed;
    /* Violet 600 */
    --vp-primary-end: #a855f7;
    /* Purple 500 */
    --vp-primary: #7c3aed;
    --vp-bg-light: #f8fafc;
    /* Slate 50 */
    --vp-text-dark: #1e293b;
    /* Slate 800 */
    --vp-text-muted: #64748b;
    /* Slate 500 */
    --vp-green: #10b981;
    --msg-user-bg: #ede9fe;
    /* Violet 100 */
    --msg-bot-bg: #ffffff;
    --shadow-soft: 0 8px 24px rgba(124, 58, 237, 0.12);
    --shadow-hover: 0 8px 20px rgba(124, 58, 237, 0.2);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 10px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html,
body {
    height: 100%;
    width: 100%;
    margin: 0;
}

body {
    font-family: var(--font-family);
    background: transparent;
    margin: 0;
}


/* Chat Widget Container */

.chat-widget {
    position: fixed;
    inset: 0;
    /* ✅ EXACTLY like vp-chat-container */
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 0;
}

@media (min-width: 768px) {
    body.preview-mode .chat-widget {
        max-width: 420px;
        max-height: 700px;
        margin: auto;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-soft);
    }
}

@media (min-width: 480px) {
    .chat-widget {
        height: 85vh;
        margin: 20px;
    }
}


/* Header */

.chat-header {
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

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

.logo-circle {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--vp-primary-start), var(--vp-primary-end));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--vp-text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--vp-green);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}


/* Messages Area */

.chat-messages {
    flex: 1;
    background-color: var(--vp-bg-light);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}


/* Message Styles */

.message {
    display: flex;
    align-items: flex-end;
    /* Align avatar to bottom */
    gap: 8px;
    max-width: 85%;
    opacity: 0;
    animation: messageSlideIn 0.3s ease forwards;
}

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

.message.bot {
    align-self: flex-start;
}

.avatar {
    width: 32px;
    height: 32px;
    background: #ddd6fe;
    /* Violet 200 */
    color: var(--vp-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.message.user .avatar {
    display: none;
}


/* No avatar for user */

.message-content {
    display: flex;
    flex-direction: column;
}

.bubble {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}


/* User Bubble */

.message.user .bubble {
    background: var(--msg-user-bg);
    color: var(--vp-text-dark);
    border-radius: 18px 18px 4px 18px;
}


/* Bot Bubble */

.message.bot .bubble {
    background: var(--msg-bot-bg);
    color: var(--vp-text-dark);
    border-radius: 18px 18px 18px 4px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}


/* Typing Indicator */

.typing-bubble {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    min-width: 60px;
    justify-content: center;
}

.dot {
    width: 6px;
    height: 6px;
    background: #bfdbfe;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

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

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


/* Product Cards */

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 10px;
    width: 100%;
}

.product-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-md);
    padding: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    display: block;
    color: inherit;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    border-color: #d8b4fe;
}

.product-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--vp-text-dark);
}

.product-price {
    font-weight: 700;
    color: var(--vp-primary);
    font-size: 14px;
}

.product-link {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--vp-primary);
    font-weight: 500;
    text-decoration: none;
}

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

.product-image {
    width: 100%;
    height: 120px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 8px;
    background: #f9fafb;
}

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

.product-image-placeholder {
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 24px;
}


/* Input & Chips Area */

.suggestion-chips {
    padding: 8px 20px 0;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    /* Hide scrollbar Firefox */
    -ms-overflow-style: none;
    /* IE */
}

.suggestion-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    background: white;
    border: 1px solid #e5e7eb;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--vp-text-dark);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.chip:hover {
    background: #f3e8ff;
    border-color: #d8b4fe;
    color: var(--vp-primary);
}

.input-area {
    padding: 16px 20px;
    background: #fff;
    flex-shrink: 0;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-area input {
    width: 100%;
    padding: 12px 48px 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f9fafb;
}

.input-area input:focus {
    border-color: var(--vp-primary);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.15);
    background: #fff;
}

.input-area button {
    position: absolute;
    right: 8px;
    background: linear-gradient(135deg, var(--vp-primary-start), var(--vp-primary-end));
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
}

.input-area button:hover {
    transform: scale(1.05);
    opacity: 0.95;
}

.input-area button:active {
    transform: scale(0.95);
}


/* Animations */

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

@keyframes typingBounce {
    0%,
    80%,
    100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}


/* HTML Content Styling */

.bubble ul {
    padding-left: 18px;
    margin: 8px 0;
    list-style-type: disc;
}

.bubble li {
    margin-bottom: 6px;
    padding-left: 4px;
    line-height: 1.5;
}

.bubble b {
    font-weight: 600;
    color: #4b5563;
}

.chat-close-btn {
    background: transparent;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #64748b;
    padding: 4px 8px;
}

.chat-close-btn:hover {
    color: #111827;
}

@media (min-width: 768px) {
    body.standalone-preview .chat-widget {
        inset: auto;
        width: 420px;
        height: 700px;
        margin: auto;
        border-radius: 24px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    }
}

#user-input {
    font-size: 18px !important;
}