/* ═══════════════════════════════════════
   ROYA AI CHATBOT WIDGET
   Floating chat widget with RTL support
   ═══════════════════════════════════════ */

/* ── Floating Action Button ── */
.chatbot-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #d4af37, #b8972e);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s, box-shadow 0.3s;
}

.chatbot-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(212, 175, 55, 0.5);
}

.chatbot-fab .fab-close { display: none; }
.chatbot-fab.open .fab-open { display: none; }
.chatbot-fab.open .fab-close { display: inline; }

[dir="rtl"] .chatbot-fab {
    right: auto;
    left: 30px;
}

/* ── Chat Window ── */
.chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    z-index: 9999;
    width: 380px;
    max-height: 520px;
    border-radius: 16px;
    background: var(--card-bg, #1a1a2e);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    box-shadow: 0 12px 48px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chatbot-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

[dir="rtl"] .chatbot-window {
    right: auto;
    left: 30px;
}

/* ── Chat Header ── */
.chatbot-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(212,175,55,0.12), rgba(212,175,55,0.04));
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d4af37, #b8972e);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #fff;
    flex-shrink: 0;
}

.chatbot-header-info h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-1, #fff);
}

.chatbot-header-info span {
    font-size: 0.72rem;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-header-info span::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
}

/* ── Messages Area ── */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    max-height: 340px;
    scroll-behavior: smooth;
}

.chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.55;
    word-break: break-word;
    animation: chatMsgIn 0.25s ease;
}

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

.chatbot-msg.bot {
    align-self: flex-start;
    background: var(--body-bg, #12121f);
    color: var(--text-2, #ccc);
    border-bottom-left-radius: 4px;
}

[dir="rtl"] .chatbot-msg.bot {
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 4px;
}

.chatbot-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #d4af37, #b8972e);
    color: #000;
    border-bottom-right-radius: 4px;
}

[dir="rtl"] .chatbot-msg.user {
    border-bottom-right-radius: 14px;
    border-bottom-left-radius: 4px;
}

/* ── Typing Indicator ── */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
    background: var(--body-bg, #12121f);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.chatbot-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold, #d4af37);
    animation: typingBounce 1.2s infinite;
}

.chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ── Input Area ── */
.chatbot-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border, rgba(255,255,255,0.06));
    display: flex;
    gap: 8px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    background: var(--body-bg, #12121f);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.85rem;
    color: var(--text-1, #fff);
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.chatbot-input:focus {
    border-color: var(--gold, #d4af37);
}

.chatbot-input::placeholder {
    color: var(--text-3, #666);
}

.chatbot-send {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #d4af37, #b8972e);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.chatbot-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
    .chatbot-fab {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    .chatbot-window {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 80px;
        max-height: 60vh;
    }
    [dir="rtl"] .chatbot-fab {
        right: auto;
        left: 16px;
    }
    [dir="rtl"] .chatbot-window {
        right: auto;
        left: 12px;
    }
}
@media (max-width: 380px) {
    .chatbot-fab {
        bottom: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }
    .chatbot-window {
        bottom: 68px;
    }
    [dir="rtl"] .chatbot-fab {
        right: auto;
        left: 12px;
    }
}

/* ── Cooldown state (on rate-limit) ── */
.chatbot-input.chatbot-cooldown {
    opacity: 0.5;
    pointer-events: none;
}

/* ═══════════════════════════════════════
   AI MODAL TOUR (Spotlight Overlay)
   ═══════════════════════════════════════ */
.ai-tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 10010;
    background: rgba(0, 0, 0, 0.7);
    pointer-events: auto;
    animation: ai-fade-in 0.3s ease;
}

.ai-tour-spotlight {
    position: absolute;
    z-index: 10011;
    border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    transition: all 0.4s ease;
}

.ai-tour-tooltip {
    position: absolute;
    z-index: 10012;
    background: var(--card-bg, #1e1e32);
    border: 1px solid var(--gold, #d4af37);
    border-radius: 12px;
    padding: 16px 20px;
    max-width: 280px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: chatMsgIn 0.3s ease;
}

.ai-tour-tooltip h4 {
    margin: 0 0 6px;
    font-size: 0.85rem;
    color: var(--gold, #d4af37);
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-tour-tooltip p {
    margin: 0 0 12px;
    font-size: 0.82rem;
    color: var(--text-2, #ccc);
    line-height: 1.5;
}

.ai-tour-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-tour-dots {
    display: flex;
    gap: 5px;
}

.ai-tour-dots .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-3, #555);
    transition: background 0.2s;
}

.ai-tour-dots .dot.active {
    background: var(--gold, #d4af37);
    width: 16px;
    border-radius: 3px;
}

.ai-tour-next {
    padding: 6px 16px;
    border-radius: 8px;
    border: none;
    background: var(--gold, #d4af37);
    color: #000;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.ai-tour-next:hover { opacity: 0.85; }

/* ═══════════════════════════════════════
   CHATBOT — LIGHT THEME OVERRIDES
   ═══════════════════════════════════════ */
[data-theme="light"] .chatbot-window {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .chatbot-header {
    background: linear-gradient(135deg, rgba(184, 134, 11, 0.08), rgba(184, 134, 11, 0.03));
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .chatbot-header-info h4 {
    color: #1e293b;
}

[data-theme="light"] .chatbot-messages {
    background: #ffffff;
}

[data-theme="light"] .chatbot-msg.bot {
    background: #f1f5f9;
    color: #374151;
}

[data-theme="light"] .chatbot-typing {
    background: #f1f5f9;
}

[data-theme="light"] .chatbot-input-area {
    border-top-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .chatbot-input {
    background: #f8f9fa;
    border-color: #d1d5db;
    color: #1e293b;
}

[data-theme="light"] .chatbot-input:focus {
    border-color: #B8860B;
}

[data-theme="light"] .chatbot-input::placeholder {
    color: #9ca3af;
}

/* ── AI Tour Light Theme ── */
[data-theme="light"] .ai-tour-tooltip {
    background: #ffffff;
    border-color: rgba(184, 134, 11, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .ai-tour-tooltip p {
    color: #475569;
}

[data-theme="light"] .ai-tour-dots .dot {
    background: #d1d5db;
}
