/**
 * Frontline Aide — AI Chat Widget Styles
 * Floating chat bubble for frontlineaide.com visitors.
 * @version 2.4.1
 */

/* ── Container ── */
#fla-chat-container {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

#fla-chat-container[data-position="bottom-left"] {
    right: auto;
    left: 0;
}

/* ── Toggle Button ── */
#fla-chat-toggle {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--fla-chat-color, #1e5a8e);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
    z-index: 999999 !important;
    visibility: visible !important;
    opacity: 1 !important;
    animation: fla-chat-bounce-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.8s both;
}

#fla-chat-container[data-position="bottom-left"] #fla-chat-toggle {
    right: auto;
    left: 28px;
    bottom: 100px;
}

#fla-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 32px rgba(0, 0, 0, 0.3);
}

#fla-chat-toggle:active {
    transform: scale(0.95);
}

#fla-chat-toggle.fla-chat-hidden {
    transform: scale(0) !important;
    opacity: 0 !important;
    pointer-events: none;
}

#fla-chat-toggle svg {
    color: #fff;
}

/* Notification dot */
#fla-chat-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: fla-chat-pulse 2s infinite;
}

@keyframes fla-chat-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

@keyframes fla-chat-bounce-in {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ── Chat Panel ── */
#fla-chat-panel {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 380px;
    height: 540px;
    max-height: calc(100vh - 60px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0) translateY(20px);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s;
    z-index: 999999 !important;
}

#fla-chat-container[data-position="bottom-left"] #fla-chat-panel {
    right: auto;
    left: 28px;
    bottom: 100px;
    transform-origin: bottom left;
}

#fla-chat-panel.fla-chat-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ── Header ── */
#fla-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    background: var(--fla-chat-color, #1e5a8e);
    color: #fff;
    flex-shrink: 0;
}

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

#fla-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

#fla-chat-avatar svg {
    color: #fff;
}

#fla-chat-title {
    display: block;
    font-size: 15px;
    font-weight: 700;
}

#fla-chat-subtitle {
    display: block;
    font-size: 12px;
    opacity: 0.8;
}

#fla-chat-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
}

#fla-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ── Status Bar ── */
#fla-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: #f0f4f8;
    border-bottom: 1px solid #e2e8f0;
    font-size: 11px;
    color: #64748b;
    flex-shrink: 0;
}

#fla-chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    flex-shrink: 0;
}

#fla-chat-status-dot.fla-chat-typing {
    background: #f59e0b;
    animation: fla-chat-blink-dot 0.8s infinite;
}

@keyframes fla-chat-blink-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ── Messages ── */
#fla-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

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

#fla-chat-messages::-webkit-scrollbar-thumb {
    background: #d0d7de;
    border-radius: 10px;
}

/* ── Message Bubbles ── */
.fla-chat-msg {
    display: flex;
    max-width: 88%;
    animation: fla-chat-msg-in 0.25s ease-out;
}

@keyframes fla-chat-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.fla-chat-user {
    align-self: flex-end;
}

.fla-chat-bot {
    align-self: flex-start;
}

.fla-chat-bubble {
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.fla-chat-user .fla-chat-bubble {
    background: var(--fla-chat-color, #1e5a8e);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
}

.fla-chat-bot .fla-chat-bubble {
    background: #f1f5f9;
    color: #1e293b;
    border-radius: 18px 18px 18px 4px;
    border: 1px solid #e2e8f0;
}

.fla-chat-bubble strong {
    font-weight: 600;
    color: var(--fla-chat-color, #1e5a8e);
}

.fla-chat-bubble code {
    background: #e2e8f0;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
    color: #c7254e;
}

.fla-chat-cursor {
    display: inline;
    animation: fla-chat-cursor-blink 0.6s infinite;
    color: var(--fla-chat-color, #1e5a8e);
    font-weight: 400;
}

@keyframes fla-chat-cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ── Suggested Questions ── */
#fla-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
}

.fla-suggestion-chip {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--fla-chat-color, #1e5a8e);
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.fla-suggestion-chip:hover {
    background: var(--fla-chat-color, #1e5a8e);
    color: #fff;
    border-color: var(--fla-chat-color, #1e5a8e);
}

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

#fla-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f4f5f7;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 8px 10px 8px 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#fla-chat-input-wrap:focus-within {
    border-color: var(--fla-chat-color, #1e5a8e);
    box-shadow: 0 0 0 3px rgba(30, 90, 142, 0.1);
    background: #fff;
}

#fla-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    padding: 0;
    min-height: 22px;
    max-height: 100px;
    font-family: inherit;
    color: #1e293b;
}

#fla-chat-input::placeholder {
    color: #94a3b8;
}

#fla-chat-send {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--fla-chat-color, #1e5a8e);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    padding: 0;
}

#fla-chat-send:hover:not(:disabled) {
    opacity: 0.85;
}

#fla-chat-send:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

#fla-chat-send svg {
    color: #fff;
}

#fla-chat-footer-text {
    font-size: 10px;
    color: #94a3b8;
    text-align: center;
    margin-top: 6px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    /* On mobile: no animation delay, appear instantly so avoidance can position above cookie banner */
    #fla-chat-toggle {
        bottom: 80px;
        right: 16px;
        width: 52px;
        height: 52px;
        animation: none !important;
    }

    #fla-chat-container[data-position="bottom-left"] #fla-chat-toggle {
        right: auto;
        left: 16px;
        bottom: 80px;
    }

    #fla-chat-panel {
        bottom: 80px;
        right: 8px;
        left: 8px;
        width: calc(100vw - 16px);
        height: calc(100vh - 120px);
        border-radius: 16px;
        max-height: none;
        transform-origin: bottom center;
    }

    #fla-chat-container[data-position="bottom-left"] #fla-chat-panel {
        left: 8px;
        right: 8px;
        bottom: 80px;
    }
}

/* Small phones */
@media (max-width: 380px) {
    #fla-chat-toggle {
        bottom: 76px;
        width: 48px;
        height: 48px;
    }

    #fla-chat-panel {
        bottom: 76px;
        height: calc(100vh - 100px);
    }
}
