/* ═══════════════════════════════════════════════════════════════
   STAY AI CHAT WIDGET
   ═══════════════════════════════════════════════════════════════ */

/* ── FAB (Floating Action Button) ─────────────────────────── */
.chat-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(16, 185, 129, 0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.5);
}

.chat-fab-icon-close { display: none; }
#stay-chat-widget.open .chat-fab-icon-open { display: none; }
#stay-chat-widget.open .chat-fab-icon-close { display: block; }

/* Pulse ring */
.chat-fab-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(16, 185, 129, 0.4);
    animation: chatPulse 2s ease-out infinite;
}

#stay-chat-widget.open .chat-fab-pulse { display: none; }

@keyframes chatPulse {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* ── Chat Panel ───────────────────────────────────────────── */
.chat-panel {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 380px;
    height: 540px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ── Header ───────────────────────────────────────────────── */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #2C2E83 0%, #1470B8 100%);
    color: white;
    flex-shrink: 0;
}

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

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.chat-header-title {
    font-weight: 700;
    font-size: 0.95rem;
}

.chat-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    opacity: 0.8;
}

.chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
}

.chat-status-dot.thinking {
    animation: dotBlink 0.8s ease-in-out infinite;
}

@keyframes dotBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.chat-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ── Messages Area ────────────────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Welcome screen */
.chat-welcome {
    text-align: center;
    padding: 24px 12px;
}

.chat-welcome-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2C2E83, #009FE3);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin: 0 auto 16px;
}

.chat-welcome h4 {
    font-size: 1.1rem;
    color: #1e293b;
    margin-bottom: 6px;
}

.chat-welcome p {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 20px;
}

.chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-suggestion-btn {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 0.85rem;
    color: #1470B8;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.chat-suggestion-btn:hover {
    background: #eef6ff;
    border-color: #1470B8;
}

/* ── Message Bubbles ──────────────────────────────────────── */
.chat-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: msgFadeIn 0.3s ease;
}

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

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

.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2C2E83, #1470B8);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.chat-msg-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.55;
    word-break: break-word;
}

.chat-msg-user .chat-msg-bubble {
    background: linear-gradient(135deg, #1470B8, #2C2E83);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg-assistant .chat-msg-bubble {
    background: white;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

/* ── Typing indicator ─────────────────────────────────────── */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typingBounce 1.2s ease-in-out infinite;
}

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

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

/* ── Input Area ───────────────────────────────────────────── */
.chat-input-area {
    padding: 12px 16px 14px;
    background: white;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.chat-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    transition: border-color 0.2s;
}

.chat-input-wrap:focus-within {
    border-color: #1470B8;
    box-shadow: 0 0 0 3px rgba(20, 112, 184, 0.08);
}

#chatInput {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.88rem;
    color: #1e293b;
    outline: none;
    font-family: inherit;
    padding: 8px 0;
}

#chatInput::placeholder {
    color: #94a3b8;
}

.chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
}

.chat-send:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.chat-powered {
    text-align: center;
    font-size: 0.65rem;
    color: #cbd5e1;
    margin-top: 8px;
    letter-spacing: 0.03em;
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 480px) {
    .chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .chat-fab {
        bottom: 20px;
        right: 20px;
        width: 54px;
        height: 54px;
        font-size: 1.2rem;
    }
}
