/* Custom styles for Flask App */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.5rem;
}

.jumbotron {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
}

.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow 0.15s ease-in-out;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.error-page {
    padding: 2rem 0;
}

.error-page h1 {
    font-size: 8rem;
    font-weight: 300;
    margin-bottom: 0;
}

.btn {
    border-radius: 0.375rem;
    padding: 0.5rem 1rem;
    transition: all 0.15s ease-in-out;
}

.btn:hover {
    transform: translateY(-1px);
}

code {
    background-color: #f8f9fa;
    color: #e83e8c;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

#api-result {
    min-height: 100px;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.alert {
    border: none;
    border-radius: 0.5rem;
}

footer {
    margin-top: auto;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .error-page h1 {
        font-size: 4rem;
    }
    
    .jumbotron {
        padding: 2rem !important;
    }
    
    .display-4 {
        font-size: 2rem;
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Soniox Voice Recorder Styles */
.soniox-voice-recorder {
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 2rem 0;
}

.language-selector .language-select {
    max-width: 250px;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Chat Input Styles */
.chat-input-container {
    margin-bottom: 2rem;
}

.chat-input-wrapper {
    background: white;
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}

.chat-input {
    border: none;
    resize: none;
    font-size: 1.1rem;
    color: #495057;
    background: transparent;
    padding: 0.5rem 0;
}

.chat-input:focus {
    box-shadow: none;
    border: none;
    outline: none;
}

.chat-input::placeholder {
    color: #adb5bd;
    font-style: normal;
}

.recording-area {
    padding: 3rem 1rem;
}

.main-heading {
    font-size: 2.5rem;
    font-weight: 300;
    color: #2c3e50;
    margin-bottom: 3rem;
    line-height: 1.2;
}

.recording-btn {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border-radius: 50px;
    min-width: 200px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(13, 110, 253, 0.3);
}

.recording-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 110, 253, 0.4);
}

.recording-btn.recording {
    background-color: #dc3545;
    border-color: #dc3545;
    animation: pulse 2s infinite;
}

.recording-btn.recording:hover {
    background-color: #c82333;
    border-color: #c82333;
}

@keyframes pulse {
    0% { box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3); }
    50% { box-shadow: 0 4px 25px rgba(220, 53, 69, 0.6); }
    100% { box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3); }
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: #f8f9fa;
    border-radius: 25px;
    font-size: 0.9rem;
}

.status-indicator.recording {
    background-color: #fff5f5;
    color: #dc3545;
}

.status-indicator.recording i {
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* Audio Visualizer */
.audio-visualizer {
    margin: 2rem 0;
}

.wave-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3px;
    height: 60px;
}

