/**
 * CW-Lehrgang spezifisches Styling
 * Nutzt CSS-Variablen und learn-area-card aus style.css
 */

/* Fehler melden Button */
.cw-report-btn {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
}

.btn-report {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}
.btn-report:hover {
    background: #b91c1c;
    color: white;
}
.btn-report svg {
    stroke: white;
}

/* Lektionen-Liste (Index) - nutzt learn-area-card aus style.css */
.cw-lessons-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Lektionsnummer im Icon */
.cw-lesson-number {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    font-family: monospace;
}

/* Gesperrte Lektionen */
.cw-locked {
    opacity: 0.5;
    pointer-events: none;
}

.cw-locked .learn-area-arrow svg {
    color: var(--text-light);
}

/* Lektion-Seite */
.cw-section {
    max-width: 100%;
}

.cw-section h1 {
    margin-bottom: 1.5rem;
    font-weight: 400;
}

.cw-section h1 .lesson-prefix {
    font-weight: 300;
}

.cw-section h1 strong {
    font-weight: 700;
}

/* Container für mehrere neue Zeichen (z.B. Lektion 1: K, M) */
.new-chars-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: flex-start;
    margin-bottom: 2rem;
}

.new-chars-container .morse-display {
    flex: 0 0 calc(50% - 0.5rem);
    min-width: 200px;
}

/* Neues Zeichen Display */
.morse-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.morse-display .new-char {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary);
    font-family: monospace;
}

.morse-display .morse-code {
    font-size: 2rem;
    color: var(--text-light);
    font-family: monospace;
    letter-spacing: 0.2em;
    margin: 0.5rem 0 1rem;
}

.morse-play-large {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s ease;
}

.morse-play-large:hover {
    background: var(--primary-dark);
}

.morse-play-large svg {
    width: 20px;
    height: 20px;
}

/* Zeichen-Buttons */
.char-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-start;
    margin: 1.5rem 0 2rem;
}

.char-btn {
    min-width: 75px;
    padding: 0.6rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.char-btn:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.char-btn:active {
    transform: scale(0.95);
}

.char-btn-new {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
}

.char-letter {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: monospace;
    color: var(--text);
}

.char-morse {
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--text-light);
    letter-spacing: 0.1em;
}

.char-audio-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.35rem;
    color: var(--text-light);
    opacity: 0.6;
    transition: opacity 0.2s, color 0.2s;
}

.char-btn:hover .char-audio-icon {
    opacity: 1;
    color: var(--primary);
}

/* Start-Buttons */
.exercise-start-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

#start-exercise-btn,
#start-exercise-short-btn {
    display: block;
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

#start-exercise-btn {
    background: var(--success);
}

#start-exercise-btn:hover {
    background: #059669;
}

.exercise-hint {
    margin: 0.5rem 0 0;
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Übungs-Section */
.exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
}

#timer {
    font-size: 2rem;
    font-weight: 700;
    font-family: monospace;
    color: var(--text);
}

#timer.warning {
    color: var(--error);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.wpm-display {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Audio-Controls */
.audio-controls {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.audio-controls button {
    flex: 1;
    padding: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-controls button svg {
    flex-shrink: 0;
}

/* Morse-Input */
.input-container {
    margin-bottom: 1.5rem;
}

#morse-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.5rem;
    font-family: monospace;
    text-align: center;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s ease;
}

#morse-input:focus {
    outline: none;
    border-color: var(--primary);
}

#morse-input::placeholder {
    letter-spacing: normal;
    text-transform: none;
}

#submit-btn,
#cancel-btn {
    display: block;
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.125rem;
    margin-top: 0.75rem;
}

/* Ergebnis-Section (wie play.html) */
.cw-result {
    text-align: center;
    padding: 2rem 1rem;
}

.cw-result-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
}

.cw-result-icon.success {
    color: var(--success);
}

.cw-result-icon.fail {
    color: var(--text-light);
}

.cw-result h2 {
    margin-bottom: 0.5rem;
}

.cw-result h2.success {
    color: var(--success);
}

.cw-result-accuracy {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.cw-result-subtitle {
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.cw-result-stats {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

/* Vergleich */
#comparison {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.comparison-row {
    margin-bottom: 0.75rem;
}

.comparison-row:last-child {
    margin-bottom: 0;
}

.comparison-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.comparison-chars {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

.comparison-char {
    width: 24px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: monospace;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 4px;
    background: var(--border);
}

.comparison-char.correct {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.comparison-char.wrong {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.comparison-char.missing {
    background: rgba(107, 114, 128, 0.2);
    color: var(--text-light);
}

/* Result-Actions */
.result-actions {
    display: flex;
    gap: 1rem;
}

.result-actions button {
    flex: 1;
    padding: 0.875rem;
}

/* Mobile-Optimierungen */
@media (max-width: 768px) {
    .cw-section h2 {
        font-size: 1.125rem;
    }

    .char-buttons {
        gap: 0.4rem;
    }

    .char-btn {
        flex: 1 1 calc(33.33% - 0.3rem);
        min-width: 0;
        max-width: calc(33.33% - 0.3rem);
        padding: 0.5rem 0.25rem;
    }

    .char-letter {
        font-size: 1.125rem;
    }

    .char-morse {
        font-size: 0.65rem;
    }

    .char-audio-icon svg {
        width: 14px;
        height: 14px;
    }

    /* Sticky Start-Button auf Mobile (nur der grüne) */
    #start-exercise-btn {
        position: fixed;
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        width: auto;
        z-index: 90;
        box-shadow: 0 8px 30px rgba(16, 185, 129, 0.5), 0 4px 15px rgba(0, 0, 0, 0.2);
    }

    /* Abstand unten für den Content, damit er nicht vom Button überdeckt wird */
    #learn-section {
        padding-bottom: 100px;
    }

    #morse-input {
        font-size: 1.25rem;
        letter-spacing: 0.2em;
    }

    .exercise-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    #timer {
        font-size: 2.5rem;
    }

    /* Sticky Input auf Mobile */
    .input-container {
        position: sticky;
        bottom: 0;
        background: var(--bg);
        padding: 1rem;
        margin: 0 -1rem -1rem;
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    }

    #accuracy-circle {
        width: 120px;
        height: 120px;
    }

    #accuracy-value {
        font-size: 2.5rem;
    }

    .comparison-char {
        width: 20px;
        height: 24px;
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .audio-controls {
        flex-direction: column;
    }

    .result-actions {
        flex-direction: column;
    }
}

/* Timer während Countdown */
#timer.countdown-active {
    color: var(--primary);
    animation: timer-pulse 1s ease-in-out infinite;
}

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

/* Settings Link */
.cw-settings-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-light);
    font-size: 0.875rem;
    text-decoration: none;
}

.cw-settings-link:hover {
    color: var(--primary);
}

/* Statistik-Box Abstand */
.exam-user-progress {
    margin-top: 1.5rem;
}

/* Statistik-Zeile (wie in play.css) */
.play-stats-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

.play-stats-row strong {
    color: var(--primary);
}

.play-stats-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

@media (max-width: 480px) {
    .play-stats-row {
        flex-direction: column;
        gap: 0.25rem;
    }
}
