/* ── Flood Sentinel Chat Widget ─────────────────────────────────────── */

/* Floating action button */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-primary, #1557b0);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
    background: var(--accent-hover, #1248a0);
}
.chat-fab:active {
    transform: scale(0.95);
}
.chat-fab svg {
    width: 26px;
    height: 26px;
    fill: white;
}
.chat-fab.active {
    background: var(--text-muted, #666);
}

/* Chat panel */
.chat-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 370px;
    height: 520px;
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-primary, #e0e0e0);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
    z-index: 1049;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.25s ease, transform 0.25s ease;
    transform-origin: bottom right;
}
.chat-panel.hidden {
    display: none;
    opacity: 0;
    transform: scale(0.9) translateY(10px);
}
.chat-panel.visible {
    display: flex;
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--accent-primary, #1557b0);
    color: white;
    flex-shrink: 0;
}
.chat-header span {
    font-weight: 600;
    font-size: 0.92rem;
    letter-spacing: 0.01em;
}
.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.15s;
    padding: 0 2px;
    line-height: 1;
}
.chat-close:hover {
    opacity: 1;
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-messages::-webkit-scrollbar {
    width: 5px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-primary, #ccc);
    border-radius: 3px;
}

/* Message bubbles */
.chat-msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.chat-msg.assistant {
    background: var(--bg-secondary, #f4f4f5);
    color: var(--text-primary, #1a1a1a);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.chat-msg.user {
    background: var(--accent-primary, #1557b0);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Source badges */
.chat-sources {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.chat-source-badge {
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 10px;
    background: var(--accent-primary, #1557b0);
    color: white;
    opacity: 0.7;
    font-weight: 500;
}

/* Suggestion chips */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
}
.chat-chip {
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid var(--border-primary, #d0d5dd);
    background: var(--bg-primary, #ffffff);
    color: var(--accent-primary, #1557b0);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.chat-chip:hover {
    background: var(--accent-primary, #1557b0);
    color: white;
    border-color: var(--accent-primary, #1557b0);
}

/* Input area */
.chat-input {
    display: flex;
    padding: 12px;
    border-top: 1px solid var(--border-primary, #e0e0e0);
    gap: 8px;
    flex-shrink: 0;
    background: var(--card-bg, #ffffff);
}
.chat-input input {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid var(--border-primary, #d0d5dd);
    border-radius: 10px;
    font-size: 0.88rem;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #1a1a1a);
    outline: none;
    transition: border-color 0.15s;
}
.chat-input input:focus {
    border-color: var(--accent-primary, #1557b0);
}
.chat-input input::placeholder {
    color: var(--text-muted, #999);
}
#chat-send {
    padding: 9px 16px;
    border: none;
    border-radius: 10px;
    background: var(--accent-primary, #1557b0);
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
#chat-send:hover {
    background: var(--accent-hover, #1248a0);
}
#chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Typing indicator */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
}
.chat-typing .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted, #999);
    animation: chatTyping 1.4s infinite;
}
.chat-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTyping {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* Confidence indicator */
.chat-confidence {
    font-size: 0.7rem;
    margin-top: 4px;
    opacity: 0.6;
}
.chat-confidence.high { color: var(--risk-normal, #34a853); }
.chat-confidence.medium { color: var(--risk-minor, #fbbc04); }
.chat-confidence.low { color: var(--risk-moderate, #f9ab00); }

/* ── Responsive: full-width on mobile ────────────────────────────────── */
@media (max-width: 480px) {
    .chat-panel {
        width: calc(100vw - 16px);
        height: calc(100vh - 120px);
        bottom: 80px;
        right: 8px;
        border-radius: 12px;
    }
    .chat-fab {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
    }
}