.wave-bar {
    width: 4px;
    background: linear-gradient(to top, #007bff, #0056b3);
    border-radius: 2px;
    animation: wave 1.5s ease-in-out infinite;
}

.wave-bar:nth-child(2) { animation-delay: 0.1s; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; }
.wave-bar:nth-child(6) { animation-delay: 0.5s; }
.wave-bar:nth-child(7) { animation-delay: 0.6s; }
.wave-bar:nth-child(8) { animation-delay: 0.7s; }

@keyframes wave {
    0%, 100% { height: 10px; }
    50% { height: 50px; }
}

/* Transcript Styles */
.transcript-container {
    margin-top: 2rem;
    text-align: left;
}

.transcript-text {
    min-height: 100px;
    font-size: 1.1rem;
    line-height: 1.6;
    color: #2c3e50;
}

.interim-text {
    font-style: italic;
    opacity: 0.7;
    border-left: 3px solid #007bff;
    padding-left: 1rem;
    margin-top: 1rem;
}

/* Recording Info Cards */
.recording-info {
    margin-top: 3rem;
}

.info-card {
    padding: 1.5rem;
    background-color: #f8f9fa;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    transition: transform 0.2s ease;
}

.info-card:hover {
    transform: translateY(-2px);
}

.info-card i {
    font-size: 1.5rem;
}

.info-value {
    font-size: 1.8rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0.5rem 0;
}

.info-label {
    font-size: 0.9rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Instructions */
.instructions .card {
    background-color: #f8f9fa;
    border: none;
}

.instructions ul {
    padding-left: 1.2rem;
}

.instructions li {
    margin-bottom: 0.5rem;
    color: #495057;
}

/* Enhanced Transcript Display */
.transcript-display {
    min-height: 400px;
    max-height: 600px;
    overflow-y: auto;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 1.2rem;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    border: 2px solid #e3f2fd;
    position: relative;
    scroll-behavior: smooth;
}

.transcript-display::-webkit-scrollbar {
    width: 6px;
}

.transcript-display::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.transcript-display::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.transcript-display::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.transcript-content {
    font-size: 1.15rem;
    line-height: 1.7;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.transcript-segment {
    margin-bottom: 2rem;
    padding: 1rem 0;
    border-left: 4px solid transparent;
    padding-left: 1rem;
    animation: slideInText 0.4s ease-out;
    transition: all 0.3s ease;
}

.transcript-segment:hover {
    background: rgba(13, 110, 253, 0.02);
    border-left-color: #007bff;
    border-radius: 0 0.5rem 0.5rem 0;
}

.transcript-segment.speaking {
    border-left-color: #28a745;
    background: rgba(40, 167, 69, 0.03);
    animation: pulseText 2s infinite;
}

.speaker-header {
    font-weight: 700;
    color: #1976d2;
    margin-bottom: 0.8rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.speaker-header::before {
    content: "🎤";
    font-size: 1rem;
}

.language-tag {
    display: inline-block;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1565c0;
    padding: 0.3rem 0.7rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    margin-left: 0.7rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(21, 101, 192, 0.1);
    border: 1px solid rgba(21, 101, 192, 0.1);
}

.transcript-text {
    color: #1a1a1a;
    margin-left: 0;
    font-weight: 400;
    text-align: justify;
    word-spacing: 0.1rem;
    line-height: 1.8;
}

.transcript-text.interim {
    color: #607d8b;
    font-style: italic;
    opacity: 0.85;
    background: linear-gradient(90deg, transparent 0%, rgba(96, 125, 139, 0.05) 50%, transparent 100%);
    padding: 0.2rem 0.5rem;
    border-radius: 0.3rem;
    animation: shimmer 2s infinite;
}

.transcript-text.final {
    animation: finalizeText 0.5s ease-out;
}

.empty-transcript {
    text-align: center;
    color: #9e9e9e;
    font-style: italic;
    padding: 3rem;
    background: rgba(158, 158, 158, 0.03);
    border-radius: 0.8rem;
    border: 2px dashed rgba(158, 158, 158, 0.2);
}

.empty-transcript::before {
    content: "🎙️";
    display: block;
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Enhanced Animations */
@keyframes slideInText {
    from { 
        opacity: 0; 
        transform: translateX(-20px);
        filter: blur(2px);
    }
    to { 
        opacity: 1; 
        transform: translateX(0);
        filter: blur(0);
    }
}

@keyframes pulseText {
    0%, 100% { 
        border-left-color: #28a745;
        background: rgba(40, 167, 69, 0.03);
    }
    50% { 
        border-left-color: #20c997;
        background: rgba(40, 167, 69, 0.08);
    }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes finalizeText {
    0% { 
        background: rgba(76, 175, 80, 0.1);
        transform: scale(1.01);
    }
    100% { 
        background: transparent;
        transform: scale(1);
    }
}

/* Real-time typing indicator */
.typing-indicator {
    display: inline-block;
    width: 3px;
    height: 1.2rem;
    background: #007bff;
    margin-left: 0.2rem;
    animation: blink 1s infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

@keyframes slideInResponse {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes thinking {
    0% { content: '...'; }
    33% { content: '....'; }
    66% { content: '.....'; }
    100% { content: '...'; }
}

/* Section headers */
.section-header h5 {
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 8px;
    position: relative;
}

.openai-status {
    float: right;
    margin-top: -5px;
}

/* AI Response Display */
.ai-response-display {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid #0ea5e9;
    border-radius: 15px;
    padding: 20px;
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(14, 165, 233, 0.1);
    transition: all 0.3s ease;
    position: relative;
}

.ai-response-content::-webkit-scrollbar {
    width: 8px;
}

.ai-response-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.ai-response-content::-webkit-scrollbar-thumb {
    background: linear-gradient(45deg, #0ea5e9, #0284c7);
    border-radius: 4px;
}

.ai-response-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(45deg, #0284c7, #0369a1);
}

.empty-response {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 60px 20px;
    font-size: 1.1rem;
}

.empty-response .ai-waiting-icon {
    font-size: 3rem;
    color: #0ea5e9;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

.empty-response p {
    margin-bottom: 10px;
    font-size: 1.2rem;
    color: #374151;
}

.empty-response small {
    color: #9ca3af;
}

/* AI Response styling */
.ai-response-item {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
    transition: all 0.3s ease;
    transform: translateY(0);
    opacity: 1;
}

.ai-response-item:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.ai-response-item::before {
    content: '🤖';
    position: absolute;
    top: -8px;
    left: 15px;
    background: #ffffff;
    padding: 0 8px;
    font-size: 14px;
    color: #0ea5e9;
}

.ai-response-text {
    color: #374151;
    font-size: 1rem;
    line-height: 1.6;
    margin: 0;
}

.ai-response-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.ai-response-input {
    font-size: 0.85rem;
    color: #6b7280;
    font-style: italic;
    flex-grow: 1;
}

.ai-response-time {
    font-size: 0.75rem;
    color: #9ca3af;
}

.ai-thinking {
    text-align: center;
    color: #6b7280;
    font-style: italic;
    padding: 15px;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border-radius: 10px;
    margin-bottom: 10px;
}

.ai-thinking::after {
    content: '...';
    animation: thinking 1.5s infinite;
}

/* Recording Controls */
.recording-controls-bottom {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    border-radius: 2rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-record {
    min-width: 160px;
    height: 65px;
    border-radius: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    border: none;
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.3);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-record::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn-record:hover::before {
    left: 100%;
}

.btn-record:hover {
    background: linear-gradient(135deg, #c82333 0%, #b21e2f 100%);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(220, 53, 69, 0.4);
}

.btn-record.recording {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    animation: recordingPulse 1.5s infinite, recordingGlow 3s infinite;
}

.btn-record.recording:hover {
    background: linear-gradient(135deg, #20c997 0%, #17a2b8 100%);
}

.btn-record .btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    position: relative;
    z-index: 1;
}

.btn-record .btn-content i {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.btn-record.recording .btn-content i {
    animation: microphonePulse 1s infinite;
}

@keyframes recordingPulse {
    0%, 100% { 
        box-shadow: 0 6px 20px rgba(40, 167, 69, 0.3);
        transform: translateY(-3px) scale(1.02);
    }
    50% { 
        box-shadow: 0 8px 30px rgba(40, 167, 69, 0.5);
        transform: translateY(-4px) scale(1.03);
    }
}

@keyframes recordingGlow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.1); }
}

@keyframes microphonePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.btn-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #dee2e6;
    background: white;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    border-color: #007bff;
    color: #007bff;
    transform: translateY(-2px);
}

/* Connection Status */
.connection-status {
    font-size: 0.9rem;
}

.connection-status .fa-circle {
    font-size: 0.6rem;
    margin-right: 0.5rem;
}

/* Recording Stats */
.recording-stats {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}

.stat-card {
    text-align: center;
    padding: 1rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.8rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .soniox-voice-recorder {
        padding: 1rem 0;
    }
    
    .recording-controls-bottom {
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        transform: none;
        padding: 0.75rem 1rem;
    }
    
    .btn-record {
        min-width: 120px;
        height: 50px;
    }
    
    .btn-icon {
        width: 45px;
        height: 45px;
    }
    
    .language-selector .language-select {
        max-width: 200px;
    }
    
    .transcript-display {
        margin-bottom: 100px; /* Space for fixed controls */
    }
}

@media (max-width: 576px) {
    .chat-input-wrapper {
        padding: 0.75rem;
    }
    
    .recording-controls-bottom {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .btn-record {
        min-width: 100px;
        height: 45px;
        font-size: 0.9rem;
    }
    
    .btn-icon {
        width: 40px;
        height: 40px;
    }
}

/* Utility classes */
.text-shadow {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.border-radius-lg {
    border-radius: 0.75rem !important;
}
