/**
 * AI Voice Support - CSS Styles
 * 
 * Modern Dark Glassmorphism Theme with Canvas Visualizer,
 * Pulsing Glow Effects, and Floating Avatar Launcher.
 * 
 * @version 2.5.0
 * @author Mark Nader Kamel
 */

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
    --ai-primary-color: #f7931e;
    --ai-primary-dark: #d6790b;
    --ai-primary-light: rgba(247, 147, 30, 0.25);
    --ai-accent-cyan: #00ffff;
    --ai-accent-purple: #8b5cf6;
    --ai-accent-purple-dark: #6366f1;
    --ai-bg-overlay: rgba(8, 10, 18, 0.88);
    --ai-bg-modal: #161a2b;
    --ai-bg-card: rgba(22, 27, 43, 0.95);
    --ai-text-primary: #ffffff;
    --ai-text-secondary: rgba(255, 255, 255, 0.72);
    --ai-success: #10b981;
    --ai-error: #ef4444;
    --ai-warning: #f59e0b;
    --ai-border: rgba(255, 255, 255, 0.12);
    --ai-border-radius: 24px;
}

/* ============================================================
   FLOATING AVATAR LAUNCHER & SPEECH BUBBLE
   ============================================================ */
.ai-floating-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    user-select: none;
}

/* Speech Bubble Label */
.ai-floating-label {
    background: linear-gradient(135deg, var(--ai-accent-purple), var(--ai-accent-purple-dark));
    color: #ffffff;
    padding: 7px 15px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 18px rgba(139, 92, 246, 0.45);
    animation: aiLabelFloat 3.2s ease-in-out infinite;
    position: relative;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.ai-floating-label::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 7px solid var(--ai-accent-purple-dark);
}

@keyframes aiLabelFloat {
    0%, 100% { transform: translateY(0); opacity: 1; }
    50% { transform: translateY(-5px); opacity: 0.92; }
}

/* Circular Avatar Button */
.ai-floating-btn {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e1b4b, #312e81);
    border: 3px solid #a78bfa;
    outline: none;
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.45), 0 0 0 0 rgba(247, 147, 30, 0.4);
    cursor: pointer;
    overflow: hidden;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: aiGentleFloat 4s ease-in-out infinite;
}

.ai-floating-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 12px 40px rgba(139, 92, 246, 0.6), 0 0 20px rgba(0, 255, 255, 0.5);
    border-color: var(--ai-accent-cyan);
    animation-play-state: paused;
}

.ai-floating-btn:active {
    transform: scale(0.96);
}

.ai-floating-btn .ai-btn-icon-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #ffffff;
    font-size: 26px;
    transition: transform 0.3s ease;
}

.ai-floating-btn:hover .ai-btn-icon-inner {
    transform: scale(1.1);
}

/* Animated Ring around Button */
.ai-floating-btn .pulse-ring {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 2px solid var(--ai-accent-cyan);
    animation: aiPulseRing 2.4s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    pointer-events: none;
    opacity: 0.6;
}

@keyframes aiPulseRing {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 0; }
    100% { transform: scale(0.95); opacity: 0; }
}

@keyframes aiGentleFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-6px) scale(1.02); }
}

/* ============================================================
   MODAL OVERLAY
   ============================================================ */
.ai-voice-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ai-bg-overlay);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
    box-sizing: border-box;
}

.ai-voice-modal.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================================
   MODAL CONTAINER (Glassmorphic)
   ============================================================ */
.ai-voice-container {
    background: var(--ai-bg-card);
    border-radius: var(--ai-border-radius);
    padding: 36px 32px;
    width: 100%;
    max-width: 460px;
    position: relative;
    text-align: center;
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.75), 0 0 0 1px var(--ai-border);
    transform: scale(0.92) translateY(20px);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.ai-voice-modal.active .ai-voice-container {
    transform: scale(1) translateY(0);
}

/* ============================================================
   AURORA & PULSE GLOW EFFECTS
   ============================================================ */
.ai-voice-glow {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 240px;
    height: 240px;
    background: radial-gradient(circle, var(--ai-primary-light) 0%, rgba(139, 92, 246, 0.15) 50%, transparent 70%);
    border-radius: 50%;
    filter: blur(50px);
    transition: all 0.6s ease;
    pointer-events: none;
    z-index: 0;
}

.ai-voice-modal.active .ai-voice-glow {
    animation: aiGlowPulse 2.8s ease-in-out infinite;
}

.ai-voice-glow.speaking {
    background: radial-gradient(circle, rgba(139, 92, 246, 0.4) 0%, rgba(247, 147, 30, 0.25) 50%, transparent 70%);
    width: 280px;
    height: 280px;
}

.ai-voice-glow.listening {
    background: radial-gradient(circle, rgba(0, 255, 255, 0.3) 0%, rgba(16, 185, 129, 0.2) 50%, transparent 70%);
}

@keyframes aiGlowPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
    50% { transform: translate(-50%, -50%) scale(1.25); opacity: 0.9; }
}

/* ============================================================
   CLOSE BUTTON
   ============================================================ */
.ai-voice-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--ai-text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    outline: none;
}

.ai-voice-close:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #ffffff;
    border-color: rgba(239, 68, 68, 0.5);
    transform: rotate(90deg);
}

