/**
 * RTF Exercises - Styles Widget Frontend
 * 
 * @package RTF_Exercises
 * @since 1.0.0
 */

/* ==========================================================================
   VARIABLES
   ========================================================================== */
:root {
    --rtf-widget-primary: #2271b1;
    --rtf-widget-primary-hover: #135e96;
    --rtf-widget-success: #00a32a;
    --rtf-widget-warning: #dba617;
    --rtf-widget-error: #d63638;
    --rtf-widget-border: #c3c4c7;
    --rtf-widget-bg: #f6f7f7;
    --rtf-widget-radius: 8px;
    --rtf-widget-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   WIDGET PRINCIPAL
   ========================================================================== */
.rtf-exercise-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background: #fff;
    border: 1px solid var(--rtf-widget-border);
    border-radius: var(--rtf-widget-radius);
    box-shadow: var(--rtf-widget-shadow);
    padding: 24px;
    margin: 24px 0;
    max-width: 700px;
}

/* En-tête */
.rtf-exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--rtf-widget-bg);
}

.rtf-exercise-topic {
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
}

.rtf-exercise-badge {
    background: var(--rtf-widget-primary);
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* ==========================================================================
   SECTIONS PILOTE ET ATC
   ========================================================================== */
.rtf-role-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #50575e;
    margin-bottom: 10px;
}

.rtf-role-icon {
    font-size: 18px;
}

/* Section ATC */
.rtf-atc-section {
    background: var(--rtf-widget-bg);
    padding: 16px;
    border-radius: var(--rtf-widget-radius);
    margin-bottom: 20px;
}

.rtf-atc-text {
    font-family: "Monaco", "Menlo", "Courier New", monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #1d2327;
    padding: 12px;
    background: #fff;
    border-radius: 6px;
    border: 1px solid var(--rtf-widget-border);
    margin-bottom: 12px;
}

.rtf-listen-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--rtf-widget-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.rtf-listen-btn:hover {
    background: var(--rtf-widget-primary-hover);
}

.rtf-listen-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.rtf-listen-btn.playing {
    background: var(--rtf-widget-success);
}

/* Section Pilote */
.rtf-pilot-section {
    margin-bottom: 24px;
}

.rtf-spoken-text {
    font-family: "Monaco", "Menlo", "Courier New", monospace;
    font-size: 16px;
    line-height: 1.7;
    color: #1d2327;
    padding: 16px;
    background: #fffbeb;
    border: 2px solid #fcd34d;
    border-radius: var(--rtf-widget-radius);
    word-break: break-word;
}

/* ==========================================================================
   ZONE DE PRATIQUE (PTT)
   ========================================================================== */
.rtf-practice-section {
    text-align: center;
    padding: 20px;
    background: var(--rtf-widget-bg);
    border-radius: var(--rtf-widget-radius);
}

.rtf-ptt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 32px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.rtf-ptt-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.rtf-ptt-btn:active,
.rtf-ptt-btn.recording {
    transform: translateY(0);
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.rtf-ptt-btn.recording {
    animation: pulse 1.5s infinite;
}

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

.rtf-btn-icon {
    font-size: 20px;
}

/* Indicateur d'enregistrement */
.rtf-recording-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    color: var(--rtf-widget-error);
    font-weight: 500;
}

.rtf-pulse {
    width: 12px;
    height: 12px;
    background: var(--rtf-widget-error);
    border-radius: 50%;
    animation: pulse-dot 1s infinite;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

.rtf-recording-time {
    font-family: monospace;
    font-size: 16px;
}

/* Indicateur de traitement */
.rtf-processing-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    color: var(--rtf-widget-primary);
}

