/* Modern Voice Widget Styles - Matching Website Theme */

.modern-voice-widget {
    width: 340px !important;
    max-width: 95vw;
    max-height: 85vh;
    background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.98) 100%) !important;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(30, 58, 138, 0.15);
    box-shadow: 0 12px 40px rgba(30, 58, 138, 0.12), 0 0 0 1px rgba(255,255,255,0.5) inset !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.voice-modal-header.minimal {
    padding: 0.75rem 1rem !important;
    border-bottom: 1px solid rgba(30, 58, 138, 0.1) !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent !important;
    min-height: auto;
}

.sara-status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    transition: all 0.3s ease;
}

.status-dot.active {
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.status-dot.active.speaking {
    background: #1e3a8a; /* --primary */
    animation: pulse 1.5s infinite;
}

.status-text {
    font-size: 0.7rem;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Segoe UI', sans-serif;
}

.close-modal.minimal {
    background: transparent !important;
    border: none !important;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    color: #9ca3af;
}

.close-modal.minimal:hover {
    background: rgba(30, 58, 138, 0.1) !important; /* --primary */
    color: #1e3a8a; /* --primary */
}

/* Avatar Section */
.voice-avatar-section {
    padding: 1rem 1rem 0.75rem;
    text-align: center;
}

.sara-avatar-container {
    position: relative;
    width: 60px;
    height: 60px;
    margin: 0 auto 0.5rem;
}

.sara-avatar {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.2);
    z-index: 2;
}

.sara-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: all 0.3s ease;
    border-radius: 50%;
}

/* Fallback for img without class */
.sara-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: all 0.3s ease;
    border-radius: 50%;
}

/* Rainbow Border Animation - Beautiful flowing multi-colored border around Sara */
.voice-pulse {
    position: absolute;
    width: calc(100% + 8px);
    height: calc(100% + 8px);
    top: -4px;
    left: -4px;
    border-radius: 50%;
    background: linear-gradient(
        90deg,
        #ff6b6b 0%,
        #4ecdc4 16.67%,
        #45b7d1 33.33%,
        #96ceb4 50%,
        #feca57 66.67%,
        #ff9ff3 83.33%,
        #54a0ff 100%
    );
    background-size: 200% 100%;
    animation: rainbow-flow 3s ease-in-out infinite;
    z-index: 1;
}

@keyframes rainbow-flow {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* Add subtle glow effect to rainbow border */
.voice-pulse::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border-radius: 50%;
    background: linear-gradient(
        90deg,
        rgba(255, 107, 107, 0.3) 0%,
        rgba(78, 205, 196, 0.3) 16.67%,
        rgba(69, 183, 209, 0.3) 33.33%,
        rgba(150, 206, 180, 0.3) 50%,
        rgba(254, 202, 87, 0.3) 66.67%,
        rgba(255, 159, 243, 0.3) 83.33%,
        rgba(84, 160, 255, 0.3) 100%
    );
    background-size: 200% 100%;
    animation: rainbow-flow 3s ease-in-out infinite;
    filter: blur(1px);
    z-index: -1;
    opacity: 0.6;
}

/* Speaking animation for when AI is talking - Beautiful glow effect */
.voice-chat-button.speaking {
    animation: speaking-pulse 1s ease-in-out infinite alternate;
}

.voice-chat-button.speaking .sara-avatar {
    animation: speaking-pulse 1s ease-in-out infinite alternate;
}

@keyframes speaking-pulse {
    0% { 
        box-shadow: 0 10px 30px rgba(0,0,0,0.3), 0 0 20px rgba(255, 107, 107, 0.5);
        border-color: rgba(255, 255, 255, 0.2);
    }
    100% { 
        box-shadow: 0 15px 40px rgba(0,0,0,0.4), 0 0 30px rgba(255, 107, 107, 0.8);
        border-color: rgba(255, 255, 255, 0.4);
    }
}

/* Hover effect for Sara avatar image */
.voice-chat-button:hover .sara-avatar-image {
    transform: scale(1.05);
}

.sara-modal-avatar.modern {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    position: relative;
    z-index: 2;
}

