/* ═══════════════════════════════════════════════════════════════════
   Support Chat Widget — Floating Visitor Chat Head
   Premium glassmorphism design with smooth animations
   ═══════════════════════════════════════════════════════════════════ */

/* ── Floating Action Button (FAB) ─────────────────────────────────── */
.support-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(37, 99, 235, 0.4), 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    color: white;
    font-size: 1.4rem;
    outline: none;
}

.support-fab:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 12px 40px rgba(37, 99, 235, 0.5), 0 4px 12px rgba(0,0,0,0.15);
}

.support-fab:active {
    transform: scale(0.95);
}

.support-fab .fab-icon-chat,
.support-fab .fab-icon-close {
    position: absolute;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.support-fab .fab-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.support-fab.open .fab-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.support-fab.open .fab-icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Pulse ring */
.support-fab::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(37,99,235,0.3), rgba(124,58,237,0.3));
    animation: supportPulse 2.5s ease-in-out infinite;
    z-index: -1;
}

.support-fab.open::before {
    animation: none;
    opacity: 0;
}

@keyframes supportPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.15); opacity: 0; }
}

/* Unread badge */
.support-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    border-radius: 11px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    animation: badgeBounce 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.support-fab-badge.visible {
    display: flex;
}

@keyframes badgeBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ── Chat Window ──────────────────────────────────────────────────── */
.support-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 9999;
    width: 380px;
    max-height: 520px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(0,0,0,0.06);
}

.support-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header ───────────────────────────────────────────────────────── */
.support-chat-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    padding: 18px 20px;
    color: white;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.support-chat-header::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.15);
    pointer-events: none;
}

.support-chat-header-top {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.support-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.support-chat-avatar img {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1);
}

.support-chat-title {
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.2px;
}

.support-chat-subtitle {
    font-size: 0.72rem;
    opacity: 0.7;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.support-chat-subtitle .online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #34d399;
    display: inline-block;
    animation: onlinePulse 2s ease-in-out infinite;
}

@keyframes onlinePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Pre-chat Form ────────────────────────────────────────────────── */
.support-prechat {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
}

.support-prechat-intro {
    font-size: 0.88rem;
    color: #475569;
    line-height: 1.6;
    margin-bottom: 4px;
}

.support-prechat-intro strong {
    color: #1e293b;
}

.support-prechat label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    margin-bottom: 4px;
}

.support-prechat input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.88rem;
    font-family: 'Inter', sans-serif;
    color: #1e293b;
    background: #f8fafc;
    transition: all 0.2s;
    outline: none;
    box-sizing: border-box;
}

.support-prechat input:focus {
    border-color: #2563eb;
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.support-prechat textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.88rem;
    font-family: 'Inter', sans-serif;
    color: #1e293b;
    background: #f8fafc;
    transition: all 0.2s;
    outline: none;
    resize: vertical;
    min-height: 80px;
    box-sizing: border-box;
}

.support-prechat textarea:focus {
    border-color: #2563eb;
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.support-prechat-submit {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
}

.support-prechat-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
}

.support-prechat-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Hidden honeypot */
.support-hp-field {
    position: absolute;
    left: -9999px;
    opacity: 0;
    height: 0;
    overflow: hidden;
}

/* ── Messages Area ────────────────────────────────────────────────── */
.support-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-height: 320px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.1) transparent;
}

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

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

/* Message bubbles */
.support-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    word-wrap: break-word;
    animation: msgAppear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

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

.support-msg.visitor {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.support-msg.admin {
    background: #f1f5f9;
    color: #1e293b;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

.support-msg-time {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 4px;
    display: block;
}

.support-msg.visitor .support-msg-time {
    text-align: right;
    color: rgba(255,255,255,0.7);
}

/* Welcome message */
.support-welcome-msg {
    text-align: center;
    padding: 20px 16px;
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.6;
}

.support-welcome-msg i {
    font-size: 2rem;
    color: #2563eb;
    margin-bottom: 10px;
    display: block;
    opacity: 0.3;
}

/* Typing indicator */
.support-typing {
    display: none;
    align-self: flex-start;
    padding: 10px 16px;
    background: #f1f5f9;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    gap: 4px;
}

.support-typing.visible {
    display: flex;
}

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

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

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

/* ── Input Area ───────────────────────────────────────────────────── */
.support-input-area {
    padding: 12px 16px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    background: #fafbfc;
}

.support-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    color: #1e293b;
    background: white;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.support-input-area input:focus {
    border-color: #2563eb;
}

.support-input-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: all 0.2s;
}

.support-input-send:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.support-input-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ── Powered by footer ────────────────────────────────────────────── */
.support-powered {
    text-align: center;
    padding: 6px;
    font-size: 0.62rem;
    color: #94a3b8;
    background: #fafbfc;
    border-top: 1px solid #f1f5f9;
    letter-spacing: 0.3px;
}

.support-powered a {
    color: #64748b;
    text-decoration: none;
    font-weight: 600;
}

/* ── Mobile Responsive ────────────────────────────────────────────── */
@media (max-width: 480px) {
    .support-chat-window {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
    }

    .support-chat-window.open {
        border-radius: 16px 16px 0 0;
        max-height: 85dvh;
    }

    .support-fab {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }
}