/**
 * Chatbot AI - Live Calling + Dynamic Island (from call button)
 */

.chatbot-ai-call {
    position: relative;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    border: 0;
    border-radius: 12px !important;
    background: #0f172a !important;
    color: #ffffff !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        transform 0.28s cubic-bezier(0.32, 0.72, 0, 1),
        background 0.2s ease,
        box-shadow 0.2s ease,
        opacity 0.2s ease,
        border-radius 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.22);
}

.chatbot-ai-call:hover {
    transform: translateY(-1px);
    background: #1e293b !important;
}

.chatbot-ai-call.is-calling {
    background: #111111 !important;
    border-radius: 999px !important;
    box-shadow: none;
}

.chatbot-ai-call .fas,
.chatbot-ai-call svg {
    width: auto;
    height: auto;
    font-size: 14px;
    color: #ffffff !important;
    transition: opacity 0.2s ease, transform 0.25s ease;
}

.chatbot-ai-call-status {
    display: none;
}

.chatbot-ai-actions {
    position: relative;
}

.chatbot-ai-call-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
}

.chatbot-ai-call-overlay.is-connecting,
.chatbot-ai-call-overlay.ai-speaking,
.chatbot-ai-call-overlay.user-speaking {
    animation: chatbot-ai-call-btn-pulse 1.2s infinite;
}

@keyframes chatbot-ai-call-btn-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(15, 23, 42, 0.35);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(15, 23, 42, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(15, 23, 42, 0);
    }
}

/* =========================================
   Call slot — button morphs into island
   ========================================= */

.chatbot-ai-call-slot {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    z-index: 6;
    transition: width 0.52s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: width;
}

.chatbot-ai-call-slot.is-live {
    width: 220px;
}

.chatbot-ai-call-slot.is-collapsing {
    width: 40px;
    transition-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
}

.chatbot-ai-call-slot .chatbot-ai-call {
    position: absolute;
    inset: 0;
    z-index: 1;
    margin: 0;
}

.chatbot-ai-call-slot.is-live .chatbot-ai-call,
.chatbot-ai-call-slot.is-collapsing .chatbot-ai-call {
    opacity: 0;
    transform: scale(0.55);
    pointer-events: none;
    border-radius: 999px !important;
}

.chatbot-ai-call-slot.is-collapsing .chatbot-ai-call {
    transition-delay: 0.18s;
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* Island grows from the same spot as the call button */
.chatbot-ai-call-island {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: none;
    align-items: center;
    border-radius: 999px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    background: linear-gradient(180deg, #1c1c1e 0%, #0a0a0b 100%);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.28),
        0 0 0 1px rgba(255, 255, 255, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transform: scale(0.92);
    transition:
        opacity 0.22s ease,
        visibility 0.22s ease,
        transform 0.48s cubic-bezier(0.32, 0.72, 0, 1),
        box-shadow 0.35s ease;
}

.chatbot-ai-call-slot.is-live .chatbot-ai-call-island,
.chatbot-ai-call-slot.is-collapsing .chatbot-ai-call-island,
.chatbot-ai-call-island.is-active {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: scale(1);
}

.chatbot-ai-call-slot.is-collapsing .chatbot-ai-call-island {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.88);
    transition-delay: 0.08s;
    pointer-events: none;
}

.chatbot-ai-call-island-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 100%;
    padding: 0 6px 0 12px;
    color: #f5f5f7;
    opacity: 0;
    transform: translateX(10px) scale(0.98);
    transition:
        opacity 0.28s ease 0.14s,
        transform 0.4s cubic-bezier(0.32, 0.72, 0, 1) 0.1s;
}

.chatbot-ai-call-slot.is-live .chatbot-ai-call-island-inner {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.chatbot-ai-call-slot.is-collapsing .chatbot-ai-call-island-inner {
    opacity: 0;
    transform: translateX(6px) scale(0.98);
    transition:
        opacity 0.14s ease 0s,
        transform 0.18s ease 0s;
}

.chatbot-ai-call-island-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.chatbot-ai-call-island-dot {
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.55);
    animation: chatbot-ai-island-dot-pulse 1.4s ease-out infinite;
}

.chatbot-ai-call-island.is-connected .chatbot-ai-call-island-dot {
    background: #34d399;
    animation-name: chatbot-ai-island-dot-pulse-green;
}

.chatbot-ai-call-island.is-ending .chatbot-ai-call-island-dot,
.chatbot-ai-call-island.is-error .chatbot-ai-call-island-dot {
    background: #f87171;
    animation: none;
    box-shadow: none;
}

.chatbot-ai-call-island-meta {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.chatbot-ai-call-island-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 88px;
}

.chatbot-ai-call-island-timer {
    font-size: 10px;
    font-weight: 500;
    color: rgba(245, 245, 247, 0.55);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.chatbot-ai-call-island-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 16px;
    flex-shrink: 0;
}

.chatbot-ai-call-island-wave span {
    display: block;
    width: 2.5px;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.35);
    transform-origin: center;
    animation: chatbot-ai-island-wave 1.1s ease-in-out infinite;
}

