/**
 * AI Voice Support - CSS Styles
 * 
 * Modern, animated modal styles for AI voice interactions.
 * Updated for Gemini Live API with canvas visualizer support.
 * 
 * @version 2.0.0
 */

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
    --ai-primary-color: #f7931e;
    --ai-primary-dark: #e08100;
    --ai-primary-light: rgba(247, 147, 30, 0.2);
    --ai-bg-overlay: rgba(0, 0, 0, 0.85);
    --ai-bg-modal: #1a1a2e;
    --ai-text-primary: #ffffff;
    --ai-text-secondary: rgba(255, 255, 255, 0.7);
    --ai-success: #22c55e;
    --ai-error: #ef4444;
    --ai-warning: #f59e0b;
    --ai-border-radius: 20px;
}

/* ============================================================
   MODAL OVERLAY
   ============================================================ */
.ai-voice-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ai-bg-overlay);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.ai-voice-modal.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================================
   MODAL CONTAINER
   ============================================================ */
.ai-voice-container {
    background: var(--ai-bg-modal);
    border-radius: var(--ai-border-radius);
    padding: 40px;
    width: 90%;
    max-width: 450px;
    position: relative;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
}

.ai-voice-modal.active .ai-voice-container {
    transform: scale(1) translateY(0);
}

/* ============================================================
   BACKGROUND GLOW EFFECT
   ============================================================ */
.ai-voice-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, var(--ai-primary-light) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(40px);
    transition: all 0.5s ease;
    pointer-events: none;
    z-index: 0;
}

.ai-voice-modal.active .ai-voice-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0.8;
    }
}

/* ============================================================
   CLOSE BUTTON
   ============================================================ */
.ai-voice-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--ai-text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.ai-voice-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--ai-text-primary);
    transform: rotate(90deg);
}

/* ============================================================
   HEADER
   ============================================================ */
.ai-voice-header {
    margin-bottom: 25px;
    position: relative;
    z-index: 1;
}

.ai-voice-header h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--ai-text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.ai-voice-header h3 i {
    color: var(--ai-primary-color);
}

.ai-voice-header p {
    font-size: 14px;
    color: var(--ai-text-secondary);
    margin: 0;
}

/* ============================================================
   STATUS DISPLAY
   ============================================================ */
.ai-voice-status {
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    padding: 12px 24px;
    border-radius: 25px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--ai-text-primary);
    margin: 15px auto;
    max-width: 300px;
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
}

.ai-voice-status.connecting {
    color: var(--ai-warning);
}

.ai-voice-status.connected {
    color: var(--ai-success);
}

.ai-voice-status.speaking {
    color: var(--ai-primary-color);
    animation: speaking-pulse 1s ease-in-out infinite;
}

.ai-voice-status.error {
    color: var(--ai-error);
}

@keyframes speaking-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* ============================================================
   CANVAS VISUALIZER
   ============================================================ */
.ai-voice-visualizer {
    width: 100%;
    max-width: 320px;
    height: 100px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    margin: 20px auto;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 1;
}

.ai-voice-visualizer canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ============================================================
   CSS WAVE ANIMATION (Fallback)
   ============================================================ */
.ai-voice-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 60px;
    margin: 20px 0;
    position: relative;
    z-index: 1;
}

.ai-voice-wave span {
    width: 4px;
    height: 20px;
    background: linear-gradient(180deg, var(--ai-primary-color), var(--ai-primary-dark));
    border-radius: 2px;
    animation: wave-idle 1.5s ease-in-out infinite;
}

.ai-voice-modal.active .ai-voice-wave span {
    animation: wave-active 0.5s ease-in-out infinite;
}

.ai-voice-wave span:nth-child(1) {
    animation-delay: 0s;
}

.ai-voice-wave span:nth-child(2) {
    animation-delay: 0.1s;
}

.ai-voice-wave span:nth-child(3) {
    animation-delay: 0.2s;
}

.ai-voice-wave span:nth-child(4) {
    animation-delay: 0.3s;
}

.ai-voice-wave span:nth-child(5) {
    animation-delay: 0.4s;
}

.ai-voice-wave span:nth-child(6) {
    animation-delay: 0.3s;
}

.ai-voice-wave span:nth-child(7) {
    animation-delay: 0.2s;
}

