/* ==========================================================================
   AI Helpdesk Chatbot - Combined Responsive Widget (Text & Voice)
   Namespace: .ai-chatbot-*
   ========================================================================== */

:root {
    --ai-chatbot-primary: #0f52ba;
    --ai-chatbot-primary-hover: #0a3d8f;
    --ai-chatbot-primary-light: rgba(15, 82, 186, 0.08);
    --ai-chatbot-secondary: #003366;
    --ai-chatbot-accent: #2563eb;
    --ai-chatbot-bg: #ffffff;
    --ai-chatbot-surface: #f8fafc;
    --ai-chatbot-card: #ffffff;
    --ai-chatbot-text: #0f172a;
    --ai-chatbot-text-muted: #64748b;
    --ai-chatbot-text-light: #94a3b8;
    --ai-chatbot-border: #e2e8f0;
    --ai-chatbot-user-bubble: #0f52ba;
    --ai-chatbot-user-text: #ffffff;
    --ai-chatbot-bot-bubble: #f1f5f9;
    --ai-chatbot-bot-text: #0f172a;
    --ai-chatbot-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --ai-chatbot-radius: 16px;
    --ai-chatbot-shadow: 0 20px 35px -10px rgba(15, 23, 42, 0.18), 0 10px 15px -5px rgba(15, 23, 42, 0.08);
    --ai-chatbot-z-index: 2147483640;
    --ai-chatbot-pulse: #3b82f6;
}

[data-ai-theme="dark"] {
    --ai-chatbot-bg: #0f172a;
    --ai-chatbot-surface: #1e293b;
    --ai-chatbot-card: #1e293b;
    --ai-chatbot-text: #f8fafc;
    --ai-chatbot-text-muted: #94a3b8;
    --ai-chatbot-text-light: #64748b;
    --ai-chatbot-border: #334155;
    --ai-chatbot-bot-bubble: #1e293b;
    --ai-chatbot-bot-text: #f8fafc;
    --ai-chatbot-user-bubble: #2563eb;
    --ai-chatbot-user-text: #ffffff;
    --ai-chatbot-primary-light: rgba(37, 99, 235, 0.15);
    --ai-chatbot-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.45);
}

/* Base Widget Container */
.ai-chatbot-container {
    position: fixed;
    z-index: var(--ai-chatbot-z-index);
    font-family: var(--ai-chatbot-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ai-chatbot-text);
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

.ai-chatbot-container *,
.ai-chatbot-container *::before,
.ai-chatbot-container *::after {
    box-sizing: border-box;
}

/* Widget Positions */
.ai-chatbot-container.pos-bottom-right {
    bottom: 24px;
    right: 24px;
}

.ai-chatbot-container.pos-bottom-left {
    bottom: 24px;
    left: 24px;
}

.ai-chatbot-container.pos-top-right {
    top: 24px;
    right: 24px;
}

.ai-chatbot-container.pos-top-left {
    top: 24px;
    left: 24px;
}

/* ==========================================================================
   Launcher Button
   ========================================================================== */
.ai-chatbot-launcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
    outline: none;
    user-select: none;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-chatbot-launcher:hover {
    transform: scale(1.05);
}

.ai-chatbot-launcher:active {
    transform: scale(0.95);
}

.ai-chatbot-launcher-label {
    background: var(--ai-chatbot-card);
    color: var(--ai-chatbot-text);
    padding: 8px 14px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 13px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    border: 1px solid var(--ai-chatbot-border);
    white-space: nowrap;
    animation: ai-slide-in 0.3s ease-out;
}

.ai-chatbot-launcher-icon {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: transparent;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.25s ease, box-shadow 0.25s ease;
    position: relative;
    overflow: visible;
    animation: ai-launcher-float 3.6s ease-in-out infinite;
}

.ai-chatbot-launcher-icon::before {
    content: '';
    position: absolute;
    inset: 5px;
    border: 2px solid rgba(99, 102, 241, 0.42);
    border-radius: 50%;
    pointer-events: none;
    animation: ai-launcher-ring 2.8s ease-out infinite;
}

.ai-chatbot-launcher-icon:hover {
    transform: scale(1.08);
    box-shadow: none;
}

.ai-chatbot-launcher-icon .ai-chatbot-launcher-img {
    width: 58px;
    height: 58px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 6px 10px rgba(49, 46, 129, 0.32));
    transition: transform 0.25s ease, opacity 0.2s ease;
    animation: ai-robot-breathe 2.4s ease-in-out infinite;
}

