/* ═══════════════════════════════════════════════════════════════════
   Chat Widget — Floating bottom-right chat panel
   ═══════════════════════════════════════════════════════════════════ */

.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary, #006233);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 98, 51, 0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(0, 98, 51, 0.5);
}
.chat-fab .chat-close { display: none; }
.chat-fab.active .chat-icon { display: none; }
.chat-fab.active .chat-close { display: block; }

.chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border, #e5e7eb);
}
.chat-panel.open {
    display: flex;
}

.chat-header {
    background: var(--primary, #006233);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.chat-header-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.chat-header-info h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}
.chat-header-info small {
    opacity: 0.8;
    font-size: 12px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg, #f5f6fa);
}

.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.chat-msg.bot {
    background: #fff;
    color: var(--text, #1a1a2e);
    border: 1px solid var(--border, #e5e7eb);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.chat-msg.user {
    background: var(--primary, #006233);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.chat-msg strong { font-weight: 700; }

.chat-typing {
    align-self: flex-start;
    display: none;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}
.chat-typing.show { display: flex; }
.chat-typing span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border, #e5e7eb);
    display: flex;
    gap: 8px;
    background: #fff;
    flex-shrink: 0;
}
.chat-input {
    flex: 1;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    resize: none;
    min-height: 42px;
    max-height: 100px;
}
.chat-input:focus {
    border-color: var(--primary, #006233);
}
.chat-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary, #006233);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: background 0.2s;
}
.chat-send:hover { background: var(--primary-dark, #004d26); }
.chat-send:disabled { background: #9ca3af; cursor: not-allowed; }

/* Confirm/Cancel action buttons */
.chat-confirm-row {
    display: flex;
    gap: 8px;
    align-self: flex-end;
    margin-top: 4px;
}
.chat-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.2s, transform 0.1s;
}
.chat-btn:hover { transform: scale(1.05); }
.chat-btn-confirm {
    background: var(--success, #059669);
    color: #fff;
}
.chat-btn-confirm:hover { background: #047857; }
.chat-btn-cancel {
    background: var(--danger, #dc2626);
    color: #fff;
}
.chat-btn-cancel:hover { background: #b91c1c; }

/* Mobile responsive */
@media (max-width: 600px) {
    .chat-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
    .chat-fab {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
        font-size: 20px;
    }
}