.chatbot-ai-call-island-wave span:nth-child(1) { animation-delay: 0s; height: 5px; }
.chatbot-ai-call-island-wave span:nth-child(2) { animation-delay: 0.12s; height: 9px; }
.chatbot-ai-call-island-wave span:nth-child(3) { animation-delay: 0.24s; height: 13px; }
.chatbot-ai-call-island-wave span:nth-child(4) { animation-delay: 0.12s; height: 8px; }
.chatbot-ai-call-island-wave span:nth-child(5) { animation-delay: 0s; height: 5px; }

.chatbot-ai-call-island.is-connecting .chatbot-ai-call-island-wave span {
    animation-duration: 1.6s;
    background: rgba(251, 191, 36, 0.55);
}

.chatbot-ai-call-island.is-connected .chatbot-ai-call-island-wave span {
    background: rgba(52, 211, 153, 0.75);
}

.chatbot-ai-call-island.user-speaking .chatbot-ai-call-island-wave span,
.chatbot-ai-call-island.ai-speaking .chatbot-ai-call-island-wave span {
    animation-duration: 0.55s;
    background: #60a5fa;
}

.chatbot-ai-call-hangup {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #ef4444;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(239, 68, 68, 0.4);
    transition: transform 0.15s ease, background 0.15s ease;
}

.chatbot-ai-call-hangup:hover {
    background: #dc2626;
    transform: scale(1.08);
}

.chatbot-ai-call-hangup:active {
    transform: scale(0.94);
}

.chatbot-ai-call-hangup .fas {
    font-size: 12px;
    color: #ffffff !important;
    line-height: 1;
}

