:root {
    --primary-cyan: #00f5ff;
    --primary-purple: #bf00ff;
    --primary-blue: #0080ff;
    --glow-cyan: rgba(0, 245, 255, 0.6);
    --glow-purple: rgba(191, 0, 255, 0.6);
    --dark-bg: #0a0a1a;
    --darker-bg: #050510;
    --card-bg: rgba(15, 15, 35, 0.8);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --ring-speed: 4s;
    --voice-level: 0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Orbitron', 'Rajdhani', 'Segoe UI', sans-serif;
    background: var(--darker-bg);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* Import futuristic font */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700&family=Rajdhani:wght@400;500;600;700&display=swap');

/* Animated grid background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(90deg, rgba(0, 245, 255, 0.03) 1px, transparent 1px),
        linear-gradient(rgba(0, 245, 255, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: grid-move 20s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes grid-move {
    0% { transform: perspective(500px) rotateX(60deg) translateY(0); }
    100% { transform: perspective(500px) rotateX(60deg) translateY(50px); }
}

/* Radial gradient overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 0%, rgba(0, 128, 255, 0.15) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 80%, rgba(191, 0, 255, 0.1) 0%, transparent 40%),
                radial-gradient(ellipse at 20% 80%, rgba(0, 245, 255, 0.1) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

/* Floating particles */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--primary-cyan);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--glow-cyan), 0 0 20px var(--glow-cyan);
    animation: float-particle linear infinite;
    opacity: 0.6;
}

@keyframes float-particle {
    0% {
        transform: translateY(100vh) translateX(0) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
        transform: scale(1);
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(-100vh) translateX(100px) scale(0);
        opacity: 0;
    }
}

.container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Header */
.header {
    position: absolute;
    top: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 48px;
    filter: drop-shadow(0 0 20px var(--glow-cyan));
    animation: logo-pulse 3s ease-in-out infinite;
}

@keyframes logo-pulse {
    0%, 100% { filter: drop-shadow(0 0 20px var(--glow-cyan)); transform: scale(1); }
    50% { filter: drop-shadow(0 0 40px var(--glow-cyan)); transform: scale(1.05); }
}

.hospital-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-cyan);
    text-transform: uppercase;
    letter-spacing: 4px;
    text-shadow: 0 0 10px var(--glow-cyan), 0 0 20px var(--glow-cyan);
    animation: text-flicker 4s ease-in-out infinite;
}

@keyframes text-flicker {
    0%, 100% { opacity: 1; }
    92% { opacity: 1; }
    93% { opacity: 0.8; }
    94% { opacity: 1; }
    95% { opacity: 0.9; }
    96% { opacity: 1; }
}

/* Hexagonal frame around button */
.hex-frame {
    position: absolute;
    width: 320px;
    height: 320px;
    pointer-events: none;
    animation: hex-rotate 30s linear infinite;
}

.hex-frame svg {
    width: 100%;
    height: 100%;
}