/* ============================================================
   HEADER & AVATAR BADGE
   ============================================================ */
.ai-voice-header {
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
}

.ai-voice-avatar-badge {
    width: 60px;
    height: 60px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-primary-color), var(--ai-accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(247, 147, 30, 0.35);
    border: 2px solid rgba(255, 255, 255, 0.25);
}

.ai-voice-avatar-badge svg,
.ai-voice-avatar-badge i {
    color: #ffffff;
    font-size: 26px;
}

.ai-voice-header h3 {
    font-size: 22px;
    font-weight: 700;
    color: var(--ai-text-primary);
    margin: 0 0 6px 0;
    letter-spacing: -0.2px;
}

.ai-voice-header p {
    font-size: 13px;
    color: var(--ai-text-secondary);
    margin: 0;
}

/* ============================================================
   STATUS DISPLAY BADGE
   ============================================================ */
.ai-voice-status {
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    padding: 10px 20px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--ai-text-primary);
    margin: 14px auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
}

.ai-voice-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.ai-voice-status.connecting {
    color: var(--ai-warning);
    border-color: rgba(245, 158, 11, 0.3);
}

.ai-voice-status.connected,
.ai-voice-status.listening {
    color: var(--ai-accent-cyan);
    border-color: rgba(0, 255, 255, 0.3);
}

.ai-voice-status.speaking {
    color: var(--ai-primary-color);
    border-color: rgba(247, 147, 30, 0.4);
    animation: aiSpeakingPulse 1.2s ease-in-out infinite;
}

.ai-voice-status.error,
.ai-voice-status.disconnected {
    color: var(--ai-error);
    border-color: rgba(239, 68, 68, 0.3);
}

@keyframes aiSpeakingPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.03); opacity: 0.85; }
}

/* ============================================================
   CANVAS VISUALIZER
   ============================================================ */
.ai-voice-visualizer {
    width: 100%;
    height: 90px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 16px;
    margin: 16px 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-voice-visualizer canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ============================================================
   CSS WAVE ANIMATION (Fallback)
   ============================================================ */
.ai-voice-wave {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 40px;
    margin: 10px 0;
    position: relative;
    z-index: 1;
}

.ai-voice-wave.active {
    display: flex;
}

.ai-voice-wave span {
    width: 4px;
    height: 16px;
    background: linear-gradient(180deg, var(--ai-primary-color), var(--ai-accent-purple));
    border-radius: 2px;
    animation: aiWaveMotion 1s ease-in-out infinite;
}

.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.5s; }
.ai-voice-wave span:nth-child(7) { animation-delay: 0.6s; }

@keyframes aiWaveMotion {
    0%, 100% { height: 8px; }
    50% { height: 28px; }
}

/* ============================================================
   RESPONSE TRANSCRIPT AREA
   ============================================================ */
.ai-voice-response-area {
    min-height: 24px;
    margin: 8px 0 16px;
    position: relative;
    z-index: 1;
}

.ai-voice-response-area p {
    font-size: 13px;
    color: var(--ai-text-secondary);
    margin: 0;
    line-height: 1.4;
    max-height: 60px;
    overflow-y: auto;
}

/* ============================================================
   VOICE SELECTOR & CONTROLS
   ============================================================ */
.ai-voice-options {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 18px;
    position: relative;
    z-index: 1;
}

.ai-voice-options label {
    font-size: 12px;
    color: var(--ai-text-secondary);
    font-weight: 500;
}

.ai-voice-select {
    background: rgba(0, 0, 0, 0.4);
    color: #ffffff;
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    padding: 6px 12px;
    font-size: 12px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.ai-voice-select:hover,
.ai-voice-select:focus {
    border-color: var(--ai-primary-color);
}

.ai-voice-select option {
    background: #161a2b;
    color: #ffffff;
}

.ai-voice-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 10px 0 16px;
    position: relative;
    z-index: 1;
}

.ai-voice-end-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.35);
    transition: all 0.25s ease;
    outline: none;
}

.ai-voice-end-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.ai-voice-retry-btn {
    background: linear-gradient(135deg, var(--ai-primary-color), var(--ai-primary-dark));
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(247, 147, 30, 0.35);
    transition: all 0.25s ease;
    outline: none;
}

.ai-voice-retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(247, 147, 30, 0.5);
}

/* ============================================================
   CONTACT FOOTER LINK
   ============================================================ */
.ai-voice-contact {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--ai-text-secondary);
    text-decoration: none;
    margin-top: 6px;
    transition: color 0.2s ease;
    position: relative;
    z-index: 1;
}

.ai-voice-contact:hover {
    color: var(--ai-primary-color);
    text-decoration: underline;
}

/* ============================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================ */
@media (max-width: 576px) {
    .ai-floating-wrapper {
        bottom: 16px;
        right: 16px;
    }
    .ai-floating-btn {
        width: 58px;
        height: 58px;
    }
    .ai-floating-label {
        font-size: 11px;
        padding: 5px 12px;
    }
    .ai-voice-container {
        padding: 28px 20px;
    }
    .ai-voice-header h3 {
        font-size: 19px;
    }
    .ai-voice-visualizer {
        height: 75px;
    }
}