@keyframes chatbot-ai-island-dot-pulse {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.55); }
    70% { box-shadow: 0 0 0 7px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

@keyframes chatbot-ai-island-dot-pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
    70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

@keyframes chatbot-ai-island-wave {
    0%,
    100% {
        transform: scaleY(0.45);
        opacity: 0.55;
    }

    50% {
        transform: scaleY(1);
        opacity: 1;
    }
}

/* Soft bounce once when island opens */
.chatbot-ai-call-slot.is-live.is-opening {
    animation: chatbot-ai-island-open-bounce 0.55s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes chatbot-ai-island-open-bounce {
    0% { width: 40px; }
    60% { width: 228px; }
    100% { width: 220px; }
}

/* Call transcript bubbles */

.chatbot-ai-call-message {
    width: fit-content;
    max-width: 90%;
    margin: 8px auto;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.3;
    text-align: center;
    animation: chatbot-ai-call-message-in 0.2s ease;
}

.chatbot-ai-call-message.connected {
    background: #ecfdf5;
    color: #047857;
}

.chatbot-ai-call-message.ended {
    background: #f3f4f6;
    color: #6b7280;
}

.chatbot-ai-call-system-message {
    width: fit-content;
    max-width: 85%;
    margin: 10px auto;
    padding: 7px 12px;
    border-radius: 20px;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
    opacity: 0.7;
}

@keyframes chatbot-ai-call-message-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

@media (max-width: 480px) {
    .chatbot-ai-call-slot.is-live {
        width: 200px;
    }

    @keyframes chatbot-ai-island-open-bounce {
        0% { width: 40px; }
        60% { width: 208px; }
        100% { width: 200px; }
    }

    .chatbot-ai-call-island-label {
        max-width: 72px;
        font-size: 10px;
    }

    .chatbot-ai-call-hangup {
        width: 26px;
        height: 26px;
    }

    .chatbot-ai-voice-slot.is-live {
        width: 236px;
    }

    @keyframes chatbot-ai-voice-island-open-bounce {
        0% { width: 40px; }
        60% { width: 244px; }
        100% { width: 236px; }
    }

    .chatbot-ai-voice-island-label {
        max-width: 70px;
        font-size: 10px;
    }
}

/* =========================================
   Voice slot — mic morphs into island
   ========================================= */

.chatbot-ai-voice-live {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 10px;
    padding: 12px 14px;
    border-radius: 16px;
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: #f8fafc;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
}

.chatbot-ai-voice-live.is-visible,
.chatbot-ai-footer.is-voice-listening .chatbot-ai-voice-live {
    display: flex;
}

.chatbot-ai-voice-live[hidden] {
    display: none !important;
}

.chatbot-ai-voice-live-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.chatbot-ai-voice-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45);
    animation: chatbot-ai-voice-dot-pulse 1.2s ease-out infinite;
}

