/* Custom styles for the realtime translation app */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Smooth transitions - optimized for performance */
* {
    transition: all 0.2s ease-in-out;
}

/* Performance optimizations */
#messagesContainer {
    will-change: scroll-position;
    contain: layout style;
    overflow-anchor: auto;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Pulse animation for speech status */
.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: .7;
    }
}

/* Custom scrollbar for messages */
#messagesContainer::-webkit-scrollbar {
    width: 6px;
}

#messagesContainer::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#messagesContainer::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

#messagesContainer::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Message bubbles - more compact */
.message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.75rem;
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(10px);
    opacity: 0;
    animation: slideIn 0.3s ease-out forwards;
    will-change: transform, opacity;
}

/* Fade-in animation for smooth message appearance */
.message-bubble.fade-in {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-original {
    font-size: 1.1rem;
    opacity: 0.7;
    margin-bottom: 0.3rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 0.3rem;
}

.message-translation {
    font-size: 1.5rem;
    font-weight: 500;
    line-height: 1.4;
}

.message-timestamp {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 0.3rem;
    text-align: right;
}

/* RTL support for current languages (Arabic, Farsi) */
#messages.rtl .message-translation,
#messages.rtl .message-original {
    text-align: right;
}

@keyframes slideIn {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Student list items */
.student-item {
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #f9fafb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.student-item:hover {
    background: #f3f4f6;
}

/* Loading spinner */
.spinner {
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toast notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #10b981;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease-out;
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    background: #ef4444;
}

/* Pulse animation for connection status */
.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Speech recognition specific styles */
.speech-listening {
    background: linear-gradient(45deg, #10b981, #059669);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.speech-button {
    position: relative;
    overflow: hidden;
}

.speech-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.speech-button:hover::before {
    width: 200px;
    height: 200px;
}

/* Live speech text animation */
.live-speech-text {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Microphone icon animation */
.mic-pulse {
    animation: micPulse 1.5s ease-in-out infinite;
}

@keyframes micPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Speech status indicator */
.speech-status-active {
    position: relative;
}

.speech-status-active::before {
    content: '';
    position: absolute;
    left: -15px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

/* Enhanced form styling */
input:focus, textarea:focus, select:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

/* Button hover effects */
button {
    position: relative;
    overflow: hidden;
}

button:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transition: width 0.3s, height 0.3s, top 0.3s, left 0.3s;
    transform: translate(-50%, -50%);
}

button:hover:before {
    width: 300px;
    height: 300px;
}

/* Responsive design improvements */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .message-bubble {
        margin-left: 0;
        margin-right: 0;
    }
    
    #messagesContainer {
        height: 300px;
    }
}