@keyframes hex-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Call Button - Sci-Fi Core */
.call-button {
    position: relative;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(135deg,
        rgba(0, 245, 255, 0.2) 0%,
        rgba(0, 128, 255, 0.3) 50%,
        rgba(191, 0, 255, 0.2) 100%);
    backdrop-filter: blur(10px);
    border: 2px solid var(--primary-cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow:
        0 0 30px var(--glow-cyan),
        0 0 60px rgba(0, 245, 255, 0.3),
        inset 0 0 30px rgba(0, 245, 255, 0.1);
    animation: button-idle 3s ease-in-out infinite;
    z-index: 10;
}

@keyframes button-idle {
    0%, 100% {
        box-shadow:
            0 0 30px var(--glow-cyan),
            0 0 60px rgba(0, 245, 255, 0.3),
            inset 0 0 30px rgba(0, 245, 255, 0.1);
    }
    50% {
        box-shadow:
            0 0 50px var(--glow-cyan),
            0 0 80px rgba(0, 245, 255, 0.4),
            inset 0 0 40px rgba(0, 245, 255, 0.15);
    }
}

.call-button:hover {
    transform: scale(1.08);
    border-color: var(--primary-purple);
    box-shadow:
        0 0 40px var(--glow-purple),
        0 0 80px rgba(191, 0, 255, 0.4),
        inset 0 0 40px rgba(191, 0, 255, 0.15);
}

/* Rotating ring around button */
.call-button::before {
    content: '';
    position: absolute;
    inset: -15px;
    border-radius: 50%;
    border: 2px dashed rgba(0, 245, 255, 0.5);
    animation: ring-spin 8s linear infinite;
    pointer-events: none;
}

.call-button::after {
    content: '';
    position: absolute;
    inset: -30px;
    border-radius: 50%;
    border: 1px solid rgba(191, 0, 255, 0.3);
    animation: ring-spin 12s linear infinite reverse;
    pointer-events: none;
}

@keyframes ring-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Outer glow ring */
.outer-ring {
    position: absolute;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    border: 1px solid rgba(0, 245, 255, 0.2);
    animation: outer-ring-pulse 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes outer-ring-pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

/* Active Call State */
.call-button.active {
    width: 260px;
    height: 260px;
    cursor: default;
    background: linear-gradient(135deg,
        rgba(0, 245, 255, 0.3) 0%,
        rgba(0, 128, 255, 0.4) 50%,
        rgba(191, 0, 255, 0.3) 100%);
}

.call-button.active:hover {
    transform: scale(1);
}

/* Calling State */
.call-button.calling {
    animation: calling-pulse 1.5s ease-in-out infinite;
    border-color: #ffaa00;
    box-shadow:
        0 0 40px rgba(255, 170, 0, 0.6),
        0 0 80px rgba(255, 170, 0, 0.3),
        inset 0 0 30px rgba(255, 170, 0, 0.1);
}

@keyframes calling-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* AI Speaking State */
.call-button.ai-speaking {
    border-color: var(--primary-purple);
    background: linear-gradient(135deg,
        rgba(191, 0, 255, 0.3) 0%,
        rgba(128, 0, 255, 0.4) 50%,
        rgba(0, 128, 255, 0.3) 100%);
    box-shadow:
        0 0 50px var(--glow-purple),
        0 0 100px rgba(191, 0, 255, 0.4),
        inset 0 0 40px rgba(191, 0, 255, 0.15);
    animation: ai-speaking-glow 2s ease-in-out infinite;
}

@keyframes ai-speaking-glow {
    0%, 100% {
        box-shadow:
            0 0 50px var(--glow-purple),
            0 0 100px rgba(191, 0, 255, 0.4),
            inset 0 0 40px rgba(191, 0, 255, 0.15);
    }
    50% {
        box-shadow:
            0 0 70px var(--glow-purple),
            0 0 140px rgba(191, 0, 255, 0.5),
            inset 0 0 50px rgba(191, 0, 255, 0.2);
    }
}

/* User Speaking State */
.call-button.user-speaking {
    border-color: #00ff88;
    background: linear-gradient(135deg,
        rgba(0, 255, 136, 0.3) 0%,
        rgba(0, 200, 100, 0.4) 50%,
        rgba(0, 245, 255, 0.3) 100%);
    box-shadow:
        0 0 50px rgba(0, 255, 136, 0.6),
        0 0 100px rgba(0, 255, 136, 0.3),
        inset 0 0 40px rgba(0, 255, 136, 0.15);
}

/* Scanning line effect */
.scan-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-cyan), transparent);
    top: 0;
    left: 0;
    animation: scan 2s linear infinite;
    pointer-events: none;
    opacity: 0.5;
}

@keyframes scan {
    0% { top: 0; }
    100% { top: 100%; }
}

/* Icons */
.phone-icon,
.avatar,
.mic-icon {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s ease;
    z-index: 5;
}

.phone-icon svg,
.avatar svg,
.mic-icon svg {
    filter: drop-shadow(0 0 10px var(--glow-cyan));
    fill: var(--primary-cyan);
}

.hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

/* Avatar pulse animation when AI speaks */
.avatar.pulsing {
    animation: avatar-hologram 1.5s ease-in-out infinite;
}

.avatar.pulsing svg {
    fill: var(--primary-purple);
    filter: drop-shadow(0 0 15px var(--glow-purple));
}

@keyframes avatar-hologram {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.08); opacity: 0.9; }
}

/* Holographic glitch effect */
.avatar.pulsing::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(transparent 50%, rgba(191, 0, 255, 0.1) 50%);
    background-size: 100% 4px;
    animation: hologram-lines 0.1s linear infinite;
    pointer-events: none;
    opacity: 0.3;
}

@keyframes hologram-lines {
    0% { background-position: 0 0; }
    100% { background-position: 0 4px; }
}

