/**
 * MultiCalc Voice Assistant Styles
 * Floating button + modal with glassmorphism design
 */

/* ========================================
   CSS Variables
   ======================================== */
:root {
    --va-primary: #0e3d77;
    --va-primary-light: #1a5db8;
    --va-accent: #9fd236;
    --va-bg: rgba(255, 255, 255, 0.95);
    --va-glass: rgba(255, 255, 255, 0.85);
    --va-shadow: 0 8px 32px rgba(14, 61, 119, 0.15);
    --va-radius: 16px;
}

/* ========================================
   Floating Action Button - Compact Size
   ======================================== */
.va-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--va-primary) 0%, var(--va-primary-light) 100%);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(14, 61, 119, 0.2);
    z-index: 9998;
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
}

.va-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(14, 61, 119, 0.3);
    opacity: 1;
}

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

.va-fab.va-active {
    background: linear-gradient(135deg, var(--va-accent) 0%, #7fb829 100%);
}

/* Pulse animation ring */
.va-fab-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--va-primary);
    opacity: 0;
    pointer-events: none;
}

.va-fab.va-listening .va-fab-pulse {
    animation: va-pulse 1.5s ease-out infinite;
}

@keyframes va-pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }

    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

/* Listening state - microphone animation */
.va-fab.va-listening {
    animation: va-glow 1s ease-in-out infinite alternate;
}

@keyframes va-glow {
    from {
        box-shadow: 0 0 10px rgba(159, 210, 54, 0.5),
            0 0 20px rgba(159, 210, 54, 0.3),
            0 0 30px rgba(159, 210, 54, 0.1);
    }

    to {
        box-shadow: 0 0 20px rgba(159, 210, 54, 0.8),
            0 0 40px rgba(159, 210, 54, 0.5),
            0 0 60px rgba(159, 210, 54, 0.3);
    }
}

/* ========================================
   Modal Overlay - No blur, page stays visible
   ======================================== */
.va-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 24px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.va-modal.va-open {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   Modal Content
   ======================================== */
.va-modal-content {
    background: var(--va-glass);
    backdrop-filter: blur(20px);
    border-radius: var(--va-radius);
    box-shadow: var(--va-shadow);
    width: 100%;
    max-width: 380px;
    max-height: 500px;
    display: flex;
    flex-direction: column;
    transform: translateY(100px) scale(0.95);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    overflow: hidden;
    pointer-events: auto;
    border: 1px solid rgba(14, 61, 119, 0.15);
}

.va-modal.va-open .va-modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* ========================================
   Header
   ======================================== */
.va-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--va-primary) 0%, var(--va-primary-light) 100%);
    color: white;
}

.va-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-right: 12px;
}

.va-title {
    flex: 1;
}

.va-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.va-title span {
    font-size: 13px;
    opacity: 0.85;
}

.va-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.va-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ========================================
   Body
   ======================================== */
.va-body {
    padding: 24px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
}

/* Waveform Animation */
.va-waveform {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
    gap: 6px;
    margin-bottom: 20px;
}

.va-wave {
    width: 4px;
    height: 20px;
    background: var(--va-primary);
    border-radius: 4px;
    opacity: 0.3;
    transition: height 0.15s ease;
}

.va-waveform.va-active .va-wave {
    animation: va-wave 0.8s ease-in-out infinite;
    opacity: 1;
}

.va-waveform.va-active .va-wave:nth-child(1) {
    animation-delay: 0s;
}

.va-waveform.va-active .va-wave:nth-child(2) {
    animation-delay: 0.1s;
}

.va-waveform.va-active .va-wave:nth-child(3) {
    animation-delay: 0.2s;
}

.va-waveform.va-active .va-wave:nth-child(4) {
    animation-delay: 0.3s;
}

.va-waveform.va-active .va-wave:nth-child(5) {
    animation-delay: 0.4s;
}

@keyframes va-wave {

    0%,
    100% {
        height: 20px;
    }

    50% {
        height: 50px;
    }
}

/* Transcript Display */
.va-transcript {
    width: 100%;
    text-align: center;
}

.va-user-text {
    color: var(--va-primary);
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 12px 0;
    min-height: 24px;
}

.va-ai-text {
    color: #555;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    padding: 12px 16px;
    background: #f0f4f8;
    border-radius: 12px;
    min-height: 24px;
}

.va-ai-text:empty {
    display: none;
}

/* ========================================
   Footer
   ======================================== */
.va-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(240, 244, 248, 0.5);
}

.va-hint {
    color: #777;
    font-size: 12px;
    text-align: center;
}

.va-hint i {
    color: #f0ad4e;
    margin-right: 6px;
}

/* Text Input Fallback */
.va-text-input {
    display: flex;
    gap: 8px;
}

.va-text-input input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.va-text-input input:focus {
    border-color: var(--va-primary);
}

.va-text-submit {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--va-primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.va-text-submit:hover {
    background: var(--va-primary-light);
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 480px) {
    .va-fab {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
        font-size: 20px;
    }

    .va-modal {
        padding: 0;
        align-items: flex-end;
        justify-content: stretch;
    }

    .va-modal-content {
        max-width: 100%;
        border-radius: var(--va-radius) var(--va-radius) 0 0;
        max-height: 60vh;
    }
}

/* ========================================
   Accessibility
   ======================================== */
@media (prefers-reduced-motion: reduce) {

    .va-fab,
    .va-modal,
    .va-modal-content,
    .va-wave,
    .va-fab-pulse {
        animation: none !important;
        transition: none !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .va-modal-content {
        background: white;
        border: 2px solid var(--va-primary);
    }

    .va-ai-text {
        background: #e0e0e0;
    }
}

/* ========================================
   Print - Hide voice assistant
   ======================================== */
@media print {
    #multicalc-voice-assistant {
        display: none !important;
    }
}