.rtf-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--rtf-widget-border);
    border-top-color: var(--rtf-widget-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   ZONE DE FEEDBACK
   ========================================================================== */
.rtf-feedback-section {
    margin-top: 24px;
    padding: 20px;
    border-radius: var(--rtf-widget-radius);
    animation: slideIn 0.3s ease;
}

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

/* États de feedback */
.rtf-feedback-section.excellent {
    background: #d1fae5;
    border: 2px solid var(--rtf-widget-success);
}

.rtf-feedback-section.partial {
    background: #fef3c7;
    border: 2px solid var(--rtf-widget-warning);
}

.rtf-feedback-section.incorrect {
    background: #fee2e2;
    border: 2px solid var(--rtf-widget-error);
}

/* En-tête feedback */
.rtf-feedback-header {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 15px;
}

.rtf-feedback-header .icon {
    font-size: 28px;
}

.rtf-feedback-section.excellent .rtf-feedback-header { color: #065f46; }
.rtf-feedback-section.partial .rtf-feedback-header { color: #92400e; }
.rtf-feedback-section.incorrect .rtf-feedback-header { color: #991b1b; }

/* Score */
.rtf-feedback-score {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
}

/* Détails par segment */
.rtf-feedback-details {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
}

.rtf-segment {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.rtf-segment:last-child {
    border-bottom: none;
}

.rtf-segment-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.rtf-segment-content {
    flex: 1;
}

.rtf-segment-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 2px;
}

.rtf-segment-text {
    font-family: monospace;
    font-size: 13px;
}

.rtf-segment.correct .rtf-segment-text {
    color: #065f46;
}

.rtf-segment.incorrect .rtf-segment-text {
    color: #991b1b;
}

.rtf-segment-diff {
    margin-top: 5px;
    font-size: 12px;
    color: #991b1b;
}

/* Transcription utilisateur */
.rtf-feedback-transcription {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 15px;
    font-size: 13px;
}

.rtf-feedback-transcription strong {
    display: block;
    margin-bottom: 5px;
    color: #666;
}

.rtf-feedback-transcription p {
    margin: 0;
    font-family: monospace;
}

/* Conseil */
.rtf-feedback-tip {
    background: rgba(255, 255, 255, 0.9);
    border-left: 4px solid var(--rtf-widget-primary);
    padding: 10px 15px;
    border-radius: 0 6px 6px 0;
    font-size: 14px;
    margin-bottom: 15px;
}

.rtf-feedback-tip strong {
    color: var(--rtf-widget-primary);
}

/* Actions feedback */
.rtf-feedback-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.rtf-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #fff;
    color: #1d2327;
    border: 2px solid var(--rtf-widget-border);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.rtf-retry-btn:hover {
    border-color: var(--rtf-widget-primary);
    color: var(--rtf-widget-primary);
}

/* ==========================================================================
   ERREUR
   ========================================================================== */
.rtf-exercise-error {
    background: #fee2e2;
    border: 1px solid var(--rtf-widget-error);
    border-radius: var(--rtf-widget-radius);
    padding: 20px;
    color: #991b1b;
}

.rtf-exercise-error p:first-child {
    margin-top: 0;
}

.rtf-exercise-error p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 600px) {
    .rtf-exercise-widget {
        padding: 16px;
        margin: 16px 0;
    }
    
    .rtf-exercise-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .rtf-spoken-text {
        font-size: 14px;
        padding: 12px;
    }
    
    .rtf-ptt-btn {
        padding: 14px 28px;
        font-size: 15px;
    }
    
    .rtf-feedback-header {
        font-size: 18px;
    }
}

/* ==========================================================================
   ACCESSIBILITÉ
   ========================================================================== */
.rtf-exercise-widget *:focus {
    outline: 2px solid var(--rtf-widget-primary);
    outline-offset: 2px;
}

.rtf-ptt-btn:focus {
    outline-offset: 4px;
}

/* Réduire les animations pour les utilisateurs qui le préfèrent */
@media (prefers-reduced-motion: reduce) {
    .rtf-ptt-btn.recording,
    .rtf-pulse,
    .rtf-spinner {
        animation: none;
    }
    
    .rtf-feedback-section {
        animation: none;
    }
}
