/* ===== ENHANCED TYPING ANIMATION STYLES ===== */

/* Base typing bubble - moved from chatbox.css */
.bubble.typing {
  background: rgba(51, 51, 51, 0.3);
  animation: typingPulse 1s forwards;
  font-style: italic;
  color: var(--text-muted);
  border: 1px solid rgba(107, 114, 128, 0.3);
}

.bubble.typing:not(.enhanced)::after {
  content: '...';
  animation: typingDots 1.5s infinite;
}

/* Enhanced typing bubble */
.bubble.typing.enhanced {
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%) !important;
    border: 1px solid rgba(79, 195, 247, 0.4) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 20px rgba(79, 195, 247, 0.2) !important;
    animation: typingPulse 1s ease-in-out forwards !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    padding: 14px 18px !important;
    min-height: 42px !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    /* Prevent interference from other animations */
    z-index: 10;
    position: relative;
}

/* Enhanced processing bubble - matched styling with perfect centering */
.bubble.processing.enhanced {
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%) !important;
    border: 1px solid rgba(79, 195, 247, 0.4) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 20px rgba(79, 195, 247, 0.2) !important;
    animation: processingPulse 1s ease-in-out forwards !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    padding: 14px 18px !important;
    min-height: 42px !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    /* Prevent interference from other animations */
    z-index: 10;
    position: relative;
}

/* Override default typing bubble styles for enhanced version */
.bubble.typing.enhanced::after {
    content: none !important;
    animation: none !important;
}

/* Override default processing bubble styles for enhanced version */
.bubble.processing.enhanced::after {
    content: none !important;
    animation: none !important;
}

/* NOAH typing label - improved spacing */
.typing-label {
    color: #4fc3f7;
    font-size: 13px;
    font-weight: 500;
    text-shadow: 0 0 8px rgba(79, 195, 247, 0.4);
    opacity: 0.95;
    white-space: nowrap;
    flex-shrink: 0;
    animation: labelGlow 2.5s ease-in-out infinite;
}

/* NOAH processing label - matched styling */
.processing-label {
    color: #4fc3f7;
    font-size: 13px;
    font-weight: 500;
    text-shadow: 0 0 8px rgba(79, 195, 247, 0.4);
    opacity: 0.95;
    white-space: nowrap;
    flex-shrink: 0;
    animation: processingLabelGlow 3s ease-in-out infinite;
}

/* Brain icon - improved styling */
.brain-icon {
    font-size: 18px;
    color: #4fc3f7;
    filter: drop-shadow(0 0 6px rgba(79, 195, 247, 0.6));
    flex-shrink: 0;
    animation: brainPulse 2s ease-in-out infinite;
}

/* Processing icon - professional CPU/lightning styling */
.processing-icon {
    font-size: 20px;
    color: #4fc3f7;
    filter: drop-shadow(0 0 8px rgba(79, 195, 247, 0.8));
    flex-shrink: 0;
    animation: processingIconPulse 1.5s ease-in-out infinite;
    text-shadow: 0 0 12px rgba(79, 195, 247, 0.6);
}

/* Processing container - improved layout */
.processing-container {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

/* Typing dots container - improved spacing */
.typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
    margin-left: auto;
    padding-left: 8px;
}

/* Processing dots container - matched spacing */
.processing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
    margin-left: auto;
    padding-left: 8px;
}

/* Individual typing dots - improved uniformity */
.typing-dot {
    width: 7px;
    height: 7px;
    background: #4fc3f7;
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(79, 195, 247, 0.6);
}

/* Individual processing dots - matched styling */
.processing-dot {
    width: 7px;
    height: 7px;
    background: #4fc3f7;
    border-radius: 50%;
    animation: processingBounce 2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(79, 195, 247, 0.6);
}



/* Enhanced processing bubble pulse animation */


/* Base typing animations - moved from chatbox.css */
@keyframes typingPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

@keyframes typingDots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* Label glow animation */
@keyframes labelGlow {
    0%, 100% {
        text-shadow: 0 0 8px rgba(79, 195, 247, 0.4);
        opacity: 0.9;
    }
    50% {
        text-shadow: 0 0 15px rgba(79, 195, 247, 0.8);
        opacity: 1;
    }
}

