/* ==========================================================================
   COMPONENT: Site-wide chat widget (pill launcher + glass panel)
   Uses tokens from styles.css (--color-dark-blue, --color-bright-blue,
   --gradient-cta, --shadow-xl, --font-family). Fixed position, sits above
   all page content.
   ========================================================================== */

.chatbot-root {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px;
}

.chatbot-glow {
    position: absolute;
    right: -60px;
    bottom: -60px;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(52, 152, 219, 0.35) 0%, transparent 70%);
    filter: blur(10px);
    pointer-events: none;
    z-index: -1;
}

/* -------------------- Launcher pill -------------------- */
.chatbot-launcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    cursor: pointer;
    padding: 8px 20px 8px 8px;
    border-radius: 999px;
    background: var(--gradient-cta);
    color: #fff;
    font-family: var(--font-family);
    box-shadow: 0 10px 30px rgba(12, 52, 131, 0.35);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.chatbot-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(12, 52, 131, 0.42);
}

.chatbot-launcher-avatar {
    position: relative;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-launcher-avatar img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    border-radius: 50%;
}

.chatbot-launcher-status::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: #2ECC71;
    animation: chatbot-status-pulse 1.8s ease-out infinite;
}

@keyframes chatbot-status-pulse {
    0% { transform: scale(1); opacity: 0.7; }
    100% { transform: scale(2.2); opacity: 0; }
}

.chatbot-launcher-text {
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
}

.chatbot-launcher-icon {
    position: relative;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.chatbot-launcher-icon svg {
    position: absolute;
    inset: 0;
    width: 18px;
    height: 18px;
    transition: opacity var(--transition-base), transform var(--transition-base);
}

.chatbot-launcher-icon-close {
    opacity: 0;
    transform: scale(0.6) rotate(-45deg);
}

.chatbot-launcher[aria-expanded="true"] .chatbot-launcher-icon-chat {
    opacity: 0;
    transform: scale(0.6) rotate(45deg);
}

.chatbot-launcher[aria-expanded="true"] .chatbot-launcher-icon-close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

@media (max-width: 480px) {
    .chatbot-launcher-text { display: none; }
    .chatbot-launcher { padding: 8px; }
}

/* -------------------- Panel -------------------- */
.chatbot-panel {
    display: none;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 560px;
    max-height: calc(100vh - 160px);
    border-radius: 26px;
    overflow: hidden;
    flex-direction: column;
    position: relative;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 24px 60px rgba(12, 52, 131, 0.28), 0 0 0 1px rgba(52, 152, 219, 0.08);
}

.chatbot-panel:not([hidden]) {
    display: flex;
    animation: chatbot-panel-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes chatbot-panel-in {
    from { opacity: 0; transform: translateY(16px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.chatbot-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px;
    background: var(--gradient-cta);
    color: #fff;
    flex-shrink: 0;
}

.chatbot-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 85% -20%, rgba(255, 255, 255, 0.25) 0%, transparent 55%);
    pointer-events: none;
}

.chatbot-header-avatar {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chatbot-header-avatar img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.chatbot-header-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.chatbot-header-title {
    font-weight: 800;
    font-size: 0.98rem;
}

.chatbot-header-subtitle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.82);
}

.chatbot-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2ECC71;
    flex-shrink: 0;
}

.chatbot-close {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition-base);
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

.chatbot-close svg {
    width: 16px;
    height: 16px;
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chatbot-msg {
    max-width: 85%;
    padding: 11px 15px;
    font-size: 0.9rem;
    line-height: 1.55;
    white-space: pre-wrap;
}

.chatbot-msg-bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid rgba(12, 52, 131, 0.08);
    color: var(--color-dark-blue);
    border-radius: 4px 16px 16px 16px;
    box-shadow: 0 2px 8px rgba(12, 52, 131, 0.06);
}

.chatbot-msg-user {
    align-self: flex-end;
    background: var(--gradient-cta);
    color: #fff;
    border-radius: 16px 4px 16px 16px;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
}

.chatbot-msg-error {
    align-self: flex-start;
    background: #FDECEA;
    border: 1px solid rgba(214, 61, 61, 0.25);
    color: #9C2A2A;
    border-radius: 4px 16px 16px 16px;
}

.chatbot-msg-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 13px 16px;
    background: #fff;
    border: 1px solid rgba(12, 52, 131, 0.08);
    border-radius: 4px 16px 16px 16px;
    box-shadow: 0 2px 8px rgba(12, 52, 131, 0.06);
}

.chatbot-msg-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-bright-blue);
    opacity: 0.5;
    animation: chatbot-typing-bounce 1s infinite ease-in-out;
}

.chatbot-msg-typing span:nth-child(2) { animation-delay: 0.15s; }
.chatbot-msg-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatbot-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.chatbot-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px;
    border-top: 1px solid rgba(12, 52, 131, 0.08);
    background: rgba(255, 255, 255, 0.7);
    flex-shrink: 0;
}

.chatbot-input {
    flex: 1;
    min-width: 0;
    border: 1.5px solid rgba(12, 52, 131, 0.14);
    border-radius: 999px;
    padding: 11px 16px;
    font-family: var(--font-family);
    font-size: 0.9rem;
    color: var(--color-dark-blue);
    background: #fff;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.chatbot-input:focus {
    outline: none;
    border-color: var(--color-bright-blue);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.chatbot-mic {
    position: relative;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border: 1.5px solid rgba(12, 52, 131, 0.12);
    border-radius: 50%;
    background: #fff;
    color: rgba(12, 52, 131, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: not-allowed;
}

.chatbot-mic svg {
    width: 17px;
    height: 17px;
}

.chatbot-mic-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--color-dark-blue);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    padding: 6px 10px;
    border-radius: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base), transform var(--transition-base);
}

.chatbot-mic-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--color-dark-blue);
}

.chatbot-mic:hover .chatbot-mic-tooltip,
.chatbot-mic:focus-visible .chatbot-mic-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.chatbot-send {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--gradient-cta);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transition: transform var(--transition-base), box-shadow var(--transition-base), opacity var(--transition-base);
}

.chatbot-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chatbot-send svg {
    width: 18px;
    height: 18px;
}

@media (max-width: 480px) {
    .chatbot-root {
        right: 16px;
        bottom: 16px;
    }

    .chatbot-panel {
        width: calc(100vw - 32px);
        height: calc(100vh - 140px);
    }
}