.ai-chatbot-launcher:hover .ai-chatbot-launcher-img {
    animation: none;
    transform: scale(1.1) rotate(-2deg);
}

.ai-chatbot-launcher:hover .ai-chatbot-launcher-icon {
    animation-play-state: paused;
}

.ai-chatbot-launcher-icon svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

.ai-chatbot-launcher-icon .icon-chat,
.ai-chatbot-launcher-icon .icon-close {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chatbot-launcher-icon .icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.8);
}

.ai-chatbot-container.is-open .ai-chatbot-launcher-icon .icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.8);
}

.ai-chatbot-container.is-open .ai-chatbot-launcher-icon .icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.ai-chatbot-container.is-open .ai-chatbot-launcher-icon {
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 50%, #4f46e5 100%);
    box-shadow: 0 8px 22px rgba(79, 70, 229, 0.34);
    overflow: hidden;
    animation: none;
}

.ai-chatbot-container.is-open .ai-chatbot-launcher-icon::before {
    display: none;
}

.ai-chatbot-container.is-open .ai-chatbot-launcher-img {
    animation: none;
}

.ai-chatbot-container.is-open .ai-chatbot-launcher-label {
    display: none;
}

/* ==========================================================================
   Chat Window Frame
   ========================================================================== */
.ai-chatbot-window {
    position: absolute;
    bottom: 76px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 620px;
    max-height: calc(100vh - 100px);
    background: var(--ai-chatbot-bg);
    border-radius: var(--ai-chatbot-radius);
    box-shadow: var(--ai-chatbot-shadow);
    border: 1px solid var(--ai-chatbot-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-chatbot-container.pos-bottom-right .ai-chatbot-window {
    right: 0;
    bottom: 70px;
    transform-origin: bottom right;
}

.ai-chatbot-container.pos-bottom-left .ai-chatbot-window {
    left: 0;
    bottom: 70px;
    transform-origin: bottom left;
}

.ai-chatbot-container.pos-top-right .ai-chatbot-window {
    right: 0;
    top: 70px;
    bottom: auto;
    transform-origin: top right;
}

.ai-chatbot-container.pos-top-left .ai-chatbot-window {
    left: 0;
    top: 70px;
    bottom: auto;
    transform-origin: top left;
}

.ai-chatbot-container.is-open .ai-chatbot-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ==========================================================================
   Header
   ========================================================================== */
.ai-chatbot-header {
    background: var(--ai-chatbot-card);
    border-bottom: 1px solid var(--ai-chatbot-border);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    user-select: none;
}

.ai-chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ai-chatbot-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--ai-chatbot-primary-light);
    color: var(--ai-chatbot-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid var(--ai-chatbot-border);
}

.ai-chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-chatbot-avatar svg {
    width: 20px;
    height: 20px;
}

.ai-chatbot-bot-info {
    min-width: 0;
}

.ai-chatbot-bot-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--ai-chatbot-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-chatbot-status-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.ai-chatbot-bot-subtitle {
    font-size: 11px;
    color: var(--ai-chatbot-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Mode Switcher Pill */
.ai-chatbot-mode-pill {
    display: flex;
    align-items: center;
    background: var(--ai-chatbot-surface);
    border: 1px solid var(--ai-chatbot-border);
    border-radius: 20px;
    padding: 2px;
}

.ai-chatbot-mode-btn {
    background: transparent;
    border: none;
    color: var(--ai-chatbot-text-muted);
    padding: 5px 9px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.ai-chatbot-mode-btn.active {
    background: var(--ai-chatbot-card);
    color: var(--ai-chatbot-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ai-chatbot-btn-icon {
    background: transparent;
    border: none;
    color: var(--ai-chatbot-text-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.ai-chatbot-btn-icon:hover {
    background: var(--ai-chatbot-surface);
    color: var(--ai-chatbot-text);
}

/* ==========================================================================
   Chat Body / Messages View
   ========================================================================== */
.ai-chatbot-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

.ai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

/* Welcome Card */
.ai-chatbot-welcome {
    background: var(--ai-chatbot-surface);
    border: 1px solid var(--ai-chatbot-border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 6px;
}

.ai-chatbot-welcome-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--ai-chatbot-text);
    margin-bottom: 4px;
}

.ai-chatbot-welcome-msg {
    font-size: 13px;
    color: var(--ai-chatbot-text-muted);
}

.ai-chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.ai-chatbot-chip {
    background: var(--ai-chatbot-card);
    border: 1px solid var(--ai-chatbot-border);
    color: var(--ai-chatbot-primary);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 14px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}

.ai-chatbot-chip:hover {
    background: var(--ai-chatbot-primary-light);
    border-color: var(--ai-chatbot-primary);
    transform: translateY(-1px);
}

/* Messages */
.ai-chatbot-msg-row {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: ai-msg-appear 0.2s ease-out;
}

.ai-chatbot-msg-row.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-chatbot-msg-row.bot {
    align-self: flex-start;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.ai-chatbot-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
    position: relative;
}

.ai-chatbot-msg-row.user .ai-chatbot-msg-bubble {
    background: var(--ai-chatbot-user-bubble);
    color: var(--ai-chatbot-user-text);
    border-bottom-right-radius: 4px;
}

.ai-chatbot-msg-row.bot .ai-chatbot-msg-bubble {
    background: var(--ai-chatbot-bot-bubble);
    color: var(--ai-chatbot-bot-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--ai-chatbot-border);
}

.ai-chatbot-msg-row.bot .ai-chatbot-msg-bubble p:first-child {
    margin-top: 0;
}

.ai-chatbot-msg-row.bot .ai-chatbot-msg-bubble p:last-child {
    margin-bottom: 0;
}

.ai-chatbot-msg-row.bot .ai-chatbot-msg-bubble a {
    color: var(--ai-chatbot-primary);
    text-decoration: underline;
}

.ai-chatbot-msg-row.bot .ai-chatbot-msg-bubble ul,
.ai-chatbot-msg-row.bot .ai-chatbot-msg-bubble ol {
    margin: 6px 0;
    padding-left: 20px;
}

.ai-chatbot-msg-row.bot .ai-chatbot-msg-bubble code {
    background: rgba(0, 0, 0, 0.08);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}

/* Citations Pill */
.ai-chatbot-citations {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--ai-chatbot-border);
}

.ai-chatbot-cite-badge {
    background: var(--ai-chatbot-card);
    border: 1px solid var(--ai-chatbot-border);
    color: var(--ai-chatbot-text-muted);
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: color 0.15s, border-color 0.15s;
}

.ai-chatbot-cite-badge:hover {
    color: var(--ai-chatbot-primary);
    border-color: var(--ai-chatbot-primary);
}

/* Message Actions (Feedback, Copy) */
.ai-chatbot-msg-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding-left: 4px;
}

.ai-chatbot-action-btn {
    background: transparent;
    border: none;
    color: var(--ai-chatbot-text-light);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: color 0.15s;
}

.ai-chatbot-action-btn:hover {
    color: var(--ai-chatbot-primary);
}

.ai-chatbot-action-btn.active {
    color: var(--ai-chatbot-primary);
    font-weight: 600;
}

/* Typing Indicator */
.ai-chatbot-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--ai-chatbot-bot-bubble);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    border: 1px solid var(--ai-chatbot-border);
}

.ai-chatbot-dot {
    width: 6px;
    height: 6px;
    background: var(--ai-chatbot-text-muted);
    border-radius: 50%;
    animation: ai-bounce 1.4s infinite ease-in-out both;
}

.ai-chatbot-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-chatbot-dot:nth-child(2) { animation-delay: -0.16s; }

/* ==========================================================================
   Chat Input Area
   ========================================================================== */
.ai-chatbot-input-area {
    padding: 10px 14px;
    background: var(--ai-chatbot-card);
    border-top: 1px solid var(--ai-chatbot-border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-chatbot-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--ai-chatbot-surface);
    border: 1px solid var(--ai-chatbot-border);
    border-radius: 20px;
    padding: 6px 10px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-chatbot-input-row:focus-within {
    border-color: var(--ai-chatbot-primary);
    box-shadow: 0 0 0 3px var(--ai-chatbot-primary-light);
}

.ai-chatbot-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--ai-chatbot-text);
    max-height: 120px;
    min-height: 22px;
    line-height: 1.4;
    padding: 2px 4px;
}

.ai-chatbot-textarea::placeholder {
    color: var(--ai-chatbot-text-muted);
}

.ai-chatbot-send-btn,
.ai-chatbot-voice-shortcut-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.ai-chatbot-voice-shortcut-btn {
    background: transparent;
    color: var(--ai-chatbot-text-muted);
}

.ai-chatbot-voice-shortcut-btn:hover {
    background: var(--ai-chatbot-primary-light);
    color: var(--ai-chatbot-primary);
}

.ai-chatbot-send-btn {
    background: var(--ai-chatbot-primary);
    color: #ffffff;
}

.ai-chatbot-send-btn:hover {
    background: var(--ai-chatbot-primary-hover);
    transform: scale(1.05);
}

.ai-chatbot-send-btn:disabled {
    background: var(--ai-chatbot-border);
    color: var(--ai-chatbot-text-light);
    cursor: not-allowed;
    transform: none;
}

.ai-chatbot-privacy {
    font-size: 11px;
    color: var(--ai-chatbot-text-light);
    text-align: center;
}

.ai-chatbot-privacy a {
    color: inherit;
    text-decoration: underline;
}

/* ==========================================================================
   Voice Mode View (Live Call)
   ========================================================================== */
.ai-chatbot-voice-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 30px 24px 24px;
    background: radial-gradient(circle at center 40%, var(--ai-chatbot-surface) 0%, var(--ai-chatbot-bg) 100%);
    position: relative;
    overflow: hidden;
}

.ai-chatbot-voice-status-wrap {
    text-align: center;
}

.ai-chatbot-voice-status {
    font-size: 16px;
    font-weight: 600;
    color: var(--ai-chatbot-text);
    margin-bottom: 4px;
}

.ai-chatbot-voice-hint {
    font-size: 12px;
    color: var(--ai-chatbot-text-muted);
}

/* Pulsing Voice Orb */
.ai-chatbot-voice-orb-wrap {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 30px 0;
}

.ai-chatbot-voice-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--ai-chatbot-pulse);
    opacity: 0.2;
    transform: scale(0.9);
}