/* Processing label glow animation */
@keyframes processingLabelGlow {
    0%, 100% {
        text-shadow: 0 0 10px rgba(79, 195, 247, 0.6);
        opacity: 0.95;
    }
    50% {
        text-shadow: 0 0 18px rgba(79, 195, 247, 0.9);
        opacity: 1;
    }
}

/* Processing icon pulse animation - professional effect */
@keyframes processingIconPulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 8px rgba(79, 195, 247, 0.8));
        text-shadow: 0 0 12px rgba(79, 195, 247, 0.6);
    }
    50% {
        transform: scale(1.15);
        filter: drop-shadow(0 0 16px rgba(79, 195, 247, 1));
        text-shadow: 0 0 20px rgba(79, 195, 247, 0.9);
    }
}

/* Enhanced typing dots bounce animation */
@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
        box-shadow: 0 0 10px rgba(79, 195, 247, 0.4);
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
        box-shadow: 0 0 15px rgba(79, 195, 247, 0.8);
    }
}

/* Enhanced processing dots bounce animation */
@keyframes processingBounce {
    0%, 70%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
        box-shadow: 0 0 12px rgba(79, 195, 247, 0.5);
    }
    35% {
        transform: translateY(-10px) scale(1.2);
        opacity: 1;
        box-shadow: 0 0 20px rgba(79, 195, 247, 0.9);
    }
}

/* Enhanced message appearance animation - ONLY for non-typing bubbles */
.bubble.bot:not(.typing) {
    animation: messageSlideIn 0.4s ease-out forwards !important;
    opacity: 1 !important;
    transform: translateY(0) scale(1) !important;
    visibility: visible !important;
    display: block !important;
    border-radius: 12px !important; /* Preserve border radius */
    border-bottom-left-radius: 4px !important; /* Preserve specific corner */
}

.bubble.user:not(.typing) {
    animation: messageSlideIn 0.3s ease-out forwards !important;
    opacity: 1 !important;
    transform: translateY(0) scale(1) !important;
    visibility: visible !important;
    display: block !important;
    border-radius: 12px !important; /* Preserve border radius */
    border-bottom-right-radius: 4px !important; /* Preserve specific corner */
}

@keyframes messageSlideIn {
    0% {
        transform: translateY(20px) scale(0.95) !important;
        opacity: 0 !important;
        border-radius: 12px !important; /* Maintain border radius during animation */
    }
    100% {
        transform: translateY(0) scale(1) !important;
        opacity: 1 !important;
        border-radius: 12px !important; /* Maintain border radius during animation */
    }
}

/* Sound feedback visual indicator */
.sound-feedback {
    position: relative;
    overflow: hidden;
}

.sound-feedback::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(79, 195, 247, 0.3), transparent);
    animation: soundWave 0.6s ease-out;
}

