/* ============================================
   TRAUDIO Chatbot Widget — Styles
   ============================================ */

/* ---------- Variables ---------- */
:root {
    --chat-bg: rgba(18, 19, 26, 0.94);
    --chat-border: rgba(255, 255, 255, 0.08);
    --chat-blur: 24px;
    --chat-radius: 20px;
    --chat-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    --bot-bubble: #181924;
    --user-bubble: #007cfb;
    --chip-border: rgba(0, 124, 251, 0.35);
    --chip-bg: rgba(0, 124, 251, 0.08);
    --chat-width: 380px;
    --chat-height: 540px;
}

/* ---------- Trigger Button ---------- */
.chatbot-trigger {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 9998;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007cfb, #005ec4);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 20px rgba(0, 124, 251, 0.35), 0 0 0 0 rgba(0, 124, 251, 0.3);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    animation: chatbot-pulse 3s ease-in-out infinite;
    will-change: transform, box-shadow;
    transform: translateZ(0);
}

.chatbot-trigger:hover {
    transform: scale(1.08) translateZ(0);
    box-shadow: 0 6px 28px rgba(0, 124, 251, 0.45);
}

@media (max-width: 768px) {
    .chatbot-trigger {
        /* Reduce heavy multi-layered box shadow repaints on mobile GPUs */
        box-shadow: 0 4px 12px rgba(0, 124, 251, 0.3);
        animation: none;
        /* Disable expensive pulse on mobile */
    }
}

.chatbot-trigger .icon-open,
.chatbot-trigger .icon-close {
    position: absolute;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

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

.chatbot-trigger.active .icon-open {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}

.chatbot-trigger.active .icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

@keyframes chatbot-pulse {

    0%,
    100% {
        box-shadow: 0 4px 20px rgba(0, 124, 251, 0.35), 0 0 0 0 rgba(0, 124, 251, 0.25);
    }

    50% {
        box-shadow: 0 4px 20px rgba(0, 124, 251, 0.35), 0 0 0 12px rgba(0, 124, 251, 0);
    }
}

/* Notification badge */
.chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f59e0b;
    color: #000;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #0a0a0f;
    animation: badge-bounce 0.4s ease;
}

@keyframes badge-bounce {
    0% {
        transform: scale(0);
    }

    60% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

/* ---------- Chat Window ---------- */
.chatbot-window {
    position: fixed;
    bottom: 96px;
    left: 24px;
    z-index: 9999;
    width: var(--chat-width);
    height: var(--chat-height);
    max-height: calc(100dvh - 130px);
    border-radius: var(--chat-radius);
    background: var(--chat-bg);
    backdrop-filter: blur(var(--chat-blur));
    -webkit-backdrop-filter: blur(var(--chat-blur));
    border: 1px solid var(--chat-border);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

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

/* ---------- Header ---------- */
.chatbot-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: rgba(10, 10, 15, 0.6);
    border-bottom: 1px solid var(--chat-border);
    flex-shrink: 0;
}

.chatbot-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid rgba(0, 124, 251, 0.25);
}

.chatbot-header-info h4 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.2;
}

.chatbot-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}

.chatbot-header-status .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    animation: dot-pulse 2s ease infinite;
}

@keyframes dot-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ---------- Messages Area ---------- */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Message bubbles */
.chat-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: msg-in 0.3s ease;
}

@keyframes msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg.bot {
    align-self: flex-start;
}

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

.chat-msg .bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.55;
    color: #e2e8f0;
    word-break: break-word;
}

.chat-msg.bot .bubble {
    background: var(--bot-bubble);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-top-left-radius: 4px;
}

.chat-msg.user .bubble {
    background: var(--user-bubble);
    color: #fff;
    border-top-right-radius: 4px;
}

.chat-msg .bubble a {
    color: #60a5fa;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chat-msg.user .bubble a {
    color: #bfdbfe;
}

.chat-msg .bubble strong {
    color: #fff;
    font-weight: 600;
}

.chat-msg .msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bot-bubble);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    border-top-left-radius: 4px;
    width: fit-content;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typing-dot 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-dot {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ---------- Quick Reply Chips ---------- */
.chatbot-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 10px;
    flex-shrink: 0;
}

.chatbot-chip {
    padding: 6px 14px;
    border-radius: 100px;
    border: 1px solid var(--chip-border);
    background: var(--chip-bg);
    color: #60a5fa;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chatbot-chip:hover {
    background: rgba(0, 124, 251, 0.18);
    border-color: rgba(0, 124, 251, 0.55);
    color: #93c5fd;
}

/* ---------- Input Area ---------- */
.chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--chat-border);
    background: rgba(10, 10, 15, 0.4);
    flex-shrink: 0;
    position: relative;
}

.chatbot-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 14px;
    color: #e2e8f0;
    font-size: 16px;
    /* Prevents iOS auto-zoom */
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s ease;
}

.chatbot-input::placeholder {
    color: #64748b;
}

.chatbot-input:focus {
    border-color: rgba(0, 124, 251, 0.4);
}

.chatbot-send {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: #007cfb;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease;
}

.chatbot-send:hover {
    background: #006edc;
    transform: scale(1.05);
}

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

/* ---------- Type-ahead Dropdown ---------- */
.chatbot-typeahead {
    position: absolute;
    bottom: 100%;
    left: 14px;
    right: 14px;
    background: rgba(18, 19, 26, 0.97);
    backdrop-filter: blur(16px);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    margin-bottom: 6px;
    max-height: 180px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
}

.chatbot-typeahead.visible {
    display: block;
    animation: typeahead-in 0.2s ease;
}

@keyframes typeahead-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-typeahead-item {
    padding: 10px 14px;
    font-size: 12px;
    color: #94a3b8;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.15s ease, color 0.15s ease;
}

.chatbot-typeahead-item:last-child {
    border-bottom: none;
}

.chatbot-typeahead-item:hover {
    background: rgba(0, 124, 251, 0.1);
    color: #e2e8f0;
}

.chatbot-typeahead-item strong {
    color: #60a5fa;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .chatbot-window {
        left: 8px;
        right: 8px;
        bottom: 88px;
        width: auto;
        height: auto;
        max-height: calc(100dvh - 110px);
        max-width: calc(100vw - 16px);
        box-sizing: border-box;
        border-radius: 16px;
    }
}