﻿/**
 * Sales Chat Widget Styles
 * 
 * Dark theme by default, matches Chomi landing page aesthetic.
 * Uses CSS custom properties for easy theming.
 */

/* CSS Custom Properties */
.scw-container {
    --scw-primary: #8b5cf6;
    --scw-primary-hover: #7c3aed;
    --scw-bg: #1a1a2e;
    --scw-bg-secondary: #16162a;
    --scw-bg-message: #252542;
    --scw-bg-user: #8b5cf6;
    --scw-text: #ffffff;
    --scw-text-muted: #a0a0b0;
    --scw-border: #2a2a4a;
    --scw-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --scw-radius: 16px;
    --scw-radius-sm: 8px;
    --scw-font-primary: 'Poppins', sans-serif;
    --scw-font-secondary: 'Inter', sans-serif;
}

    /* Light theme override */
    .scw-container.scw-light {
        --scw-bg: #ffffff;
        --scw-bg-secondary: #f5f5f7;
        --scw-bg-message: #f0f0f5;
        --scw-bg-user: #8b5cf6;
        --scw-text: #1a1a2e;
        --scw-text-muted: #6b6b7b;
        --scw-border: #e0e0e5;
        --scw-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    }

/* Container positioning */
.scw-container {
    position: fixed;
    z-index: 9999;
    font-family: var(--scw-font-primary);
    font-size: 14px;
    line-height: 1.5;
}

    .scw-container.scw-bottom-right {
        bottom: 20px;
        right: 20px;
    }

    .scw-container.scw-bottom-left {
        bottom: 20px;
        left: 20px;
    }

/* Chat bubble */
.scw-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--scw-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--scw-shadow);
    transition: transform 0.2s ease, background-color 0.2s ease;
}

    .scw-bubble:hover {
        background: var(--scw-primary-hover);
        transform: scale(1.05);
    }

    .scw-bubble svg {
        width: 28px;
        height: 28px;
        color: white;
    }

    .scw-bubble .scw-icon-chat {
        font-size: 28px;
        line-height: 1;
    }

    .scw-bubble .scw-icon-close {
        display: none;
    }

.scw-container.scw-open .scw-bubble .scw-icon-chat {
    display: none;
}

.scw-container.scw-open .scw-bubble .scw-icon-close {
    display: block;
}

/* Chat panel */
.scw-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: var(--scw-bg);
    border-radius: var(--scw-radius);
    box-shadow: var(--scw-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.scw-container.scw-bottom-left .scw-panel {
    right: auto;
    left: 0;
}

.scw-container.scw-open .scw-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.scw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--scw-bg-secondary);
    border-bottom: 1px solid var(--scw-border);
}

.scw-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 18px;
    color: var(--scw-text);
    font-family: var(--scw-font-secondary);
}

.scw-header-icon {
    font-size: 24px;
}

.scw-header-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--scw-text-muted);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.15s;
}

    .scw-header-close:hover {
        background: var(--scw-border);
        color: var(--scw-text);
    }

/* Messages area */
.scw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

    .scw-messages::-webkit-scrollbar {
        width: 6px;
    }

    .scw-messages::-webkit-scrollbar-track {
        background: transparent;
    }

    .scw-messages::-webkit-scrollbar-thumb {
        background: var(--scw-border);
        border-radius: 3px;
    }

/* Message bubbles */
.scw-message {
    display: flex;
    max-width: 85%;
}

.scw-message-bot {
    align-self: flex-start;
}

.scw-message-user {
    align-self: flex-end;
}

.scw-message-content {
    padding: 10px 14px;
    border-radius: var(--scw-radius-sm);
    color: var(--scw-text);
    word-wrap: break-word;
}

.scw-message-bot .scw-message-content {
    background: var(--scw-bg-message);
    border-bottom-left-radius: 4px;
}

.scw-message-user .scw-message-content {
    background: var(--scw-bg-user);
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.scw-typing .scw-message-content {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.scw-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--scw-text-muted);
    border-radius: 50%;
    animation: scw-typing-bounce 1.4s ease-in-out infinite;
}

    .scw-typing-dot:nth-child(2) {
        animation-delay: 0.2s;
    }

    .scw-typing-dot:nth-child(3) {
        animation-delay: 0.4s;
    }

@keyframes scw-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Consent banner */
.scw-consent {
    padding: 12px 16px;
    background: var(--scw-bg-secondary);
    border-top: 1px solid var(--scw-border);
}

    .scw-consent p {
        margin: 0 0 12px 0;
        color: var(--scw-text);
        font-size: 13px;
    }

.scw-consent-buttons {
    display: flex;
    gap: 8px;
}

    .scw-consent-buttons button {
        flex: 1;
        padding: 8px 12px;
        border-radius: var(--scw-radius-sm);
        font-size: 13px;
        font-weight: 500;
        cursor: pointer;
        transition: background-color 0.15s;
    }

.scw-consent-yes {
    background: var(--scw-primary);
    color: white;
    border: none;
}

    .scw-consent-yes:hover {
        background: var(--scw-primary-hover);
    }

.scw-consent-no {
    background: transparent;
    color: var(--scw-text-muted);
    border: 1px solid var(--scw-border);
}

    .scw-consent-no:hover {
        background: var(--scw-border);
        color: var(--scw-text);
    }

/* Input area */
.scw-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    background: var(--scw-bg-secondary);
    border-top: 1px solid var(--scw-border);
}

.scw-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--scw-bg);
    border: 1px solid var(--scw-border);
    border-radius: var(--scw-radius-sm);
    color: var(--scw-text);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    max-height: 120px;
    outline: none;
    transition: border-color 0.15s;
}

    .scw-input::placeholder {
        color: var(--scw-text-muted);
    }

    .scw-input:focus {
        border-color: var(--scw-primary);
    }

.scw-send {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: var(--scw-primary);
    border: none;
    border-radius: var(--scw-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s;
}

    .scw-send:hover:not(:disabled) {
        background: var(--scw-primary-hover);
    }

    .scw-send:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .scw-send svg {
        width: 18px;
        height: 18px;
        color: white;
    }

/* Mobile responsiveness — full-screen at 768px and below */
@media (max-width: 768px) {
    /* Container position unchanged — bubble stays bottom-right */
    .scw-container {
        bottom: 20px;
        right: 20px;
    }

    .scw-container.scw-bottom-left {
        left: 20px;
    }

    /* Panel: full viewport, slide up from bottom, edge-to-edge */
    .scw-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        transform: translateY(100%);
        transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s;
    }

    .scw-container.scw-open .scw-panel {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    /* Hide the bubble when panel is open */
    .scw-container.scw-open .scw-bubble {
        display: none;
    }

    /* Larger close button tap target */
    .scw-header-close {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }

    /* Prevent iOS auto-zoom on input focus */
    .scw-input {
        font-size: 16px;
    }
}

.scw-message-user .scw-message-content {
    background: var(--scw-bg-user);
    border-bottom-right-radius: 4px;
    color: #ffffff;
}

/* Dark themed widget */
.scw-dark .scw-block-link {
    color: #60a5fa !important;
}

/* Light themed widget */
.scw-light .scw-block-link {
    color: #2563eb !important;
}

.scw-block-link:hover {
    text-decoration: underline;
}

button.scw-block-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
}