/* ═══════════════════════════════════════════════
   PROFESSIONAL E-COMMERCE CHATBOT WIDGET
   ═══════════════════════════════════════════════ */

#chat-widget {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    top: auto !important;
    z-index: 100000 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    width: auto !important;
}

#chat-window {
    position: fixed !important;
    bottom: 90px !important;
    right: 24px !important;
    top: auto !important;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

#chat-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Theme-Aware Variables (Defaults) */
:root {
    --chat-border: rgba(202, 151, 69, 0.15);
    --chat-bubble-user: var(--chat-accent);
  }

/* ── Toggle Button ──────────────────────────── */
#chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: var(--chat-accent);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

#chat-toggle:hover {
    transform: scale(1.1);
    background: var(--chat-accent-hover);
}

/* ── Header ─────────────────────────────────── */
#chat-header {
    background: var(--chat-header-bg);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

/* ── Messages ───────────────────────────────── */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--chat-bg-light);
    scroll-behavior: smooth;
}

/* Welcome Section Redesign - Separate Choices */
.chat-welcome {
    padding: 10px 5px 15px;
    text-align: center;
}

.chat-choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.chat-choice-card {
    background: #fff;
    border: 2px solid var(--chat-accent);
    border-radius: 12px;
    padding: 15px 10px;
    text-decoration: none !important;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.chat-choice-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
    border-color: var(--chat-accent-hover);
    background: var(--chat-bg-light);
}

.choice-icon {
    font-size: 24px;
    color: var(--chat-accent);
}

.choice-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--chat-text-main);
}

.chat-choice-card.support {
    border-color: #25d366; /* WhatsApp Green */
}
.chat-choice-card.support .choice-icon {
    color: #25d366;
}

.welcome-intro {
    font-size: 13px;
    color: #4a5568;
    line-height: 1.5;
    margin-bottom: 8px;
}

.whatsapp-hint {
    font-size: 10px;
    color: #a0aec0;
}

/* Quick Action Buttons */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0 12px;
    justify-content: center;
}

.quick-btn {
    background: #fff;
    border: 1px solid #d4e5d7;
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 12px;
    color: #405f46;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
}

.quick-btn:hover,
.quick-btn:active,
.quick-btn:focus {
    background: #405f46 !important;
    color: #fff !important;
    border-color: #405f46 !important;
}

/* Message Bubbles */
.msg {
    margin-bottom: 12px;
    display: flex;
    gap: 8px;
    animation: msgFade 0.3s ease;
}

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

.msg.user {
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.msg.bot .msg-avatar {
    background: var(--bg-dark);
    color: var(--accent-bronze);
    border: 1px solid var(--accent-bronze);
}

.msg.user .msg-avatar {
    background: #e2e8f0;
    color: #4a5568;
}

.msg-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    white-space: pre-wrap !important;
}

.msg > div:not(.msg-avatar) {
    display: flex;
    flex-direction: column;
}

.msg.user > div:not(.msg-avatar) {
    align-items: flex-end;
}

.msg.bot .msg-bubble {
    background: #fff;
    color: #2d3748 !important;
    border: 1px solid #e8efe9;
    border-radius: 16px 16px 16px 4px;
}

/* ── Formatted Bot Response Styles ────────── */
.msg.bot .msg-bubble strong {
    color: #405f46;
    font-weight: 600;
}

.msg.bot .msg-bubble ul {
    margin: 6px 0;
    padding-left: 8px;
    list-style: none;
}

.msg.bot .msg-bubble ul li {
    position: relative;
    padding: 5px 0 5px 14px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 13px;
    line-height: 1.5;
    color: #2d3748 !important;
}

.msg.bot .msg-bubble ul li:last-child {
    border-bottom: none;
}

.msg.bot .msg-bubble ul li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: #405f46;
    font-weight: bold;
}

.msg.bot .msg-bubble em {
    font-style: italic;
    color: #718096;
}

.msg.bot .msg-bubble br + br {
    display: block;
    content: '';
    margin-top: 4px;
}

.msg.user .msg-bubble {
    background: var(--accent-bronze);
    color: #1a0f0a;
    font-weight: 500;
    border-radius: 16px 16px 4px 16px;
}

.msg-time {
    font-size: 10px;
    color: #a0aec0;
    margin-top: 4px;
    padding: 0 4px;
}

.msg.user .msg-time {
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    align-items: center;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: #a0aec0;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ── Input Area ─────────────────────────────── */
#chat-input-area {
    border-top: 1px solid #e8efe9;
    background: #fff;
    flex-shrink: 0;
}

#chat-form {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    gap: 8px;
}

#chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s;
    background: #f7fafc;
}

#chat-input:focus {
    border-color: #405f46;
    background: #fff;
}

#chat-input::placeholder {
    color: #a0aec0;
}

#chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--accent-bronze);
    color: #1a0f0a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#chat-send:hover {
    background: #344a38;
    transform: scale(1.05);
}

#chat-send:disabled {
    background: #c1d3c4;
    cursor: not-allowed;
    transform: none;
}

.chat-powered {
    text-align: center;
    font-size: 10px;
    color: #cbd5e0;
    padding: 0 0 8px;
}

.chat-link {
    display: block;
    margin: 10px 0;
    padding: 10px 16px;
    background: #fff;
    color: var(--accent-bronze) !important;
    text-decoration: none !important;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 1.5px solid var(--accent-bronze);
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.chat-link:hover,
.chat-link:active,
.chat-link:focus {
    background: var(--accent-bronze) !important;
    color: #fff !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(202, 151, 69, 0.3);
}

/* Hide bullet points when the list item contains a product button */
.msg.bot .msg-bubble ul li:has(.chat-link) {
    padding-left: 0;
}
.msg.bot .msg-bubble ul li:has(.chat-link)::before {
    display: none;
}

/* Empty - removed duplicate hover block */

/* ── Error Message ──────────────────────────── */
.msg-error .msg-bubble {
    background: #fff5f5 !important;
    border-color: #fed7d7 !important;
    color: #c53030 !important;
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 440px) {
    #chat-window {
        width: calc(100vw - 24px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: -12px;
        border-radius: 12px;
    }
}
