/* ==============================
   SAC Recorder - Pronunciation Assessment
   Modern Dark Glass UI
   ============================== */

/* Recording Button on each audio item */
.sac-record-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    background: #1a73e8;
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin-right: 8px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.sac-record-btn svg {
    width: 16px;
    height: 16px;
}

.sac-record-btn:hover {
    transform: scale(1.18);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

/* Recording Modal Overlay */
.sac-recorder-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 35, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: sacFadeIn 0.3s ease;
    transition: opacity 0.25s ease;
}

.sac-recorder-overlay.sac-closing {
    opacity: 0;
}

.sac-recorder-overlay-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

@keyframes sacFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Modal */
.sac-recorder-modal {
    background: linear-gradient(180deg, #ffffff 0%, #f8f9ff 100%);
    border-radius: 24px;
    width: 92%;
    max-width: 480px;
    padding: 32px 28px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1);
    position: relative;
    animation: sacSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    direction: rtl;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes sacSlideUp {
    from {
        transform: translateY(50px) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Close Button */
.sac-recorder-close {
    position: absolute;
    top: 14px;
    left: 14px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #64748b;
    padding: 0;
}

.sac-recorder-close svg {
    width: 18px;
    height: 18px;
}

.sac-recorder-close:hover {
    background: #e2e8f0;
    color: #1e293b;
    transform: rotate(90deg);
}

/* Header */
.sac-recorder-header {
    text-align: center;
    margin-bottom: 20px;
}

.sac-header-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: #1a73e8;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.sac-header-icon svg {
    width: 26px;
    height: 26px;
}

.sac-recorder-header h3 {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 800;
    color: #1e293b;
    letter-spacing: -0.3px;
}

.sac-header-sub {
    margin: 0;
    font-size: 13px;
    color: #94a3b8;
    font-weight: 500;
}

/* Transcript Box */
.sac-recorder-transcript {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8ecff 100%);
    border: 1px solid #c7d2fe;
    border-radius: 14px;
    padding: 18px 20px;
    margin: 16px 0 24px;
    font-size: 17px;
    line-height: 1.9;
    color: #1e293b;
    direction: ltr;
    text-align: center;
    font-family: 'Georgia', 'Times New Roman', serif;
    letter-spacing: 0.4px;
    font-weight: 500;
}

/* Microphone Area */
.sac-mic-area {
    text-align: center;
    padding: 20px 0;
}

.sac-mic-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    padding: 0;
}

.sac-mic-btn svg {
    width: 36px;
    height: 36px;
}

.sac-mic-btn.ready {
    background: #1a73e8;
    color: white;

}

.sac-mic-btn.ready:hover {
    transform: scale(1.1);
}

.sac-mic-btn.recording {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 8px 30px rgba(239, 68, 68, 0.4);
    animation: sacPulse 1.5s infinite;
}

@keyframes sacPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 0 0 22px rgba(239, 68, 68, 0);
    }
}

.sac-mic-label {
    margin-top: 14px;
    font-size: 14px;
    color: #94a3b8;
    font-weight: 600;
}

/* Timer */
.sac-record-timer {
    font-size: 32px;
    font-weight: 800;
    color: #ef4444;
    margin-top: 10px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    letter-spacing: 3px;
    direction: ltr;
}

