/* ─── Sakani AI Chatbot ─────────────────────────────────────── */

/* Hide page scrollbar (scroll still works via mouse/touch) */
html {
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE / Edge */
}
html::-webkit-scrollbar {
    display: none;               /* Chrome / Safari */
}

/* Floating Button */
#sakani-chat-btn {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.5);
    z-index: 9000;
    transition: transform 0.3s, box-shadow 0.3s;
    animation: chatPulse 2.5s infinite;
}
#sakani-chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.7);
}
#sakani-chat-btn i {
    font-size: 1.5rem;
    color: #fff;
}
@keyframes chatPulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(99,102,241,0.5); }
    50% { box-shadow: 0 8px 48px rgba(99,102,241,0.85); }
}

/* Badge */
#chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 0.65rem;
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: badgeBounce 1s ease infinite alternate;
}
@keyframes badgeBounce {
    from { transform: scale(1); }
    to   { transform: scale(1.25); }
}

/* Chat Window */
#sakani-chat-window {
    position: fixed;
    bottom: 165px;
    right: 24px;
    width: 370px;
    max-height: 580px;
    background: var(--bg-card, #1e1e2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    z-index: 9001;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(.34,1.56,.64,1), opacity 0.3s;
    overflow: hidden;
}
#sakani-chat-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.chat-header-info { flex: 1; }
.chat-header-info h4 {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 2px;
}
.chat-status {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    gap: 5px;
}
.chat-status::before {
    content: '';
    width: 7px; height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: blink 1.4s infinite;
}
@keyframes blink {
    0%,100% { opacity: 1; } 50% { opacity: 0.3; }
}
.chat-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 30px; height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.chat-close:hover { background: rgba(255,255,255,0.35); }

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color, rgba(255,255,255,0.15));
    border-radius: 4px;
}

/* Bubbles */
.chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.55;
    animation: bubbleIn 0.3s ease;
    word-break: break-word;
}
@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chat-bubble.bot {
    background: var(--bg-surface, rgba(255,255,255,0.05));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    color: var(--text-primary, #fff);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.chat-bubble.user {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
    display: flex; align-items: center; gap: 4px;
    padding: 12px 16px;
    background: var(--bg-surface, rgba(255,255,255,0.05));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
}
.typing-indicator span {
    width: 7px; height: 7px;
    background: var(--text-muted, #888);
    border-radius: 50%;
    animation: typing 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%,60%,100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Quick reply chips */
.chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    align-self: flex-start;
    max-width: 100%;
}
.chip {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid #6366f1;
    color: #6366f1;
    background: transparent;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.2s;
    font-family: inherit;
}
.chip:hover {
    background: #6366f1;
    color: #fff;
    transform: translateY(-1px);
}

/* Result cards inside chat */
.chat-result-card {
    background: var(--bg-surface, rgba(255,255,255,0.04));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 12px;
    padding: 12px;
    margin-top: 4px;
    align-self: flex-start;
    width: 100%;
    max-width: 310px;
    animation: bubbleIn 0.3s ease;
}
.chat-result-card h5 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary, #fff);
    margin: 0 0 6px;
    line-height: 1.4;
}
.chat-result-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.chat-result-meta span {
    font-size: 0.75rem;
    color: var(--text-secondary, #aaa);
    display: flex;
    align-items: center;
    gap: 4px;
}
.chat-result-meta span i { color: #6366f1; }
.chat-result-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: #6366f1;
    margin-bottom: 8px;
}
.chat-result-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: #25D366;
    color: #fff;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s;
}
.chat-result-btn:hover { opacity: 0.85; }
.chat-result-view {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--primary-color, #6366f1);
    color: #fff;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    margin-right: 6px;
    transition: opacity 0.2s;
    font-family: inherit;
}
.chat-result-view:hover { opacity: 0.85; }

/* Input area */
.chat-input-area {
    padding: 12px 14px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.1));
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    background: var(--bg-card, #1e1e2e);
}
#chat-input {
    flex: 1;
    background: var(--bg-surface, rgba(255,255,255,0.05));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 12px;
    padding: 10px 14px;
    color: var(--text-primary, #fff);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
}
#chat-input:focus { border-color: #6366f1; }
#chat-input::placeholder { color: var(--text-muted, #666); }
#chat-send {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.2s, transform 0.2s;
    flex-shrink: 0;
}
#chat-send:hover { opacity: 0.85; transform: scale(1.05); }

/* RTL support – button/window stay on RIGHT to avoid scrollbar conflict */
[dir="rtl"] .chat-bubble.user { align-self: flex-start; border-radius: 16px; border-bottom-left-radius: 4px; border-bottom-right-radius: 16px; }
[dir="rtl"] .chat-bubble.bot  { align-self: flex-end;   border-radius: 16px; border-bottom-right-radius: 4px; border-bottom-left-radius: 16px; }
[dir="rtl"] .chat-chips { align-self: flex-end; }
[dir="rtl"] .chat-result-card { align-self: flex-end; }
[dir="rtl"] .typing-indicator { align-self: flex-end; border-radius: 16px; border-bottom-right-radius: 4px; }

/* Mobile */
@media (max-width: 480px) {
    #sakani-chat-window {
        right: 8px; left: 8px;
        width: auto;
        bottom: 155px;
    }
}