.chatbot-ai-voice-live-head strong {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.chatbot-ai-voice-live-hint {
    font-size: 11px;
    color: rgba(248, 250, 252, 0.65);
}

.chatbot-ai-voice-live-text {
    margin: 0;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 14px;
    line-height: 1.45;
    color: #f8fafc;
    white-space: pre-wrap;
    word-break: break-word;
}

.chatbot-ai-voice-live-text.is-empty {
    color: rgba(248, 250, 252, 0.45);
    font-style: italic;
}

.chatbot-ai-message.is-voice-draft {
    opacity: 0.78;
    border: 1px dashed rgba(10, 132, 255, 0.45);
}

.chatbot-ai-message.is-voice-draft .chatbot-ai-message-text {
    font-style: italic;
}

.chatbot-ai-voice-slot {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    z-index: 6;
    transition: width 0.52s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: width;
}

.chatbot-ai-voice-slot.is-live {
    width: 248px;
}

.chatbot-ai-voice-slot.is-collapsing {
    width: 40px;
}

.chatbot-ai-voice-slot .chatbot-ai-voice {
    position: absolute;
    inset: 0;
    z-index: 1;
    margin: 0;
}

.chatbot-ai-voice-slot.is-live .chatbot-ai-voice {
    opacity: 0;
    transform: scale(0.55);
    pointer-events: none;
    border-radius: 999px !important;
}

.chatbot-ai-voice-slot.is-collapsing .chatbot-ai-voice {
    transition-delay: 0.18s;
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.chatbot-ai-voice-island {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: none;
    align-items: center;
    border-radius: 999px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    background: linear-gradient(180deg, #1c1c1e 0%, #0a0a0b 100%);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.28),
        0 0 0 1px rgba(255, 255, 255, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transform: scale(0.92);
    transition:
        opacity 0.22s ease,
        visibility 0.22s ease,
        transform 0.48s cubic-bezier(0.32, 0.72, 0, 1);
}

.chatbot-ai-voice-slot.is-live .chatbot-ai-voice-island,
.chatbot-ai-voice-slot.is-collapsing .chatbot-ai-voice-island {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: scale(1);
}

.chatbot-ai-voice-slot.is-collapsing .chatbot-ai-voice-island {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.88);
    transition-delay: 0.08s;
    pointer-events: none;
}

.chatbot-ai-voice-island-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 100%;
    padding: 0 6px 0 12px;
    color: #f5f5f7;
    opacity: 0;
    transform: translateX(10px) scale(0.98);
    transition:
        opacity 0.28s ease 0.14s,
        transform 0.4s cubic-bezier(0.32, 0.72, 0, 1) 0.1s;
}

.chatbot-ai-voice-slot.is-live .chatbot-ai-voice-island-inner {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.chatbot-ai-voice-slot.is-collapsing .chatbot-ai-voice-island-inner {
    opacity: 0;
    transform: translateX(6px) scale(0.98);
    transition:
        opacity 0.14s ease 0s,
        transform 0.18s ease 0s;
}

.chatbot-ai-voice-island-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.chatbot-ai-voice-island-dot {
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
    animation: chatbot-ai-voice-dot-pulse 1.2s ease-out infinite;
}

.chatbot-ai-voice-island.is-sending .chatbot-ai-voice-island-dot {
    background: #60a5fa;
    animation: chatbot-ai-island-dot-pulse 1.4s ease-out infinite;
}

.chatbot-ai-voice-island-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chatbot-ai-voice-island-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 78px;
}

.chatbot-ai-voice-island-timer {
    font-size: 10px;
    font-weight: 500;
    color: rgba(245, 245, 247, 0.55);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.chatbot-ai-voice-island-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 16px;
    flex-shrink: 0;
}

.chatbot-ai-voice-island-wave span {
    display: block;
    width: 2.5px;
    height: 6px;
    border-radius: 999px;
    background: rgba(96, 165, 250, 0.75);
    transform-origin: center;
    animation: chatbot-ai-island-wave 1s ease-in-out infinite;
}

.chatbot-ai-voice-island-wave span:nth-child(1) { animation-delay: 0s; height: 5px; }
.chatbot-ai-voice-island-wave span:nth-child(2) { animation-delay: 0.1s; height: 9px; }
.chatbot-ai-voice-island-wave span:nth-child(3) { animation-delay: 0.2s; height: 13px; }
.chatbot-ai-voice-island-wave span:nth-child(4) { animation-delay: 0.1s; height: 8px; }
.chatbot-ai-voice-island-wave span:nth-child(5) { animation-delay: 0s; height: 5px; }

.chatbot-ai-voice-cancel-btn,
.chatbot-ai-voice-send-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
}

.chatbot-ai-voice-cancel-btn {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.chatbot-ai-voice-cancel-btn:hover {
    background: rgba(248, 113, 113, 0.85);
    transform: scale(1.08);
}

.chatbot-ai-voice-send-btn {
    background: #22c55e;
    color: #fff;
    box-shadow: 0 3px 10px rgba(34, 197, 94, 0.4);
}

.chatbot-ai-voice-send-btn:hover {
    background: #16a34a;
    transform: scale(1.08);
}

.chatbot-ai-voice-cancel-btn .fas,
.chatbot-ai-voice-send-btn .fas {
    font-size: 12px;
    color: #ffffff !important;
    line-height: 1;
}

.chatbot-ai-voice-island.is-sending .chatbot-ai-voice-cancel-btn,
.chatbot-ai-voice-island.is-sending .chatbot-ai-voice-send-btn {
    pointer-events: none;
    opacity: 0.45;
}

.chatbot-ai-voice-slot.is-live.is-opening {
    animation: chatbot-ai-voice-island-open-bounce 0.55s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes chatbot-ai-voice-island-open-bounce {
    0% { width: 40px; }
    60% { width: 256px; }
    100% { width: 248px; }
}

@keyframes chatbot-ai-voice-dot-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
    70% { box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
