/* ============================================
   Bitstech Messenger Chat Widget
   ============================================ */

.bt-chat-widget {
    position: fixed;
    bottom: 90px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Floating Action Button ── */
.bt-chat-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: var(--bt-chat-color, #753beb);
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(117, 59, 235, 0.4), 0 0 40px rgba(117, 59, 235, 0.15);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.bt-chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(117, 59, 235, 0.5), 0 0 60px rgba(117, 59, 235, 0.2);
}

.bt-chat-fab__icon {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.25s ease, transform 0.3s ease;
}

.bt-chat-fab__icon--chat {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.bt-chat-fab__icon--close {
    opacity: 0;
    transform: scale(0.5) rotate(-90deg);
}

.bt-chat-widget--open .bt-chat-fab__icon--chat {
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
}

.bt-chat-widget--open .bt-chat-fab__icon--close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Pulse animation */
.bt-chat-fab__pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--bt-chat-color, #753beb);
    opacity: 0;
    animation: btChatPulse 2s ease-out infinite;
    pointer-events: none;
}

.bt-chat-widget--open .bt-chat-fab__pulse {
    animation: none;
}

@keyframes btChatPulse {
    0% { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(1.8); opacity: 0; }
}

/* ── Tooltip ── */
.bt-chat-tooltip {
    display: none;
    position: absolute;
    bottom: 72px;
    right: 0;
    background: rgba(30, 42, 69, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.bt-chat-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 24px;
    width: 12px;
    height: 12px;
    background: rgba(30, 42, 69, 0.95);
    transform: rotate(45deg);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* ── Chat Popup ── */
.bt-chat-popup {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 360px;
    max-height: 480px;
    background: rgba(19, 28, 49, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.3s ease;
}

.bt-chat-widget--open .bt-chat-popup {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.bt-chat-popup__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(117, 59, 235, 0.2), rgba(0, 224, 240, 0.08));
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.bt-chat-popup__brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bt-chat-popup__avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #753beb, #00e0f0);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bt-chat-popup__brand strong {
    display: block;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
}

.bt-chat-popup__status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #00e676;
}

.bt-chat-popup__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #00e676;
    display: inline-block;
    animation: btDotPulse 2s ease infinite;
}

@keyframes btDotPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.bt-chat-popup__close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.bt-chat-popup__close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Body */
.bt-chat-popup__body {
    padding: 24px 20px;
    flex: 1;
}

.bt-chat-popup__greeting {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bt-chat-popup__bubble {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px 16px 16px 4px;
    padding: 14px 18px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    line-height: 1.6;
    max-width: 85%;
}

.bt-chat-popup__time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    padding-left: 4px;
}

/* Footer */
.bt-chat-popup__footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bt-chat-popup__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #753beb, #5a20c8);
    color: #fff;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.15);
}

.bt-chat-popup__btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(117, 59, 235, 0.4);
    color: #fff;
}

.bt-chat-popup__alt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.bt-chat-popup__alt-link {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    transition: background 0.2s, color 0.2s, transform 0.2s;
    text-decoration: none;
}

.bt-chat-popup__alt-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transform: scale(1.1);
}

/* ── Light Mode ── */
html[data-theme="light"] .bt-chat-popup {
    background: rgba(255, 255, 255, 0.97);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
}

html[data-theme="light"] .bt-chat-popup__header {
    background: linear-gradient(135deg, rgba(117, 59, 235, 0.08), rgba(0, 224, 240, 0.04));
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .bt-chat-popup__brand strong { color: #1a1d2e; }
html[data-theme="light"] .bt-chat-popup__close { background: rgba(0, 0, 0, 0.05); color: rgba(0, 0, 0, 0.5); }
html[data-theme="light"] .bt-chat-popup__close:hover { background: rgba(0, 0, 0, 0.1); color: #1a1d2e; }

html[data-theme="light"] .bt-chat-popup__bubble {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.06);
    color: #333;
}

html[data-theme="light"] .bt-chat-popup__time { color: rgba(0, 0, 0, 0.35); }
html[data-theme="light"] .bt-chat-popup__footer { border-top-color: rgba(0, 0, 0, 0.06); }
html[data-theme="light"] .bt-chat-popup__alt-link { background: rgba(0, 0, 0, 0.04); border-color: rgba(0, 0, 0, 0.08); color: rgba(0, 0, 0, 0.5); }
html[data-theme="light"] .bt-chat-popup__alt-link:hover { background: rgba(0, 0, 0, 0.08); color: #1a1d2e; }

html[data-theme="light"] .bt-chat-tooltip {
    background: rgba(255, 255, 255, 0.95);
    color: #1a1d2e;
    border-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .bt-chat-tooltip::after {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.08);
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .bt-chat-widget {
        bottom: 80px;
        right: 16px;
    }

    .bt-chat-popup {
        width: calc(100vw - 32px);
        right: -8px;
        bottom: 70px;
    }

    .bt-chat-fab {
        width: 54px;
        height: 54px;
    }
}