.ai-voice-wave span:nth-child(8) {
    animation-delay: 0.1s;
}

.ai-voice-wave span:nth-child(9) {
    animation-delay: 0s;
}

@keyframes wave-idle {

    0%,
    100% {
        height: 20px;
        opacity: 0.5;
    }

    50% {
        height: 30px;
        opacity: 0.7;
    }
}

@keyframes wave-active {

    0%,
    100% {
        height: 10px;
    }

    50% {
        height: 50px;
    }
}

/* ============================================================
   CONTROL BUTTONS
   ============================================================ */
.ai-voice-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 25px 0;
    position: relative;
    z-index: 1;
}

.ai-voice-end-btn,
.ai-voice-retry-btn {
    padding: 14px 28px;
    border-radius: 30px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-voice-end-btn {
    background: rgba(239, 68, 68, 0.2);
    color: var(--ai-error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.ai-voice-end-btn:hover {
    background: rgba(239, 68, 68, 0.4);
    transform: scale(1.05);
}

.ai-voice-retry-btn {
    background: var(--ai-primary-light);
    color: var(--ai-primary-color);
    border: 1px solid rgba(247, 147, 30, 0.3);
}

.ai-voice-retry-btn:hover {
    background: rgba(247, 147, 30, 0.4);
    transform: scale(1.05);
}

/* ============================================================
   RESPONSE DISPLAY
   ============================================================ */
.ai-voice-response-area {
    max-width: 400px;
    margin: 20px auto;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    min-height: 40px;
    position: relative;
    z-index: 1;
}

.ai-voice-response-area p {
    margin: 0;
    font-size: 14px;
    color: var(--ai-text-secondary);
    text-align: center;
    line-height: 1.5;
}

/* ============================================================
   CONTACT LINK
   ============================================================ */
.ai-voice-contact {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ai-text-secondary);
    text-decoration: none;
    font-size: 13px;
    padding: 10px 20px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
    margin-top: 15px;
    position: relative;
    z-index: 1;
}

.ai-voice-contact:hover {
    color: var(--ai-primary-color);
    background: rgba(255, 255, 255, 0.1);
}

.ai-voice-contact i {
    font-size: 14px;
}

/* ============================================================
   FLOATING AI WRAPPER
   ============================================================ */
.ai-floating-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Speech Bubble Label */
.ai-floating-label {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
    animation: labelFloat 3s ease-in-out infinite;
    position: relative;
}

.ai-floating-label::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #6366f1;
}

@keyframes labelFloat {

    0%,
    100% {
        transform: translateY(0);
        opacity: 1;
    }

    50% {
        transform: translateY(-5px);
        opacity: 0.9;
    }
}

/* ============================================================
   FLOATING TRIGGER BUTTON
   ============================================================ */
.ai-floating-btn {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    border: 4px solid #a78bfa;
    outline: none;
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.4);
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0;
    animation: gentleFloat 4s ease-in-out infinite;
}

@keyframes gentleFloat {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-8px) scale(1.02);
    }
}

.ai-floating-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 15px 50px rgba(139, 92, 246, 0.6);
    animation-play-state: paused;
}

.ai-floating-btn:focus {
    outline: none;
}

/* GIF Image in Floating Button */
.ai-floating-btn .ai-btn-gif {
    width: 140%;
    height: 140%;
    object-fit: cover;
    object-position: center top;
    border-radius: 0;
    pointer-events: none;
    margin-top: 15px;
}

/* Hide pulse ring completely */
.ai-floating-btn .pulse-ring {
    display: none !important;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* ============================================================
   RESPONSIVE STYLES
   ============================================================ */
@media (max-width: 480px) {
    .ai-voice-container {
        width: 95%;
        padding: 30px 20px;
    }

    .ai-voice-header h3 {
        font-size: 20px;
    }

    .ai-voice-status {
        font-size: 14px;
        padding: 10px 20px;
    }

    .ai-voice-controls {
        flex-direction: column;
        gap: 10px;
    }

    .ai-voice-end-btn,
    .ai-voice-retry-btn {
        width: 100%;
        justify-content: center;
    }

    .ai-floating-btn {
        bottom: 15px;
        right: 15px;
        width: 120px;
        height: 120px;
        font-size: 20px;
    }
}