.ai-chatbot-voice-view.is-listening .ai-chatbot-voice-ring {
    animation: ai-pulse 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

.ai-chatbot-voice-view.is-speaking .ai-chatbot-voice-ring {
    animation: ai-pulse-speaking 1s ease-in-out infinite alternate;
    opacity: 0.4;
    border-color: #10b981;
}

.ai-chatbot-voice-orb {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-chatbot-primary) 0%, var(--ai-chatbot-accent) 100%);
    box-shadow: 0 10px 25px rgba(15, 82, 186, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-chatbot-voice-view.is-speaking .ai-chatbot-voice-orb {
    transform: scale(1.1);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.45);
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.ai-chatbot-voice-orb svg {
    width: 36px;
    height: 36px;
}

/* Realtime Transcript Captions Box */
.ai-chatbot-voice-captions {
    width: 100%;
    background: var(--ai-chatbot-card);
    border: 1px solid var(--ai-chatbot-border);
    border-radius: 12px;
    padding: 12px 14px;
    min-height: 70px;
    max-height: 110px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.4;
    color: var(--ai-chatbot-text);
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ai-chatbot-voice-captions .caption-speaker {
    font-weight: 600;
    font-size: 11px;
    color: var(--ai-chatbot-text-muted);
    text-transform: uppercase;
    margin-bottom: 2px;
}

/* Voice Call Controls Toolbar */
.ai-chatbot-voice-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ai-chatbot-voice-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s, background-color 0.15s;
}

.ai-chatbot-voice-btn:hover {
    transform: scale(1.08);
}

.ai-chatbot-voice-btn.btn-mute {
    background: var(--ai-chatbot-surface);
    color: var(--ai-chatbot-text);
    border: 1px solid var(--ai-chatbot-border);
}

.ai-chatbot-voice-btn.btn-mute.muted {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
}

.ai-chatbot-voice-btn.btn-end {
    background: #ef4444;
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.35);
}