/* Pulse Waves - Energy Rings */
.pulse-waves {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.pulse-wave {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid var(--primary-cyan);
    border-radius: 50%;
    animation: energy-ring 2.5s ease-out infinite;
    box-shadow: 0 0 20px var(--glow-cyan), inset 0 0 20px var(--glow-cyan);
}

.pulse-wave.wave-1 { animation-delay: 0s; }
.pulse-wave.wave-2 { animation-delay: 0.8s; }
.pulse-wave.wave-3 { animation-delay: 1.6s; }

@keyframes energy-ring {
    0% {
        width: 80px;
        height: 80px;
        opacity: 0.8;
        border-width: 3px;
    }
    100% {
        width: 350px;
        height: 350px;
        opacity: 0;
        border-width: 1px;
    }
}

/* Inward pulse for listening state */
.pulse-waves.inward .pulse-wave {
    animation: energy-ring-inward 2s ease-out infinite;
    border-color: #00ff88;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.6), inset 0 0 20px rgba(0, 255, 136, 0.3);
}

@keyframes energy-ring-inward {
    0% {
        width: 350px;
        height: 350px;
        opacity: 0;
    }
    100% {
        width: 80px;
        height: 80px;
        opacity: 0.8;
    }
}

/* Waveform - Voice Visualizer */
.waveform {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    height: 50px;
    width: 60%;
    z-index: 15;
    pointer-events: none;
}

.wave-bar {
    width: 6px;
    background: linear-gradient(to top, #00ff88, var(--primary-cyan));
    border-radius: 3px;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.8), 0 0 20px var(--glow-cyan);
    transition: height 0.05s ease;
    min-height: 4px;
}

.waveform.active .wave-bar {
    animation: wave-dance 0.5s ease-in-out infinite alternate;
}

.waveform.active .wave-bar:nth-child(1) { animation-delay: 0s; }
.waveform.active .wave-bar:nth-child(2) { animation-delay: 0.1s; }
.waveform.active .wave-bar:nth-child(3) { animation-delay: 0.2s; }
.waveform.active .wave-bar:nth-child(4) { animation-delay: 0.1s; }
.waveform.active .wave-bar:nth-child(5) { animation-delay: 0s; }

@keyframes wave-dance {
    0% { height: 10px; }
    100% { height: 40px; }
}

/* Action Text */
.action-text {
    position: absolute;
    bottom: 28%;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    color: var(--primary-cyan);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 0 10px var(--glow-cyan);
    transition: all 0.3s ease;
    pointer-events: none;
    animation: text-glow 2s ease-in-out infinite;
}

@keyframes text-glow {
    0%, 100% { text-shadow: 0 0 10px var(--glow-cyan); }
    50% { text-shadow: 0 0 20px var(--glow-cyan), 0 0 30px var(--glow-cyan); }
}

/* Status Text */
.status-text {
    position: absolute;
    top: 22%;
    font-family: 'Rajdhani', sans-serif;
    font-size: 18px;
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
    padding: 0 20px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* Background effects when call is active */
body.call-active::before {
    background:
        linear-gradient(90deg, rgba(191, 0, 255, 0.05) 1px, transparent 1px),
        linear-gradient(rgba(191, 0, 255, 0.05) 1px, transparent 1px);
    animation: grid-move 15s linear infinite;
}

/* Call Duration */
.call-duration {
    position: absolute;
    top: 40px;
    right: 40px;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    color: var(--primary-cyan);
    font-weight: 500;
    padding: 8px 16px;
    background: rgba(0, 245, 255, 0.1);
    border: 1px solid rgba(0, 245, 255, 0.3);
    border-radius: 4px;
    text-shadow: 0 0 10px var(--glow-cyan);
}

/* Assistant Name */
.assistant-name {
    position: absolute;
    bottom: 32%;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    color: var(--primary-purple);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 15px var(--glow-purple);
    pointer-events: none;
}

/* End Call Button */
.end-call-button {
    position: absolute;
    bottom: 50px;
    left: calc(50% - 90px);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff0055 0%, #ff3366 100%);
    border: 2px solid #ff0055;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.5), 0 0 40px rgba(255, 0, 85, 0.3);
}

.end-call-button:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(255, 0, 85, 0.7), 0 0 60px rgba(255, 0, 85, 0.4);
}

.end-call-button svg {
    fill: white;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
}

/* Mute button */
.mute-button {
    position: absolute;
    bottom: 50px;
    left: calc(50% + 30px);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(100, 100, 120, 0.3);
    border: 2px solid rgba(150, 150, 170, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(150, 150, 170, 0.3);
}

.mute-button:hover {
    background: rgba(120, 120, 140, 0.4);
    border-color: var(--primary-cyan);
    box-shadow: 0 0 20px var(--glow-cyan);
}

.mute-button svg {
    fill: white;
}

.mute-button .mute-off { display: none; }
.mute-button[aria-pressed="true"] .mute-on { display: none; }
.mute-button[aria-pressed="true"] .mute-off { display: block; }
.mute-button[aria-pressed="true"] {
    background: rgba(255, 0, 85, 0.3);
    border-color: #ff0055;
}

/* Interrupt badge */
.interrupt-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    padding: 6px 12px;
    border-radius: 4px;
    background: rgba(255, 170, 0, 0.2);
    border: 1px solid rgba(255, 170, 0, 0.5);
    color: #ffaa00;
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    z-index: 20;
    text-shadow: 0 0 10px rgba(255, 170, 0, 0.5);
}

.interrupt-badge.show {
    opacity: 1;
    transform: translateY(0);
}

/* Error state */
.call-button.error {
    animation: error-shake 0.5s ease;
    border-color: #ff0055 !important;
    box-shadow: 0 0 50px rgba(255, 0, 85, 0.6) !important;
}

@keyframes error-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}

