/* ==========================================================================
   CAROL-IA VOICE ASSISTANT — Styles
   Premium glassmorphism floating chat widget
   ========================================================================== */

/* ── Floating Action Button ────────────────────────────────────────────── */
.va-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem 0 0;
    height: 56px;
    border: none;
    border-radius: 28px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #0f766e 100%);
    color: white;
    cursor: pointer;
    box-shadow:
        0 4px 16px rgba(15, 23, 42, 0.35),
        0 0 0 0 rgba(45, 212, 191, 0.4);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    font-family: 'Inter', system-ui, sans-serif;
    overflow: visible;
}

.va-fab:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow:
        0 8px 32px rgba(15, 23, 42, 0.45),
        0 0 20px rgba(45, 212, 191, 0.2);
}

.va-fab:active {
    transform: translateY(-1px) scale(0.98);
}

.va-fab-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.va-fab-icon svg {
    width: 24px;
    height: 24px;
    transition: transform 0.3s;
}

.va-fab-active .va-fab-icon svg {
    transform: rotate(90deg);
}

.va-fab-label {
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

/* Pulsing ring behind FAB */
.va-fab-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 28px;
    background: transparent;
    border: 2px solid rgba(45, 212, 191, 0.4);
    animation: va-fab-ring 2.5s ease-out infinite;
    pointer-events: none;
}

.va-fab-active .va-fab-pulse {
    animation: none;
    opacity: 0;
}

@keyframes va-fab-ring {
    0% { transform: scale(1); opacity: 0.7; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* ── Chat Panel ────────────────────────────────────────────────────────── */
.va-panel {
    position: fixed;
    bottom: 6.5rem;
    right: 2rem;
    z-index: 9998;
    width: 420px;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow:
        0 32px 64px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.4) inset;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
    overflow: hidden;
}

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

/* ── Panel Header ──────────────────────────────────────────────────────── */
.va-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    flex-shrink: 0;
}

.va-header-info {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.va-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(45, 212, 191, 0.15);
    border: 1px solid rgba(45, 212, 191, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

.va-avatar svg {
    width: 22px;
    height: 22px;
    stroke: #2dd4bf;
}

.va-avatar-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid #0f172a;
}

.va-header-name {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.01em;
    margin: 0;
}

.va-header-name span {
    display: inline-block;
    background: linear-gradient(135deg, #38bdf8, #2dd4bf);
    color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    font-size: 0.7rem;
    font-weight: 800;
    vertical-align: super;
    margin-left: 0.2rem;
}

.va-header-status {
    font-size: 0.75rem;
    color: #94a3b8;
    margin: 0.1rem 0 0;
    font-weight: 400;
}

.va-btn-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.va-btn-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.va-btn-close svg {
    width: 16px;
    height: 16px;
}

/* ── Messages Area ─────────────────────────────────────────────────────── */
.va-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.25rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 280px;
    max-height: 360px;
    scroll-behavior: smooth;
}

/* Scrollbar */
.va-messages::-webkit-scrollbar {
    width: 5px;
}
.va-messages::-webkit-scrollbar-track {
    background: transparent;
}
.va-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* ── Message Bubbles ───────────────────────────────────────────────────── */
.va-message {
    display: flex;
    gap: 0.65rem;
    max-width: 90%;
    animation: va-msg-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes va-msg-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.va-message-assistant {
    align-self: flex-start;
}

.va-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.va-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, #0f766e, #0284c7);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.va-msg-avatar svg {
    width: 16px;
    height: 16px;
    stroke: white;
}

.va-msg-content {
    display: flex;
    flex-direction: column;
}

.va-msg-bubble {
    padding: 0.85rem 1.15rem;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.55;
    font-family: 'Inter', system-ui, sans-serif;
}

.va-message-assistant .va-msg-bubble {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}

.va-message-user .va-msg-bubble {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.va-msg-time {
    font-size: 0.65rem;
    color: #94a3b8;
    margin-top: 0.3rem;
    padding: 0 0.25rem;
}

.va-message-user .va-msg-time {
    text-align: right;
}

/* Typing indicator */
.va-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 1rem 1.25rem !important;
}

.va-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: va-dot-bounce 1.4s infinite ease-in-out both;
}

