/* =====================================================================
   FGMS – Floating Chatbot Styles
   ===================================================================== */

/* ── Toggle Button ────────────────────────────────────────────────── */
#fgmsChatToggle {
    position: fixed;
    bottom: 158px;
    right: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d3b6e 0%, #1a5fa8 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(13, 59, 110, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    outline: none;
}
#fgmsChatToggle:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 32px rgba(13, 59, 110, 0.55);
}
#fgmsChatToggle .chat-toggle-icon,
#fgmsChatToggle .chat-close-icon {
    font-size: 22px;
    color: #fff;
    transition: opacity 0.2s, transform 0.2s;
    position: absolute;
}
#fgmsChatToggle .chat-close-icon { opacity: 0; transform: rotate(-90deg); }
#fgmsChatToggle.is-open .chat-toggle-icon { opacity: 0; transform: rotate(90deg); }
#fgmsChatToggle.is-open .chat-close-icon  { opacity: 1; transform: rotate(0); }

/* Pulse ring */
#fgmsChatToggle::before {
    content: '';
    position: absolute;
    width: 58px; height: 58px;
    border-radius: 50%;
    background: rgba(13, 59, 110, 0.3);
    animation: chatPulse 2s infinite;
}
#fgmsChatToggle.is-open::before { display: none; }
@keyframes chatPulse {
    0%   { transform: scale(1);   opacity: 0.7; }
    70%  { transform: scale(1.5); opacity: 0; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Unread badge */
#chatUnreadBadge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px; height: 20px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
    transition: transform 0.2s;
}

/* ── Chat Window ──────────────────────────────────────────────────── */
#fgmsChatWindow {
    position: fixed;
    bottom: 228px;
    right: 24px;
    width: 370px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 180px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    z-index: 9997;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
    transform-origin: bottom right;
}
#fgmsChatWindow.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ───────────────────────────────────────────────────────── */
.chat-header {
    background: linear-gradient(135deg, #0d3b6e 0%, #1a5fa8 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.chat-avatar {
    width: 40px; height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
    position: relative;
}
.chat-avatar::after {
    content: '';
    position: absolute;
    bottom: 1px; right: 1px;
    width: 10px; height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #1a5fa8;
}
.chat-header-info { flex: 1; }
.chat-header-name {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}
.chat-header-status {
    font-size: 11px;
    color: rgba(255,255,255,0.8);
}
.chat-header-actions { display: flex; gap: 8px; }
.chat-hbtn {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 8px;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}
.chat-hbtn:hover { background: rgba(255,255,255,0.25); }

/* ── Quick Topics ─────────────────────────────────────────────────── */
.chat-quick-topics {
    background: #f0f4f9;
    padding: 8px 12px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.chat-topic-pill {
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 99px;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #0d3b6e;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    user-select: none;
}
.chat-topic-pill:hover {
    background: #0d3b6e;
    color: #fff;
    border-color: #0d3b6e;
}

/* ── Messages ─────────────────────────────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }

/* Bot message */
.chat-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: msgSlideIn 0.25s ease;
}
@keyframes msgSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chat-msg-bot { align-self: flex-start; }
.chat-msg-user { align-self: flex-end; flex-direction: row-reverse; }

.chat-msg-avatar {
    width: 28px; height: 28px;
    background: #0d3b6e;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    color: #fff;
    flex-shrink: 0;
}
.chat-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.55;
    color: #1e293b;
}
.chat-msg-bot  .chat-bubble { background: #f1f5f9; border-bottom-left-radius: 4px; }
.chat-msg-user .chat-bubble { background: #0d3b6e; color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble a { color: #f59e0b; text-decoration: underline; }
.chat-msg-user .chat-bubble a { color: #ffd166; }

/* Options inside bubble */
.chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.chat-opt-btn {
    background: #fff;
    border: 1.5px solid #cbd5e1;
    border-radius: 99px;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #0d3b6e;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.chat-opt-btn:hover {
    background: #0d3b6e;
    color: #fff;
    border-color: #0d3b6e;
}

/* Typing indicator */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
}
.chat-typing-dots {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    padding: 10px 14px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}
.chat-typing-dots span {
    width: 7px; height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingBounce 1.2s infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-6px); }
}

/* ── Input Area ───────────────────────────────────────────────────── */
.chat-input-wrap {
    border-top: 1px solid #e2e8f0;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    flex-shrink: 0;
}
#chatInput {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 99px;
    padding: 9px 16px;
    font-family: inherit;
    font-size: 13.5px;
    color: #1e293b;
    outline: none;
    transition: border-color 0.2s;
    background: #f8fafc;
}
#chatInput:focus {
    border-color: #0d3b6e;
    background: #fff;
}
#chatInput::placeholder { color: #94a3b8; }
#chatSendBtn {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d3b6e, #1a5fa8);
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 15px;
    transition: transform 0.2s, opacity 0.2s;
    flex-shrink: 0;
}
#chatSendBtn:hover { transform: scale(1.1); }
#chatSendBtn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.chat-input-hint {
    text-align: center;
    font-size: 10px;
    color: #94a3b8;
    padding: 0 12px 8px;
    flex-shrink: 0;
    background: #fff;
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #fgmsChatWindow {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
    }
    #fgmsChatToggle {
        bottom: 148px;
        right: 18px;
    }
}