@keyframes soundWave {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Welcome message special styling */
.bubble.welcome-message {
    border: 1px solid rgba(79, 195, 247, 0.4);
    box-shadow: 0 0 15px rgba(79, 195, 247, 0.2);
    color: #a8d2ff;
}



/* Welcome pulse animation */
@keyframes welcomePulse {
    0%, 100% {
        box-shadow: 0 0 15px rgba(79, 195, 247, 0.2);
    }
    50% {
        box-shadow: 0 0 25px rgba(79, 195, 247, 0.4);
    }
}

/* AI Processing indicator - simplified without overflow issues */
.ai-processing:not(.typing) {
    position: relative;
    border: 1px solid rgba(79, 195, 247, 0.4);
    box-shadow: 
        0 0 8px rgba(79, 195, 247, 0.3),
        inset 0 0 8px rgba(79, 195, 247, 0.1);
    color: #a8d2ff;
}

/* Futuristic glow effects - simplified without overflow issues */
.futuristic-glow:not(.typing) {
    opacity: 1 !important;
    visibility: visible !important;
    box-shadow: 
        0 0 8px rgba(79, 195, 247, 0.4),
        0 0 15px rgba(79, 195, 247, 0.2),
        inset 0 0 8px rgba(79, 195, 247, 0.1);
    border: 1px solid rgba(79, 195, 247, 0.5);
    border-radius: 12px !important; /* Force preserve border radius */
    animation: futuristicPulse 3s ease-in-out infinite;
    color: #a8d2ff;
}

/* Ensure bot messages keep their specific border radius */
.bubble.bot.futuristic-glow:not(.typing) {
    border-bottom-left-radius: 4px !important;
}

/* Ensure user messages keep their specific border radius */
.bubble.user.futuristic-glow:not(.typing) {
    border-bottom-right-radius: 4px !important;
}

@keyframes futuristicPulse {
    0%, 100% {
        box-shadow: 
            0 0 5px rgba(79, 195, 247, 0.4),
            0 0 10px rgba(79, 195, 247, 0.3),
            0 0 15px rgba(79, 195, 247, 0.2),
            inset 0 0 5px rgba(79, 195, 247, 0.1);
        border-radius: 12px; /* Maintain border radius */
    }
    50% {
        box-shadow: 
            0 0 10px rgba(79, 195, 247, 0.6),
            0 0 20px rgba(79, 195, 247, 0.4),
            0 0 30px rgba(79, 195, 247, 0.3),
            inset 0 0 10px rgba(79, 195, 247, 0.2);
        border-radius: 12px; /* Maintain border radius */
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .typing-dot, .processing-dot {
        width: 6px;
        height: 6px;
    }
    
    .typing-label, .processing-label {
        font-size: 12px;
    }
    
    .brain-icon, .processing-icon {
        font-size: 16px;
    }
    
    .bubble.typing.enhanced, .bubble.processing.enhanced {
        padding: 12px 16px;
        gap: 10px;
        min-height: 38px;
    }
    
    .processing-container {
        gap: 10px;
    }
    
    .typing-dots, .processing-dots {
        gap: 4px;
        padding-left: 6px;
    }
}

@media (max-width: 480px) {
    .typing-dot, .processing-dot {
        width: 5px;
        height: 5px;
    }
    
    .typing-label, .processing-label {
        font-size: 11px;
    }
    
    .processing-icon {
        font-size: 14px;
    }
    
    .bubble.typing.enhanced, .bubble.processing.enhanced {
        padding: 10px 14px;
        gap: 8px;
        min-height: 36px;
    }
    
    .processing-container {
        gap: 8px;
    }
    
    .typing-dots, .processing-dots {
        gap: 3px;
        padding-left: 4px;
    }
}

/* Dark theme specific adjustments */
@media (prefers-color-scheme: dark) {
    .bubble.typing.enhanced {
        background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
        border-color: rgba(79, 195, 247, 0.5);
    }
    
    .bubble.processing.enhanced {
        background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
        border-color: rgba(79, 195, 247, 0.6);
    }
    
    .typing-dot {
        box-shadow: 0 0 12px rgba(79, 195, 247, 0.6);
    }
    
    .processing-dot {
        box-shadow: 0 0 14px rgba(79, 195, 247, 0.8);
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .typing-dot {
        background: #ffffff;
        box-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
    }
    
    .processing-dot {
        background: #4fc3f7;
        box-shadow: 0 0 10px rgba(79, 195, 247, 0.9);
    }
    
    .typing-label {
        color: #ffffff;
        text-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
    }
    
    .processing-label {
        color: #4fc3f7;
        text-shadow: 0 0 6px rgba(79, 195, 247, 0.8);
    }
    
    .processing-icon {
        color: #4fc3f7;
        filter: drop-shadow(0 0 6px rgba(79, 195, 247, 0.8));
    }
    
    .bubble.typing.enhanced {
        border-color: rgba(79, 195, 247, 0.8) !important;
    }
    
    .bubble.processing.enhanced {
        border-color: rgba(79, 195, 247, 0.9) !important;
    }
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
    .bubble.typing.enhanced {
        animation: none;
    }
    
    .bubble.processing.enhanced {
        animation: none;
    }
    
    .typing-dot {
        animation: none;
        opacity: 0.7;
    }
    
    .processing-dot {
        animation: none;
        opacity: 0.8;
    }
    
    .processing-icon {
        animation: none;
    }
    
    .bubble.bot, .bubble.user {
        animation: none;
    }
    
    .sound-feedback::after {
        animation: none;
    }
    
    .ai-processing::before {
        animation: none;
    }
    
    .futuristic-glow {
        animation: none;
    }
    
    .typing-label {
        animation: none;
    }
    
    .processing-label {
        animation: none;
    }
}