/* Action Buttons */
.sac-recorder-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.sac-recorder-actions button {
    padding: 11px 22px;
    border-radius: 14px;
    border: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.sac-btn-submit {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.sac-btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
}

.sac-btn-submit:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.sac-btn-submit svg,
.sac-btn-rerecord svg {
    width: 16px;
    height: 16px;
}

.sac-btn-rerecord {
    background: #f1f5f9;
    color: #475569;
}

.sac-btn-rerecord:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* Processing State */
.sac-processing {
    text-align: center;
    padding: 44px 0;
}

.sac-processing-spinner {
    width: 46px;
    height: 46px;
    border: 3px solid #e2e8f0;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: sacSpin 0.7s linear infinite;
    margin: 0 auto 16px;
}

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

.sac-processing-text {
    color: #94a3b8;
    font-size: 14px;
    font-weight: 600;
}

/* ==================
   Score Results
   ================== */
.sac-score-results {
    padding: 16px 0;
}

/* Overall Score Gauge */
.sac-score-gauge {
    text-align: center;
    margin-bottom: 24px;
}

.sac-gauge-circle {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 14px;
}

.sac-gauge-circle svg {
    transform: rotate(-90deg);
    width: 140px;
    height: 140px;
}

.sac-gauge-bg {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: 10;
}

.sac-gauge-fill {
    fill: none;
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.sac-gauge-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.sac-gauge-number {
    font-size: 38px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -1px;
}

.sac-gauge-label {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
    font-weight: 600;
}

/* Score levels */
.sac-score-excellent .sac-gauge-fill {
    stroke: #10b981;
}

.sac-score-excellent .sac-gauge-number {
    color: #059669;
}

.sac-score-good .sac-gauge-fill {
    stroke: #f59e0b;
}

.sac-score-good .sac-gauge-number {
    color: #d97706;
}

.sac-score-poor .sac-gauge-fill {
    stroke: #ef4444;
}

.sac-score-poor .sac-gauge-number {
    color: #dc2626;
}

.sac-score-badge {
    display: inline-block;
    padding: 7px 24px;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 800;
    margin-top: 6px;
}

.sac-score-excellent .sac-score-badge {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #059669;
}

.sac-score-good .sac-score-badge {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #d97706;
}

.sac-score-poor .sac-score-badge {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
}

/* IELTS / CEFR badges */
.sac-score-badges {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.sac-badge-item {
    background: #f1f5f9;
    padding: 6px 16px;
    border-radius: 10px;
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
}

.sac-badge-item strong {
    color: #1e293b;
}

/* Word-by-Word Breakdown */
.sac-word-scores {
    margin-top: 24px;
}

.sac-word-scores h4 {
    font-size: 14px;
    color: #475569;
    margin-bottom: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.sac-word-scores h4 svg {
    width: 18px;
    height: 18px;
    color: #6366f1;
}

.sac-words-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    direction: ltr;
    justify-content: center;
}

.sac-word-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 14px;
    transition: transform 0.2s ease;
    cursor: default;
}

.sac-word-chip:hover {
    transform: scale(1.1);
}

.sac-word-chip .sac-word-text {
    font-weight: 700;
    margin-bottom: 2px;
}

.sac-word-chip .sac-word-score {
    font-size: 11px;
    opacity: 0.75;
    font-weight: 600;
}

.sac-word-excellent {
    background: #d1fae5;
    color: #047857;
}

.sac-word-good {
    background: #fef3c7;
    color: #b45309;
}

.sac-word-poor {
    background: #fee2e2;
    color: #b91c1c;
}

/* History */
.sac-score-history {
    margin-top: 24px;
    border-top: 1px solid #e2e8f0;
    padding-top: 18px;
}

.sac-score-history h4 {
    font-size: 14px;
    color: #475569;
    margin-bottom: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sac-score-history h4 svg {
    color: #6366f1;
}

.sac-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sac-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 12px;
    font-size: 13px;
    border: 1px solid #f1f5f9;
}

.sac-history-score {
    font-weight: 800;
    font-size: 15px;
    padding: 4px 14px;
    border-radius: 10px;
}

.sac-history-date {
    color: #94a3b8;
    font-size: 12px;
    font-weight: 500;
}

/* Transcript editor in admin */
.sac-transcript-row td {
    background: #fafafe !important;
    padding: 0 !important;
}

.sac-transcript-editor {
    padding: 14px 18px;
    border-top: 1px dashed #e2e8f0;
}

.sac-transcript-editor label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 13px;
    color: #475569;
}

.sac-transcript-input {
    width: 100%;
    resize: vertical;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 10px;
    direction: ltr;
    transition: all 0.2s ease;
}

.sac-transcript-input:focus {
    border-color: #6366f1;
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* ==================
   Playback Bar
   ================== */
.sac-playback-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f1f5f9;
    border-radius: 14px;
    padding: 10px 16px;
    margin-top: 12px;
    direction: rtl;
}
.sac-playback-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #6366f1;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: all 0.2s ease;
}
.sac-playback-btn:hover {
    background: #4f46e5;
    transform: scale(1.05);
}
.sac-playback-btn svg {
    width: 14px;
    height: 14px;
}
.sac-playback-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
    white-space: nowrap;
}
.sac-playback-progress {
    flex: 1;
    height: 6px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    min-width: 60px;
}
.sac-playback-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 6px;
    width: 0%;
    transition: width 0.15s linear;
}

/* Result Playback Button */
.sac-result-playback {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #eff6ff 0%, #e0f2fe 100%);
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    padding: 12px 16px;
    margin-bottom: 20px;
    direction: rtl;
}
.sac-result-play-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}
.sac-result-play-btn:hover {
    background: #1d4ed8;
}
.sac-result-play-btn svg {
    width: 16px;
    height: 16px;
}
.sac-result-progress {
    flex: 1;
}

/* ==================
   Phoneme Breakdown
   ================== */
.sac-word-phones {
    display: flex;
    gap: 3px;
    margin-top: 6px;
    flex-wrap: wrap;
    justify-content: center;
}
.sac-phone {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    letter-spacing: 0;
    direction: ltr;
}
.sac-phone small {
    font-size: 8px;
    opacity: 0.7;
}
.sac-phone-excellent {
    background: rgba(16, 185, 129, 0.15);
    color: #047857;
}
.sac-phone-good {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
}
.sac-phone-poor {
    background: rgba(239, 68, 68, 0.15);
    color: #b91c1c;
}

/* Responsive */
@media (max-width: 600px) {
    .sac-recorder-modal {
        width: 95%;
        padding: 24px 18px;
        border-radius: 20px;
    }

    .sac-mic-btn {
        width: 74px;
        height: 74px;
    }

    .sac-mic-btn svg {
        width: 30px;
        height: 30px;
    }

    .sac-gauge-circle {
        width: 120px;
        height: 120px;
    }

    .sac-gauge-circle svg {
        width: 120px;
        height: 120px;
    }

    .sac-gauge-number {
        font-size: 30px;
    }

    .sac-recorder-actions {
        flex-direction: column;
    }
}