.ai-chatbot-voice-btn.btn-switch-text {
    background: var(--ai-chatbot-surface);
    color: var(--ai-chatbot-text);
    border: 1px solid var(--ai-chatbot-border);
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes ai-slide-in {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes ai-msg-appear {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes ai-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@keyframes ai-pulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.35); opacity: 0; }
    100% { transform: scale(1.35); opacity: 0; }
}

@keyframes ai-pulse-speaking {
    0% { transform: scale(1); }
    100% { transform: scale(1.25); }
}

@keyframes ai-launcher-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes ai-launcher-ring {
    0% { opacity: 0.5; transform: scale(0.88); }
    70%, 100% { opacity: 0; transform: scale(1.28); }
}

@keyframes ai-robot-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

@media (prefers-reduced-motion: reduce) {
    .ai-chatbot-launcher,
    .ai-chatbot-launcher-label,
    .ai-chatbot-launcher-icon,
    .ai-chatbot-launcher-icon::before,
    .ai-chatbot-launcher-img {
        animation: none !important;
        transition: none !important;
    }
}

/* ==========================================================================
   Responsive / Mobile View (Fullscreen on phones)
   ========================================================================== */
@media (max-width: 640px) {
    .ai-chatbot-container.pos-bottom-right,
    .ai-chatbot-container.pos-bottom-left,
    .ai-chatbot-container.pos-top-right,
    .ai-chatbot-container.pos-top-left {
        bottom: 16px;
        right: 16px;
        left: auto;
        top: auto;
    }

    .ai-chatbot-container.is-open .ai-chatbot-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .ai-chatbot-header {
        padding-top: calc(14px + env(safe-area-inset-top, 0px));
    }

    .ai-chatbot-input-area {
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
}

/* ==========================================================================
   Proactive Chat Speech-Bubble Teaser
   ========================================================================== */
.ai-chatbot-proactive-teaser {
    position: absolute;
    bottom: calc(100% + 14px);
    right: 0;
    width: 290px;
    max-width: calc(100vw - 48px);
    background: var(--ai-chatbot-card);
    border: 1px solid var(--ai-chatbot-border);
    border-radius: 16px;
    box-shadow: var(--ai-chatbot-shadow);
    padding: 12px 14px;
    cursor: pointer;
    z-index: 10;
    transform-origin: bottom right;
    animation: ai-teaser-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.ai-chatbot-container.pos-bottom-left .ai-chatbot-proactive-teaser {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.ai-chatbot-proactive-teaser:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px -5px rgba(15, 23, 42, 0.22);
}

.ai-chatbot-proactive-teaser::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 24px;
    width: 14px;
    height: 14px;
    background: var(--ai-chatbot-card);
    border-right: 1px solid var(--ai-chatbot-border);
    border-bottom: 1px solid var(--ai-chatbot-border);
    transform: rotate(45deg);
}

.ai-chatbot-container.pos-bottom-left .ai-chatbot-proactive-teaser::after {
    right: auto;
    left: 24px;
}

.ai-chatbot-proactive-bubble {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.ai-chatbot-proactive-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--ai-chatbot-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chatbot-proactive-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-chatbot-proactive-text {
    flex: 1;
    font-size: 13px;
    line-height: 1.45;
    color: var(--ai-chatbot-text);
    font-weight: 500;
    word-break: break-word;
    padding-right: 14px;
}

.ai-chatbot-proactive-dismiss {
    position: absolute;
    top: 6px;
    right: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--ai-chatbot-text-muted);
    font-size: 16px;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 50%;
    transition: background 0.15s ease, color 0.15s ease;
}

.ai-chatbot-proactive-dismiss:hover {
    background: var(--ai-chatbot-primary-light);
    color: var(--ai-chatbot-text);
}

@keyframes ai-teaser-pop {
    0% {
        opacity: 0;
        transform: scale(0.85) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-chatbot-proactive-teaser {
        animation: none;
        transition: none;
    }
}

/* ==========================================================================
   High Contrast Accessibility Mode (WCAG AAA)
   ========================================================================== */
.ai-chatbot-container[data-ai-contrast="high"],
.ai-chatbot-container.ai-chatbot-high-contrast {
    --ai-chatbot-bg: #000000;
    --ai-chatbot-card: #000000;
    --ai-chatbot-card-muted: #111111;
    --ai-chatbot-border: #ffffff;
    --ai-chatbot-border-light: #ffffff;
    --ai-chatbot-text: #ffffff;
    --ai-chatbot-text-muted: #e0e0e0;
    --ai-chatbot-primary: #ffff00;
    --ai-chatbot-primary-hover: #ffff33;
    --ai-chatbot-primary-text: #000000;
    --ai-chatbot-shadow: none;
    --ai-chatbot-shadow-lg: none;
}

.ai-chatbot-container[data-ai-contrast="high"] .ai-chatbot-window,
.ai-chatbot-container.ai-chatbot-high-contrast .ai-chatbot-window {
    border: 3px solid #ffffff;
}

.ai-chatbot-container[data-ai-contrast="high"] .ai-chatbot-launcher,
.ai-chatbot-container.ai-chatbot-high-contrast .ai-chatbot-launcher {
    border: 2px solid #ffffff;
}

.ai-chatbot-container[data-ai-contrast="high"] .ai-chatbot-message-assistant,
.ai-chatbot-container.ai-chatbot-high-contrast .ai-chatbot-message-assistant {
    background: #000000;
    color: #ffffff;
    border: 2px solid #ffffff;
}

.ai-chatbot-container[data-ai-contrast="high"] .ai-chatbot-message-user,
.ai-chatbot-container.ai-chatbot-high-contrast .ai-chatbot-message-user {
    background: #ffff00;
    color: #000000;
    border: 2px solid #ffffff;
    font-weight: bold;
}

/* ==========================================================================
   Consent Banner & Session Controls (Step 5)
   ========================================================================== */
.ai-chatbot-consent-banner {
    background: var(--ai-chatbot-surface);
    border-bottom: 1px solid var(--ai-chatbot-border);
    padding: 10px 14px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--ai-chatbot-text);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.ai-chatbot-consent-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-chatbot-consent-text {
    color: var(--ai-chatbot-text-muted);
}

.ai-chatbot-consent-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.ai-chatbot-btn-consent-accept,
.ai-chatbot-btn-consent-decline {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.ai-chatbot-btn-consent-accept {
    background: var(--ai-chatbot-primary);
    color: #ffffff;
}

.ai-chatbot-btn-consent-accept:hover {
    background: var(--ai-chatbot-primary-hover);
}

.ai-chatbot-btn-consent-decline {
    background: transparent;
    color: var(--ai-chatbot-text-muted);
    border: 1px solid var(--ai-chatbot-border);
}

.ai-chatbot-btn-consent-decline:hover {
    background: var(--ai-chatbot-card);
    color: var(--ai-chatbot-text);
}

.ai-chatbot-btn-icon.btn-end-session {
    color: var(--ai-chatbot-text-muted);
}

.ai-chatbot-btn-icon.btn-end-session:hover {
    color: #ef4444;
}

/* ==========================================================================
   Step 6: Returning Visitor & Past Conversations Card
   ========================================================================== */
.ai-chatbot-returning-card {
    background: var(--ai-chatbot-surface);
    border: 1px solid var(--ai-chatbot-border);
    border-radius: 12px;
    padding: 14px 16px;
    margin: 8px 12px 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ai-chatbot-returning-header {
    margin-bottom: 12px;
}

.ai-chatbot-returning-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ai-chatbot-text);
    margin-bottom: 2px;
}

.ai-chatbot-returning-subtitle {
    font-size: 12px;
    color: var(--ai-chatbot-text-muted);
}

.ai-chatbot-past-conv-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.ai-chatbot-past-conv-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--ai-chatbot-card);
    border: 1px solid var(--ai-chatbot-border);
    border-radius: 8px;
    padding: 8px 12px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-chatbot-past-conv-item:hover {
    border-color: var(--ai-chatbot-primary);
    box-shadow: 0 2px 6px rgba(15, 82, 186, 0.08);
}

.ai-chatbot-past-conv-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.ai-chatbot-past-conv-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--ai-chatbot-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chatbot-past-conv-meta {
    font-size: 11px;
    color: var(--ai-chatbot-text-light);
}

.ai-chatbot-btn-continue {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: var(--ai-chatbot-primary);
    color: #ffffff;
    white-space: nowrap;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.ai-chatbot-btn-continue:hover {
    background: var(--ai-chatbot-primary-hover);
}

.ai-chatbot-returning-actions {
    display: flex;
    justify-content: flex-start;
}

.ai-chatbot-btn-start-new {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    color: var(--ai-chatbot-primary);
    border: 1px solid var(--ai-chatbot-primary);
    transition: background 0.15s ease, color 0.15s ease;
}

.ai-chatbot-btn-start-new:hover {
    background: var(--ai-chatbot-primary-light);
}




/* ==========================================================================
   Member Personalization, Glassmorphism & UI Upgrades
   ========================================================================== */
.ai-chatbot-window {
    border-radius: 20px !important;
    box-shadow: 0 20px 45px -12px rgba(79, 70, 229, 0.28), 0 0 1px 1px rgba(0, 0, 0, 0.06) !important;
    border: 1px solid rgba(99, 102, 241, 0.25) !important;
    overflow: hidden !important;
    backdrop-filter: blur(16px);
}

.ai-chatbot-header {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #7c3aed 100%) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18) !important;
    padding: 14px 16px !important;
    color: #ffffff !important;
}

.ai-chatbot-header .ai-chatbot-bot-name {
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 14.5px !important;
}

.ai-chatbot-header .ai-chatbot-bot-subtitle {
    color: rgba(255, 255, 255, 0.88) !important;
    margin-top: 2px;
}

.ai-chatbot-member-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.38);
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    backdrop-filter: blur(4px);
    letter-spacing: 0.2px;
}