/* Interrupt flash */
.call-button.interrupt-flash {
    animation: interrupt-glow 0.6s ease-out;
}

@keyframes interrupt-glow {
    0% { box-shadow: 0 0 0 0 rgba(255, 170, 0, 0.8); }
    100% { box-shadow: 0 0 0 40px rgba(255, 170, 0, 0); }
}

/* Conversation Display (Debug) */
.conversation-display {
    position: absolute;
    bottom: 140px;
    max-width: 70%;
    max-height: 180px;
    overflow-y: auto;
    background: rgba(10, 10, 30, 0.9);
    border: 1px solid rgba(0, 245, 255, 0.3);
    padding: 15px 20px;
    border-radius: 8px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 13px;
    color: var(--text-secondary);
    backdrop-filter: blur(10px);
}

.conversation-display::-webkit-scrollbar {
    width: 4px;
}

.conversation-display::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.conversation-display::-webkit-scrollbar-thumb {
    background: var(--primary-cyan);
    border-radius: 2px;
}

.conversation-display p {
    margin: 8px 0;
}

.conversation-display .user-message {
    color: #00ff88;
    font-weight: 600;
}

.conversation-display .ai-message {
    color: var(--primary-purple);
    font-weight: 600;
}

/* Hidden audio element */
#responseAudio {
    display: none;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .call-button {
        width: 180px;
        height: 180px;
    }

    .call-button.active {
        width: 230px;
        height: 230px;
    }

    .phone-icon svg {
        width: 56px;
        height: 56px;
    }

    .avatar svg {
        width: 70px;
        height: 70px;
    }

    .header {
        top: 30px;
    }

    .logo {
        font-size: 40px;
    }

    .hospital-name {
        font-size: 14px;
        letter-spacing: 2px;
    }

    .outer-ring {
        width: 240px;
        height: 240px;
    }
}

@media (max-width: 480px) {
    .call-button {
        width: 160px;
        height: 160px;
    }

    .call-button.active {
        width: 200px;
        height: 200px;
    }

    .phone-icon svg {
        width: 48px;
        height: 48px;
    }

    .avatar svg {
        width: 60px;
        height: 60px;
    }

    .conversation-display {
        max-width: 90%;
        font-size: 12px;
    }

    .end-call-button {
        width: 50px;
        height: 50px;
        left: calc(50% - 70px);
    }

    .mute-button {
        width: 45px;
        height: 45px;
        left: calc(50% + 20px);
    }

    .outer-ring {
        width: 220px;
        height: 220px;
    }
}

/* Corner decorations */
.corner-decoration {
    position: fixed;
    width: 100px;
    height: 100px;
    pointer-events: none;
    z-index: 5;
}

.corner-decoration.top-left {
    top: 20px;
    left: 20px;
    border-top: 2px solid var(--primary-cyan);
    border-left: 2px solid var(--primary-cyan);
    box-shadow: -5px -5px 20px var(--glow-cyan);
}

.corner-decoration.top-right {
    top: 20px;
    right: 20px;
    border-top: 2px solid var(--primary-cyan);
    border-right: 2px solid var(--primary-cyan);
    box-shadow: 5px -5px 20px var(--glow-cyan);
}

.corner-decoration.bottom-left {
    bottom: 20px;
    left: 20px;
    border-bottom: 2px solid var(--primary-purple);
    border-left: 2px solid var(--primary-purple);
    box-shadow: -5px 5px 20px var(--glow-purple);
}

.corner-decoration.bottom-right {
    bottom: 20px;
    right: 20px;
    border-bottom: 2px solid var(--primary-purple);
    border-right: 2px solid var(--primary-purple);
    box-shadow: 5px 5px 20px var(--glow-purple);
}

/* Data stream effect in corners */
.data-stream {
    position: fixed;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: rgba(0, 245, 255, 0.4);
    writing-mode: vertical-rl;
    pointer-events: none;
    z-index: 2;
    animation: data-scroll 20s linear infinite;
}

.data-stream.left {
    left: 30px;
    top: 150px;
    height: calc(100% - 300px);
}

.data-stream.right {
    right: 30px;
    top: 150px;
    height: calc(100% - 300px);
    animation-direction: reverse;
}

@keyframes data-scroll {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}
