/* Streaming Voice Translation Interface - Ultra Modern Design */

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

:root {
    --primary-color: #00ff88;
    --secondary-color: #0066ff;
    --error-color: #ff4444;
    --warning-color: #ffaa00;
    --background-dark: #0a0a0a;
    --background-card: #1a1a1a;
    --background-light: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    --border-color: #333333;
    --accent-gradient: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    --success-gradient: linear-gradient(135deg, #00ff88, #00cc66);
    --error-gradient: linear-gradient(135deg, #ff4444, #cc2222);
    --shadow-light: 0 4px 16px rgba(0, 255, 136, 0.1);
    --shadow-heavy: 0 8px 32px rgba(0, 255, 136, 0.2);
}

body {
    font-family: 'Segoe UI', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    animation: fadeIn 0.6s ease-out;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 30px rgba(0, 255, 136, 0.3);
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

/* Connection Status */
.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--background-card);
    border-radius: 25px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.status-indicator.connected {
    background: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
    animation: pulse 2s infinite;
}

.status-indicator.disconnected {
    background: var(--text-muted);
}

.status-indicator.error {
    background: var(--error-color);
    box-shadow: 0 0 10px var(--error-color);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

/* Configuration Section */
.config-section {
    background: var(--background-card);
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
}

.config-section h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.config-group {
    display: flex;
    flex-direction: column;
}

.config-group label {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.config-group select {
    background: var(--background-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.config-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 255, 136, 0.2);
}

/* Controls Section */
.controls-section {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.control-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.start-btn {
    background: var(--success-gradient);
    color: white;
    box-shadow: var(--shadow-light);
}

.start-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-heavy);
}

.start-btn.active {
    animation: glow 2s infinite alternate;
}

.stop-btn {
    background: var(--error-gradient);
    color: white;
}

.stop-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(255, 68, 68, 0.3);
}

.record-btn {
    background: var(--background-light);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.record-btn.recording {
    background: var(--error-color);
    color: white;
    animation: recordingPulse 1s infinite;
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

@keyframes glow {
    from { box-shadow: var(--shadow-light); }
    to { box-shadow: var(--shadow-heavy), 0 0 30px rgba(0, 255, 136, 0.4); }
}

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

/* Visualization Section */
.visualization-section {
    background: var(--background-card);
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
}

.waveform-container {
    position: relative;
    height: 120px;
    background: var(--background-dark);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

#waveformCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.volume-meter {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.volume-bar {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.1s ease;
    border-radius: 3px;
    box-shadow: 0 0 10px currentColor;
}

/* Results Section */
.results-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.result-card {
    background: var(--background-card);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-heavy);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.result-header h3 {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
}

.latency-badge {
    background: var(--background-light);
    color: var(--primary-color);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.result-content {
    background: var(--background-dark);
    padding: 1rem;
    border-radius: 8px;
    min-height: 60px;
    border: 1px solid var(--border-color);
    font-size: 1rem;
    line-height: 1.5;
    position: relative;
    overflow-wrap: break-word;
}

.result-content.partial {
    border-left: 4px solid var(--warning-color);
    background: rgba(255, 170, 0, 0.05);
}

.placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.progress-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 0 0 16px 16px;
}

.progress-indicator.active {
    animation: progressSlide 0.5s ease;
}

@keyframes progressSlide {
    from { width: 0%; }
    to { width: 100%; }
}

/* Audio Controls */
.audio-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#audioPlayer {
    width: 100%;
    background: var(--background-dark);
    border-radius: 8px;
}

.audio-chunks {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.audio-chunk {
    background: var(--background-light);
    color: var(--primary-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    animation: chunkAppear 0.3s ease;
}

@keyframes chunkAppear {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* Metrics Section */
.metrics-section {
    background: var(--background-card);
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
}

.metrics-section h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.metric-card {
    background: var(--background-dark);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
}

.metric-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.metric-value {
    color: var(--primary-color);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

.metric-unit {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Debug Section */
.debug-section {
    background: var(--background-card);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
}

.debug-section h3 {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.debug-log {
    background: var(--background-dark);
    padding: 1rem;
    border-radius: 8px;
    height: 200px;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    border: 1px solid var(--border-color);
}

.log-entry {
    margin-bottom: 0.25rem;
    padding: 0.1rem 0;
    color: var(--text-secondary);
}

.log-entry.error {
    color: var(--error-color);
}

.log-entry.warning {
    color: var(--warning-color);
}

.log-entry.info {
    color: var(--text-secondary);
}

/* Scrollbar Styling */
.debug-log::-webkit-scrollbar {
    width: 6px;
}

.debug-log::-webkit-scrollbar-track {
    background: var(--background-light);
    border-radius: 3px;
}

.debug-log::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.debug-log::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .config-grid {
        grid-template-columns: 1fr;
    }
    
    .controls-section {
        flex-direction: column;
        align-items: center;
    }
    
    .control-btn {
        width: 100%;
        max-width: 300px;
    }
    
    .results-section {
        grid-template-columns: 1fr;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .metric-value {
        font-size: 1.5rem;
    }
    
    .waveform-container {
        height: 80px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for accessibility */
button:focus,
select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --background-dark: #000000;
        --background-card: #111111;
        --text-primary: #ffffff;
        --border-color: #666666;
    }
}