.voice-ripple-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.sara-avatar-container.speaking .ripple {
    animation: rippleOut 2s infinite;
}

.ripple {
    position: absolute;
    border: 2px solid rgba(30, 58, 138, 0.4); /* --primary */
    border-radius: 50%;
    width: 100%;
    height: 100%;
    opacity: 0;
}

.ripple:nth-child(2) { animation-delay: 0.5s; }
.ripple:nth-child(3) { animation-delay: 1s; }

@keyframes rippleOut {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.sara-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0;
    font-family: 'Segoe UI', sans-serif;
}

.sara-role {
    font-size: 0.875rem;
    color: #64748b;
}

/* Voice Visualization */
.voice-visualization {
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 40px;
    background: rgba(30, 58, 138, 0.02);
    border-top: 1px solid rgba(30, 58, 138, 0.08);
    border-bottom: 1px solid rgba(30, 58, 138, 0.08);
}

.frequency-bars {
    display: flex;
    gap: 4px;
    align-items: center;
    height: 40px;
}

.freq-bar {
    width: 3px;
    background: linear-gradient(to top, #1e3a8a, #06b6d4); /* --primary to --accent */
    border-radius: 2px;
    transition: all 0.2s ease;
    opacity: 0.3;
}

.voice-visualization.active .freq-bar {
    opacity: 1;
    animation: wave 1s ease-in-out infinite;
}

.voice-visualization.listening .freq-bar {
    opacity: 0.7;
    animation: wave 2s ease-in-out infinite;
}

.voice-visualization.speaking .freq-bar {
    opacity: 1;
    animation: wave 0.6s ease-in-out infinite;
    filter: drop-shadow(0 0 4px rgba(59, 130, 246, 0.4));
}

.voice-visualization.thinking .freq-bar {
    opacity: 0.5;
    animation: pulse-wave 1.5s ease-in-out infinite;
}

.freq-bar:nth-child(1) { height: 20px; animation-delay: 0s; }
.freq-bar:nth-child(2) { height: 30px; animation-delay: 0.1s; }
.freq-bar:nth-child(3) { height: 25px; animation-delay: 0.2s; }
.freq-bar:nth-child(4) { height: 35px; animation-delay: 0.3s; }
.freq-bar:nth-child(5) { height: 25px; animation-delay: 0.4s; }
.freq-bar:nth-child(6) { height: 30px; animation-delay: 0.5s; }
.freq-bar:nth-child(7) { height: 20px; animation-delay: 0.6s; }

.freq-bar.agent {
    background: linear-gradient(to top, #1e3a8a, #06b6d4); /* --primary to --accent */
}

.freq-bar.user {
    background: linear-gradient(to top, #10b981, #06b6d4); /* Keep green for user */
}

@keyframes wave {
    0%, 100% { 
        transform: scaleY(0.3);
        opacity: 0.6;
    }
    25% { 
        transform: scaleY(0.8);
        opacity: 0.8;
    }
    50% { 
        transform: scaleY(1.4);
        opacity: 1;
    }
    75% { 
        transform: scaleY(1.0);
        opacity: 0.9;
    }
}

/* Transcript Container - Minimal Design */
.voice-transcript-container {
    padding: 0.75rem;
    min-height: 80px;
    max-height: 140px;
    overflow-y: auto;
    background: rgba(248, 250, 252, 0.3);
    font-family: 'Segoe UI', sans-serif;
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(30, 58, 138, 0.2) transparent;
}

.voice-transcript-container::-webkit-scrollbar {
    width: 4px;
}

.voice-transcript-container::-webkit-scrollbar-track {
    background: transparent;
}

.voice-transcript-container::-webkit-scrollbar-thumb {
    background: rgba(30, 58, 138, 0.3); /* --primary */
    border-radius: 2px;
}

.voice-transcript-container::-webkit-scrollbar-thumb:hover {
    background: rgba(30, 58, 138, 0.5); /* --primary */
}

.transcript-messages {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.transcript-message {
    padding: 0.375rem 0;
    animation: slideIn 0.3s ease;
    font-family: 'Segoe UI', sans-serif;
    transition: opacity 0.2s ease;
}

.transcript-message:hover {
    opacity: 0.8;
}

.transcript-message.agent {
    border-left: 2px solid #1e3a8a;
    padding-left: 0.5rem;
    margin: 0;
}

.transcript-message.user {
    border-left: 2px solid #10b981;
    padding-left: 0.5rem;
    margin: 0;
}

.message-speaker {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.125rem;
    opacity: 0.7;
    font-family: 'Segoe UI', sans-serif;
}


.transcript-message.agent .message-speaker {
    color: #1e3a8a; /* --primary */
}

.transcript-message.user .message-speaker {
    color: #10b981;
}

.message-text {
    font-size: 0.8rem;
    line-height: 1.4;
    color: #374151;
    font-weight: 400;
    font-family: 'Segoe UI', sans-serif;
}

.transcript-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
    color: #9ca3af;
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.7;
    text-align: center;
    font-family: 'Segoe UI', sans-serif;
    background: rgba(248, 250, 252, 0.5);
    border-radius: 6px;
    border: 1px solid rgba(30, 58, 138, 0.08);
    transition: opacity 0.2s ease;
}

.transcript-placeholder:hover {
    opacity: 0.9;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Compact Action Button */
.voice-action-btn {
    width: calc(100% - 1.5rem);
    margin: 0.75rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, #1e3a8a, #06b6d4);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.2);
    font-family: 'Segoe UI', sans-serif;
}

.voice-action-btn:hover {
    transform: translateY(-1px);
    background: linear-gradient(135deg, #06b6d4, #1e3a8a);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}

.voice-action-btn.active {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.voice-action-btn.connecting {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    cursor: not-allowed;
    opacity: 0.8;
}

.connecting-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
    50% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.1); }
}

@keyframes pulse-wave {
    0%, 100% { 
        transform: scaleY(0.4);
        opacity: 0.4;
    }
    50% { 
        transform: scaleY(0.8);
        opacity: 0.7;
    }
}

/* HORIZONTAL VOICE CONTROL BAR - Emerges from Sara */

/* Main horizontal bar container - Minimal & Transparent */
.voice-control-bar {
    position: fixed;
    bottom: 20px;
    right: 90px;
    left: auto;
    width: 220px;
    height: 60px;
    background: transparent;
    transform: scaleX(0);
    transform-origin: right center;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
    font-family: 'Segoe UI', sans-serif;
}

.voice-control-bar.active {
    transform: scaleX(1);
}

.bar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 100%;
    width: 100%;
    gap: 0.75rem;
}

/* Waveform Visualization */
.voice-waveform {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 40px;
    padding: 0 1rem;
}

.wave-bar {
    width: 3px;
    background: linear-gradient(to top, #1e3a8a, #06b6d4);
    border-radius: 2px;
    transition: all 0.2s ease;
    opacity: 0.3;
    height: 12px;
}

.voice-waveform.speaking .wave-bar {
    opacity: 1;
    animation: waveform 0.8s ease-in-out infinite;
}

.voice-waveform.listening .wave-bar {
    opacity: 0.6;
    animation: waveform 1.5s ease-in-out infinite;
}

.wave-bar:nth-child(1) { 
    animation-delay: 0s; 
    height: 16px;
}
.wave-bar:nth-child(2) { 
    animation-delay: 0.1s; 
    height: 24px;
}
.wave-bar:nth-child(3) { 
    animation-delay: 0.2s; 
    height: 20px;
}
.wave-bar:nth-child(4) { 
    animation-delay: 0.3s; 
    height: 28px;
}
.wave-bar:nth-child(5) { 
    animation-delay: 0.4s; 
    height: 16px;
}

@keyframes waveform {
    0%, 100% { 
        transform: scaleY(0.5);
        opacity: 0.3;
    }
    50% { 
        transform: scaleY(1.2);
        opacity: 1;
    }
}

/* Horizontal Control Buttons */
.voice-controls-horizontal {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

/* Call Timer Display */
.call-timer {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e3a8a;
    background: rgba(255, 255, 255, 0.95);
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    border: 1px solid rgba(30, 58, 138, 0.2);
    backdrop-filter: blur(10px);
    min-width: 55px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-family: 'Segoe UI', sans-serif;
    letter-spacing: 0.5px;
}

.control-btn-round {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Segoe UI', sans-serif;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.control-btn-round.mute-btn {
    background: rgba(255, 255, 255, 0.95);
    color: #1e3a8a;
    border: 2px solid rgba(30, 58, 138, 0.2);
    backdrop-filter: blur(10px);
}

.control-btn-round.mute-btn.muted {
    background: rgba(239, 68, 68, 0.95);
    color: white;
    border: 2px solid rgba(239, 68, 68, 0.3);
}

.control-btn-round.mute-btn:not(.muted) {
    background: rgba(34, 197, 94, 0.95);
    color: white;
    border: 2px solid rgba(34, 197, 94, 0.3);
}

.control-btn-round.mute-btn:not(.muted):hover {
    background: rgba(34, 197, 94, 0.8);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

/* Muted Microphone with Slash */
.mic-muted-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slash-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.slash-line {
    width: 20px;
    height: 2px;
    background: white;
    transform: rotate(45deg);
    border-radius: 1px;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

/* Active Microphone with Animation */
.mic-active-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mic-fill-bar {
    transform-origin: bottom;
}

/* Pause animation when not speaking */
.control-btn-round.mute-btn:not(.speaking) .mic-fill-bar {
    animation-play-state: paused;
    height: 2px !important;
    transform: translateY(10px) !important;
}


.control-btn-round.mute-btn.muted:hover {
    background: rgba(220, 38, 38, 0.95);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.control-btn-round.end-call-btn {
    background: rgba(239, 68, 68, 0.95);
    color: white;
    border: 2px solid rgba(239, 68, 68, 0.3);
    backdrop-filter: blur(10px);
}

.control-btn-round.end-call-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Status Text */
.call-status-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: #1e3a8a;
    background: rgba(30, 58, 138, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid rgba(30, 58, 138, 0.15);
}

/* Red Circle Indicator for Sara Widget */
.call-active-ring {
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 3px solid #ef4444;
    border-radius: 50%;
    animation: callActivePulse 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes callActivePulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

/* Mobile Responsive for Minimal Bar */
@media (max-width: 768px) {
    .voice-control-bar {
        width: 180px;
        height: 50px;
        bottom: 15px;
        right: 75px;
    }
    
    .control-btn-round {
        width: 36px;
        height: 36px;
    }
    
    .control-btn-round svg {
        width: 14px;
        height: 14px;
    }
    
    .voice-controls-horizontal {
        gap: 0.375rem;
    }
    
    .call-timer {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
        min-width: 50px;
    }
    
    .bar-content {
        padding: 0 0.75rem;
        gap: 0.5rem;
    }
}

/* Enhanced Sara Widget - Perfectly Aligned */
.voice-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

/* Disable all Sara animations when voice bar is inactive */
.voice-chat-button {
    animation: none !important;
}

/* Make Sara feel connected to the expanding bar */
.voice-chat-button.call-active {
    z-index: 10000;
}

/* Subtle connection line effect */
.voice-chat-button.call-active::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -10px;
    width: 10px;
    height: 2px;
    background: linear-gradient(to right, rgba(30, 58, 138, 0.3), transparent);
    transform: translateY(-50%);
    transition: opacity 0.4s ease;
    opacity: 1;
}

/* Mobile positioning alignment */
@media (max-width: 768px) {
    .voice-chat-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .voice-chat-button.call-active::after {
        right: -8px;
        width: 8px;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .modern-voice-widget {
        width: 320px !important;
        max-height: 80vh;
    }
    
    .voice-avatar-section {
        padding: 0.75rem 1rem 0.5rem;
    }
    
    .sara-avatar-container {
        width: 50px;
        height: 50px;
        margin-bottom: 0.25rem;
    }
    
    .sara-modal-avatar.modern {
        width: 50px;
        height: 50px;
    }
    
    .voice-transcript-container {
        max-height: 100px;
        min-height: 60px;
    }
    
    .voice-visualization {
        height: 30px;
        padding: 0.5rem;
    }
    
    .voice-action-btn {
        padding: 0.65rem;
        font-size: 0.8rem;
    }
}