.ai-chatbot-header .ai-chatbot-btn-icon {
    color: rgba(255, 255, 255, 0.88) !important;
}

.ai-chatbot-header .ai-chatbot-btn-icon:hover {
    background: rgba(255, 255, 255, 0.22) !important;
    color: #ffffff !important;
}

.ai-chatbot-status-dot.online {
    background: #10b981 !important;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.35), 0 0 8px #10b981 !important;
    animation: ai-status-pulse 2s infinite ease-in-out !important;
}

@keyframes ai-status-pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Nav Tab Bar */
.ai-chatbot-nav-tabs {
    display: flex;
    background: #f1f5f9;
    border-bottom: 1px solid var(--ai-chatbot-border);
    padding: 5px 8px;
    gap: 6px;
}

.ai-chatbot-tab {
    flex: 1;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--ai-chatbot-text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-chatbot-tab:hover {
    color: #4f46e5;
    background: rgba(79, 70, 229, 0.08);
}

.ai-chatbot-tab.active {
    color: #4f46e5;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Welcome Card & Member Quick Actions */
.ai-chatbot-welcome {
    background: linear-gradient(180deg, #f8faff 0%, #ffffff 100%) !important;
    border: 1px solid #e0e7ff !important;
    border-radius: 14px !important;
    padding: 16px !important;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.04) !important;
}

.ai-chatbot-welcome-title {
    font-size: 14.5px !important;
    font-weight: 700 !important;
    color: #1e1b4b !important;
    margin-bottom: 6px !important;
}

.ai-chatbot-welcome-msg {
    font-size: 13px !important;
    color: #475569 !important;
    line-height: 1.5 !important;
}

.ai-chatbot-member-quick-actions {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed #e2e8f0;
}

.quick-actions-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: #6366f1;
    margin-bottom: 8px;
}

.ai-chatbot-chip {
    background: #ffffff !important;
    border: 1px solid #c7d2fe !important;
    color: #4338ca !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    padding: 7px 12px !important;
    border-radius: 20px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 1px 2px rgba(67, 56, 202, 0.05) !important;
}

.ai-chatbot-chip:hover {
    background: #4f46e5 !important;
    color: #ffffff !important;
    border-color: #4f46e5 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.22) !important;
}

/* Services View */
.ai-chatbot-services-view {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.ai-chatbot-member-profile-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #e0e7ff 0%, #ede9fe 100%);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
    border: 1px solid #c7d2fe;
}

.profile-avatar {
    width: 42px;
    height: 42px;
    background: #4f46e5;
    color: #ffffff;
    font-size: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-name {
    font-weight: 700;
    font-size: 14.5px;
    color: #1e1b4b;
}

.profile-role {
    font-size: 11px;
    color: #4338ca;
    font-weight: 600;
}

.profile-email {
    font-size: 11px;
    color: #64748b;
}

.ai-chatbot-quick-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-chatbot-quick-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid var(--ai-chatbot-border);
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

.ai-chatbot-quick-card:hover {
    border-color: #6366f1;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.12);
    transform: translateY(-1px);
}

.quick-icon {
    font-size: 18px;
    margin-bottom: 4px;
}

.quick-title {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.quick-desc {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}

/* History Drawer */
.ai-chatbot-history-drawer {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    animation: ai-slide-in 0.22s ease-out;
}

@keyframes ai-slide-in {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.ai-chatbot-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--ai-chatbot-border);
    font-weight: 700;
    font-size: 13px;
    color: #1e293b;
}

.ai-chatbot-history-close {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #64748b;
    line-height: 1;
}

.ai-chatbot-history-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-chatbot-btn-new-chat {
    width: 100%;
    padding: 10px;
    background: #4f46e5;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.ai-chatbot-btn-new-chat:hover {
    background: #4338ca;
}

.ai-chatbot-history-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid var(--ai-chatbot-border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.ai-chatbot-history-item:hover {
    background: #eef2ff;
    border-color: #c7d2fe;
}

.history-item-title {
    font-size: 12.5px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-date {
    font-size: 11px;
    color: #94a3b8;
}