.va-dots span:nth-child(1) { animation-delay: -0.32s; }
.va-dots span:nth-child(2) { animation-delay: -0.16s; }
.va-dots span:nth-child(3) { animation-delay: 0; }

@keyframes va-dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Input Area ────────────────────────────────────────────────────────── */
.va-input-area {
    padding: 1rem 1.25rem 0.75rem;
    border-top: 1px solid rgba(226, 232, 240, 0.6);
    background: rgba(248, 250, 252, 0.5);
    flex-shrink: 0;
}

.va-voice-visualizer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.05), rgba(45, 212, 191, 0.08));
    border-radius: 12px;
    border: 1px solid rgba(45, 212, 191, 0.2);
}

.va-wave-bar {
    width: 4px;
    height: 20px;
    background: linear-gradient(180deg, #2dd4bf, #0f766e);
    border-radius: 2px;
    animation: va-wave 0.8s ease-in-out infinite;
}

.va-wave-bar:nth-child(1) { animation-delay: 0s; height: 12px; }
.va-wave-bar:nth-child(2) { animation-delay: 0.1s; height: 20px; }
.va-wave-bar:nth-child(3) { animation-delay: 0.2s; height: 16px; }
.va-wave-bar:nth-child(4) { animation-delay: 0.3s; height: 22px; }
.va-wave-bar:nth-child(5) { animation-delay: 0.15s; height: 14px; }

@keyframes va-wave {
    0%, 100% { transform: scaleY(0.5); }
    50% { transform: scaleY(1.3); }
}

.va-listening-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: #0f766e;
    margin-left: 0.5rem;
    font-family: 'Inter', system-ui, sans-serif;
}

.va-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.va-text-input {
    flex: 1;
    height: 44px;
    padding: 0 1rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: white;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.9rem;
    color: #1e293b;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.va-text-input:focus {
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.va-text-input::placeholder {
    color: #94a3b8;
}

.va-btn-voice,
.va-btn-send {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.va-btn-voice {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.va-btn-voice:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.va-btn-voice-active {
    background: linear-gradient(135deg, #0f766e, #2dd4bf) !important;
    color: white !important;
    border-color: transparent !important;
    box-shadow: 0 0 16px rgba(45, 212, 191, 0.4);
    animation: va-mic-glow 1.5s ease-in-out infinite;
}

@keyframes va-mic-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(45, 212, 191, 0.3); }
    50% { box-shadow: 0 0 24px rgba(45, 212, 191, 0.6); }
}

.va-btn-voice svg,
.va-btn-send svg {
    width: 20px;
    height: 20px;
}

.va-btn-send {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
}

.va-btn-send:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.3);
}

.va-powered {
    text-align: center;
    font-size: 0.65rem;
    color: #94a3b8;
    margin-top: 0.6rem;
    font-family: 'Inter', system-ui, sans-serif;
    letter-spacing: 0.02em;
}

.va-powered strong {
    background: linear-gradient(135deg, #4285f4, #34a853, #fbbc05, #ea4335);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .va-panel {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 20px 20px 0 0;
    }

    .va-panel-open {
        transform: translateY(0);
    }

    /* Hide the FAB when the panel is open on mobile to prevent overlap */
    .va-fab-active {
        opacity: 0 !important;
        pointer-events: none !important;
        transform: scale(0) !important;
        transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
    }

    .va-fab {
        bottom: 1rem;
        right: 1rem;
    }

    .va-fab-label {
        display: none;
    }

    .va-fab {
        padding: 0;
        width: 56px;
        border-radius: 50%;
    }

    .va-messages {
        max-height: calc(100dvh - 220px);
    }

    /* Safe area padding for devices with gesture navigation bars */
    .va-input-area {
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }
}
