:root {
    --brand: #2f5597;
    --brand-dark: #1f3d70;
    --brand-light: #eef2fa;
    --surface: #ffffff;
    --body-bg: #f4f7fc;
    --text: #263042;
    --text-muted: #6b7690;
    --border: #e1e6ef;

    --voice-listen: #e8a33d;
    --voice-listen-soft: rgba(232, 163, 61, 0.16);
    --voice-speak: #3fb8af;
    --voice-speak-soft: rgba(63, 184, 175, 0.16);
    --voice-error: #e8615d;
}

/* FLOATING BUTTON */
.chatbot-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    background: linear-gradient(145deg, var(--brand), var(--brand-dark));
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(31, 61, 112, 0.32);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 1200;
}

.chatbot-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(31, 61, 112, 0.38);
}

.chatbot-button img {
    width: 55%;
    height: 55%;
    position: relative;
    z-index: 1;
}

.chatbot-ping {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--voice-speak);
    border: 2px solid #fff;
}

@media (prefers-reduced-motion: no-preference) {
    .chatbot-ping::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: 50%;
        background: var(--voice-speak);
        animation: pingPulse 2.2s ease-out infinite;
    }
}

@keyframes pingPulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(2.4); opacity: 0; }
}

/* CHAT CONTAINER */
.chatbot-container {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 340px;
    height: 540px;
    background: var(--surface);
    border-radius: 18px;
    display: none;
    flex-direction: column;
    border: 1px solid var(--border);
    box-shadow: 0 20px 48px rgba(20, 30, 60, 0.22);
    overflow: hidden;
    z-index: 1200;
}

@media (prefers-reduced-motion: no-preference) {
    .chatbot-container.open {
        animation: chatIn 0.22s ease;
    }
}

@keyframes chatIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* HEADER */
.chat-header {
    background: linear-gradient(120deg, var(--brand), var(--brand-dark));
    color: #fff;
    padding: 14px 14px 14px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
}

.chat-avatar.small {
    width: 26px;
    height: 26px;
    font-size: 12px;
    background: var(--brand-light);
    color: var(--brand);
    border: 1px solid var(--border);
    margin-top: 2px;
}

.chat-title {
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.2;
}

.chat-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #63e6a3;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.24); }

.icon-btn[aria-pressed="false"] {
    background: rgba(232, 97, 93, 0.35);
}

/* BODY */
.chat-body {
    flex: 1;
    padding: 14px 12px;
    overflow-y: auto;
    background: var(--body-bg);
    display: flex;
    flex-direction: column;
}

/* MESSAGE ROWS */
.bot-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 6px 0;
    max-width: 100%;
}

@media (prefers-reduced-motion: no-preference) {
    .bot-row, .user-msg {
        animation: msgIn 0.18s ease;
    }
}

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

.bot-msg {
    background: var(--surface);
    padding: 10px 13px;
    border-radius: 4px 14px 14px 14px;
    border: 1px solid var(--border);
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text);
    max-width: 78%;
    box-shadow: 0 1px 2px rgba(20, 30, 60, 0.04);
}

.user-msg {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    padding: 10px 13px;
    margin: 6px 0;
    border-radius: 14px 4px 14px 14px;
    text-align: left;
    margin-left: auto;
    font-size: 13.5px;
    line-height: 1.5;
    max-width: 78%;
}

/* TYPING INDICATOR */
.typing-dots {
    display: inline-flex;
    gap: 4px;
    padding: 2px 0;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.6;
}

@media (prefers-reduced-motion: no-preference) {
    .typing-dots span { animation: dotBounce 1.1s infinite ease-in-out; }
    .typing-dots span:nth-child(2) { animation-delay: 0.15s; }
    .typing-dots span:nth-child(3) { animation-delay: 0.3s; }
}

@keyframes dotBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* FAQ */
.faq-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-left: 34px;
}

.faq-buttons button {
    background: var(--brand-light);
    border: 1px solid rgba(47, 85, 151, 0.16);
    color: var(--brand-dark);
    padding: 6px 11px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.faq-buttons button:hover {
    background: #dfe7f7;
    transform: translateY(-1px);
}

/* LANGUAGE SWITCH */
.lang-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    font-size: 11.5px;
}

.lang-label { color: var(--text-muted); font-weight: 600; }

.lang-btn {
    background: var(--body-bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.lang-btn.active {
    background: var(--voice-listen-soft);
    border-color: var(--voice-listen);
    color: #93600f;
}

/* INPUT */
.chat-input {
    display: flex;
    align-items: center;
    gap: 6px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 8px;
}

.chat-input input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 11px;
    font-size: 13.5px;
    background: var(--body-bg);
    color: var(--text);
    min-width: 0;
}

.chat-input input:focus-visible,
.icon-btn:focus-visible,
.lang-btn:focus-visible,
.mic-btn:focus-visible,
.faq-buttons button:focus-visible,
.chat-input button:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.chat-input > button {
    background: var(--brand);
    color: white;
    border: none;
    padding: 9px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.chat-input > button:hover { background: var(--brand-dark); }

/* MIC BUTTON */
.mic-btn {
    position: relative;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--body-bg);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.mic-icon { width: 17px; height: 17px; position: relative; z-index: 1; }

.mic-btn:hover { background: #e9edf6; }

.mic-ring {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--voice-listen);
    opacity: 0;
    transform: scale(0.8);
}

.mic-btn.listening {
    background: var(--voice-listen-soft);
    border-color: var(--voice-listen);
    color: #93600f;
}

.mic-btn.listening .mic-ring {
    opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
    .mic-btn.listening .mic-ring { animation: micPulse 1.4s ease-out infinite; }
}

@keyframes micPulse {
    0% { transform: scale(0.85); opacity: 0.7; }
    100% { transform: scale(1.5); opacity: 0; }
}

.mic-btn.speaking {
    background: var(--voice-speak-soft);
    border-color: var(--voice-speak);
    color: #1f7d76;
}

.mic-btn.unsupported {
    display: none;
}

.mic-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* SYSTEM / ERROR NOTICE INSIDE CHAT */
.chat-notice {
    align-self: center;
    background: rgba(232, 97, 93, 0.1);
    border: 1px solid rgba(232, 97, 93, 0.3);
    color: #a83f3c;
    font-size: 11.5px;
    padding: 6px 10px;
    border-radius: 8px;
    margin: 6px 0;
    text-align: center;
}

/* MOBILE */
@media (max-width: 768px) {
    .chatbot-container {
        right: 10px;
        left: 10px;
        width: auto;
        height: 70vh;
    }
    .faq-buttons { padding-left: 0; }
}
