/* ========== CHATBOT WIDGET STYLES ========== */
.chat-widget {
    position: fixed;
    bottom: 24px;
    bottom: max(24px, env(safe-area-inset-bottom, 24px));
    right: 24px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px;
    font-family: 'Outfit', sans-serif;
    pointer-events: none;
}

/* Chat Window */
.chat-window {
    width: 370px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: rgba(10, 12, 18, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0,0,0,0.8), 0 0 0 1px rgba(16,185,129,0.1);
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom right;
}

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

/* Header */
.chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(59,130,246,0.1));
    border-bottom: 1px solid rgba(16,185,129,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(16,185,129,0.1);
    border: 1.5px solid rgba(16,185,129,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.header-info { flex: 1; }
.header-name {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
}
.header-status {
    font-size: 0.75rem;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
/* AI Disclosure (EU AI Act compliance) */
.header-ai-disclosure {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.35);
    margin-top: 3px;
    font-style: italic;
}
.header-info::after {
    content: "AI-powered · not a human agent";
    display: block;
    font-size: 0.62rem;
    color: rgba(255,255,255,0.3);
    margin-top: 2px;
    font-style: italic;
}
.status-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
    animation: chat-pulse-dot 2s infinite;
}
@keyframes chat-pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.chat-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.chat-close-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: chat-msgIn 0.3s ease;
}
@keyframes chat-msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.msg.bot { justify-content: flex-start; }
.msg.user { justify-content: flex-end; }

.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(16,185,129,0.12);
    border: 1px solid rgba(16,185,129,0.3);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.msg.bot .bubble {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.95);
    border-bottom-left-radius: 4px;
}

.msg.user .bubble {
    background: #10b981;
    color: #000;
    font-weight: 500;
    border-bottom-right-radius: 4px;
}

/* Quick replies */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
}

.qr-btn {
    padding: 7px 14px;
    border-radius: 20px;
    border: 1px solid rgba(16,185,129,0.35);
    background: rgba(16,185,129,0.08);
    color: #10b981;
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.qr-btn:hover {
    background: rgba(16,185,129,0.18);
    border-color: #10b981;
    transform: translateY(-1px);
}

/* Input */
.chat-input-wrap {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input {
    flex: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 999px;
    padding: 10px 18px;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
}
.chat-input::placeholder { color: rgba(255,255,255,0.3); }
.chat-input:focus { border-color: rgba(16,185,129,0.6); background: rgba(255,255,255,0.08); }

.chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #10b981;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chat-send-btn:hover { background: #34d399; transform: scale(1.08); }
.chat-send-btn svg { width: 18px; height: 18px; color: #000; }
.chat-send-btn, .chat-trigger, .qr-btn { touch-action: manipulation; }

/* Trigger Button */
.chat-trigger {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(16,185,129,0.2), rgba(10,12,18,0.95));
    border: 2px solid rgba(16,185,129,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 20px rgba(16,185,129,0.3);
    pointer-events: auto;
}
.chat-trigger:hover {
    border-color: #10b981;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6), 0 0 30px rgba(16,185,129,0.5);
    transform: scale(1.1);
}

.trigger-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    transition: transform 0.3s;
}
.chat-trigger:hover .trigger-avatar-img { transform: scale(1.1); }

.trigger-close-icon {
    display: none;
    color: #fff;
    font-size: 24px;
    font-weight: 300;
}

.chat-notif-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: #10b981;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #000;
    box-shadow: 0 0 10px rgba(16,185,129,0.5);
}

/* Typing indicator */
.typing { display: flex; align-items: center; gap: 4px; padding: 10px 14px; }
.typing-dot {
    width: 6px; height: 6px;
    background: rgba(255,255,255,0.4);
    border-radius: 50%;
    animation: chat-typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

@media (max-width: 480px) {
    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: auto;
        max-width: 100%;
        max-height: none;
        border-radius: 0;
        border: none;
        z-index: 10002;
        transform-origin: bottom right;
    }

    .chat-header {
        padding-top: max(16px, env(safe-area-inset-top, 16px));
    }

    .chat-input-wrap {
        padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
    }

    /* Hide Cal.com Book a Call button when chat is open on mobile */
    body.chat-open [data-cal-namespace],
    body.chat-open cal-floating-button,
    body.chat-open [id^="cal-floating"] {
        z-index: 0 !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}
