/* ============================================
   Quran Recitation Verifier - Modern UI Styles
   ============================================ */

:root {
    --primary: #0d9488;
    --primary-light: #14b8a6;
    --primary-dark: #0f766e;
    --success: #22c55e;
    --success-bg: #dcfce7;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --error: #ef4444;
    --error-bg: #fee2e2;
    --info: #3b82f6;
    --info-bg: #dbeafe;
    
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #f0fdfa 0%, #f8fafc 50%, #f0f9ff 100%);
    min-height: 100vh;
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 32px;
    padding: 32px 0;
}

header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 400;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Mode Tabs */
.mode-card {
    padding: 16px;
}

.mode-tabs {
    display: flex;
    gap: 8px;
    background: var(--bg);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.mode-tab {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.mode-tab:hover {
    color: var(--text);
}

.mode-tab.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow);
}

.expected-options {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.input-row {
    display: flex;
    gap: 16px;
}

.input-group {
    flex: 1;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.input-group select,
.input-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s;
}

.input-group select:focus,
.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Recording Section */
.recording-section {
    text-align: center;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg);
    border-radius: 20px;
    margin-bottom: 24px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-indicator.recording .status-dot {
    background: var(--error);
    animation: pulse 1s infinite;
}

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

#statusText {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

.btn-primary.recording {
    background: linear-gradient(135deg, var(--error) 0%, #dc2626 100%);
    animation: pulse-btn 1.5s infinite;
}

@keyframes pulse-btn {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
}

.btn-upload {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-upload:hover {
    background: var(--border);
    cursor: pointer;
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #16a34a 100%);
    color: white;
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
    margin-bottom: 12px;
}

/* Audio Preview */
.audio-preview {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.audio-preview audio {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
}

/* Waveform */
.waveform {
    margin-top: 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.waveform-bars {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
}

.waveform-bar {
    width: 4px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 2px;
    transition: height 0.1s ease;
}

/* Loading Section */
.loading-section {
    text-align: center;
    padding: 48px 24px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loadingTitle {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.loading-detail {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Results Section */
.results-section {
    margin-top: 24px;
}

/* Score Card */
.score-card {
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 32px;
    background: linear-gradient(135deg, #f0fdfa 0%, #ffffff 100%);
    border: 2px solid var(--primary);
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    flex-shrink: 0;
    box-shadow: 0 8px 24px rgba(13, 148, 136, 0.3);
}

.score-circle.score-excellent {
    background: linear-gradient(135deg, var(--success) 0%, #16a34a 100%);
    box-shadow: 0 8px 24px rgba(34, 197, 94, 0.3);
}

.score-circle.score-good {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.score-circle.score-fair {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.3);
}

.score-circle.score-poor {
    background: linear-gradient(135deg, var(--error) 0%, #dc2626 100%);
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3);
}

.score-value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.score-label {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.9;
    margin-top: 4px;
}

.score-details {
    flex: 1;
}

.score-details h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.match-badge {
    display: inline-block;
    padding: 6px 14px;
    background: var(--primary);
    color: white;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 16px;
}

.result-meta {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.meta-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

/* Arabic Text */
.arabic-text {
    font-family: 'Amiri', serif;
    font-size: 1.6rem;
    line-height: 2.2;
    text-align: right;
    direction: rtl;
}

.canonical-text {
    color: var(--primary-dark);
    padding: 20px;
    background: linear-gradient(135deg, #f0fdfa 0%, #ffffff 100%);
    border-radius: var(--radius-sm);
    border-right: 4px solid var(--primary);
}

.recitation-text {
    color: var(--text);
    padding: 20px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.ayah-ref {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Alignment View */
.alignment-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-dot.ok { background: var(--success); }
.legend-dot.sub { background: var(--warning); }
.legend-dot.del { background: var(--error); }
.legend-dot.ins { background: var(--info); }

.alignment-view {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    direction: rtl;
    margin-bottom: 20px;
}

.alignment-item {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    text-align: center;
    min-width: 60px;
    transition: transform 0.2s;
}

.alignment-item:hover {
    transform: scale(1.05);
}

.op-ok {
    background: var(--success-bg);
    border: 1px solid var(--success);
}

.op-sub {
    background: var(--warning-bg);
    border: 1px solid var(--warning);
}

.op-del {
    background: var(--error-bg);
    border: 1px solid var(--error);
}

.op-ins {
    background: var(--info-bg);
    border: 1px solid var(--info);
}

.align-ref, .align-hyp {
    font-family: 'Amiri', serif;
    font-size: 1.1rem;
}

.align-ref {
    color: var(--text);
    margin-bottom: 4px;
}

.align-hyp {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.align-op {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
    opacity: 0.7;
}

.alignment-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.stat-count {
    font-weight: 700;
    font-size: 1.1rem;
}

.stat-count.ok { color: var(--success); }
.stat-count.sub { color: var(--warning); }
.stat-count.del { color: var(--error); }
.stat-count.ins { color: var(--info); }
.stat-count.wer { color: var(--error); }

/* Timed Words */
.timed-words-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    direction: rtl;
}

.timed-word {
    padding: 8px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    text-align: center;
    transition: all 0.2s;
}

.timed-word:hover {
    border-color: var(--primary);
    background: #f0fdfa;
}

.timed-word .word {
    font-family: 'Amiri', serif;
    font-size: 1.1rem;
    color: var(--text);
    display: block;
    margin-bottom: 4px;
}

.timed-word .time {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: monospace;
}

.timed-word.op-ok { border-left: 3px solid var(--success); }
.timed-word.op-sub { border-left: 3px solid var(--warning); }
.timed-word.op-ins { border-left: 3px solid var(--info); }

/* Candidates List */
.candidates-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.candidate-item {
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.candidate-item:hover {
    border-color: var(--primary);
}

.candidate-item.best-match {
    background: linear-gradient(135deg, #f0fdfa 0%, #ffffff 100%);
    border-color: var(--primary);
    border-width: 2px;
}

.candidate-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.candidate-rank {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.candidate-ref {
    font-size: 0.9rem;
    color: var(--text);
    flex: 1;
}

.candidate-score {
    font-size: 0.9rem;
    font-weight: 700;
    padding: 4px 10px;
    background: var(--primary);
    color: white;
    border-radius: 12px;
}

.candidate-text {
    font-family: 'Amiri', serif;
    font-size: 1.2rem;
    line-height: 1.8;
    color: var(--text);
    direction: rtl;
    text-align: right;
}

/* JSON Response */
#jsonResponse {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-family: 'Monaco', 'Consolas', monospace;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

/* Footer */
footer {
    text-align: center;
    padding: 32px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer strong {
    color: var(--primary);
}

.api-endpoint {
    margin-top: 12px;
    font-size: 0.8rem;
}

.api-endpoint code {
    background: var(--bg-card);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    border: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 16px;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    .score-card {
        flex-direction: column;
        text-align: center;
    }
    
    .score-circle {
        width: 100px;
        height: 100px;
    }
    
    .score-value {
        font-size: 2rem;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .result-meta {
        justify-content: center;
    }
    
    .input-row {
        flex-direction: column;
    }
}
