/**
 * Testcenter Core – Frontend Styles
 *
 * CSS Custom Properties (--tc-primary, --tc-bg, --tc-text) werden
 * als inline-style am .tc-app Container gesetzt.
 */

/* ── Reset & Container ────────────────────── */

.tc-app {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--tc-text, #2d3436);
    background: var(--tc-bg, #ffffff);
    margin: 0 auto;
    padding: 24px;
    box-sizing: border-box;
}

.tc-app *,
.tc-app *::before,
.tc-app *::after {
    box-sizing: border-box;
}

/* ── Progress Bar ─────────────────────────── */

.tc-progress {
    display: flex;
    justify-content: space-between;
    margin-bottom: 32px;
    padding: 0;
    counter-reset: step;
    position: relative;
}

.tc-progress::before {
    content: '';
    position: absolute;
    top: 16px;
    left: 24px;
    right: 24px;
    height: 2px;
    background: #dfe6e9;
    z-index: 0;
}

.tc-progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    flex: 1;
}

.tc-progress-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #dfe6e9;
    color: #636e72;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    transition: background 0.3s, color 0.3s;
}

.tc-progress-label {
    font-size: 11px;
    color: #b2bec3;
    text-align: center;
    transition: color 0.3s;
}

.tc-progress-active .tc-progress-num {
    background: var(--tc-primary, #1a7a6d);
    color: #fff;
}

.tc-progress-active .tc-progress-label {
    color: var(--tc-primary, #1a7a6d);
    font-weight: 600;
}

.tc-progress-done .tc-progress-num {
    background: var(--tc-primary, #1a7a6d);
    color: #fff;
    opacity: 0.6;
}

.tc-progress-done .tc-progress-label {
    color: #636e72;
}

/* ── Steps ────────────────────────────────── */

.tc-step {
    display: none;
}

.tc-step-active {
    display: block;
}

.tc-step-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--tc-text, #2d3436);
    margin: 0 0 24px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--tc-primary, #1a7a6d);
}

.tc-step-placeholder {
    color: #b2bec3;
    font-style: italic;
    padding: 40px 0;
    text-align: center;
}

/* ── Formular ─────────────────────────────── */

.tc-form-row {
    margin-bottom: 16px;
}

.tc-form-row-half {
    display: flex;
    gap: 16px;
}

.tc-form-row-half .tc-form-group {
    flex: 1;
}

.tc-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--tc-text, #2d3436);
    margin-bottom: 4px;
}

.tc-required {
    color: #d63031;
}

.tc-form-group input[type="text"],
.tc-form-group input[type="email"],
.tc-form-group input[type="number"],
.tc-form-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid #dfe6e9;
    border-radius: 6px;
    background: #fff;
    color: var(--tc-text, #2d3436);
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

.tc-form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23636e72' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.tc-form-group input:focus,
.tc-form-group select:focus {
    outline: none;
    border-color: var(--tc-primary, #1a7a6d);
    box-shadow: 0 0 0 3px rgba(26, 122, 109, 0.15);
}

.tc-form-group input.tc-input-error,
.tc-form-group select.tc-input-error {
    border-color: #d63031;
}

.tc-form-group input.tc-input-error:focus,
.tc-form-group select.tc-input-error:focus {
    box-shadow: 0 0 0 3px rgba(214, 48, 49, 0.15);
}

/* ── Checkboxen ───────────────────────────── */

.tc-checkbox-group {
    margin: 20px 0;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 6px;
}

.tc-checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
}

.tc-checkbox-item:last-child {
    margin-bottom: 0;
}

.tc-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--tc-primary, #1a7a6d);
    cursor: pointer;
}

.tc-checkbox-item label {
    font-size: 13px;
    line-height: 1.5;
    color: var(--tc-text, #2d3436);
    cursor: pointer;
}

.tc-checkbox-item label a {
    color: var(--tc-primary, #1a7a6d);
    text-decoration: underline;
}

.tc-checkbox-item label a:hover {
    text-decoration: none;
}

.tc-checkbox-item.tc-checkbox-error label {
    color: #d63031;
}

/* ── Buttons ──────────────────────────────── */

.tc-form-actions {
    margin-top: 24px;
}

.tc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 32px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s, transform 0.1s;
}

.tc-btn:active {
    transform: scale(0.98);
}

.tc-btn-primary {
    background: var(--tc-primary, #1a7a6d);
    color: #fff;
    width: 100%;
}

.tc-btn-primary:hover {
    opacity: 0.9;
}

.tc-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Fehlermeldungen ──────────────────────── */

.tc-error {
    background: #ffeaea;
    color: #d63031;
    border: 1px solid #fab1a0;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Spinner ──────────────────────────────── */

.tc-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: tc-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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

.tc-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    color: #636e72;
    font-size: 14px;
}

.tc-loading .tc-spinner {
    border-color: rgba(26, 122, 109, 0.2);
    border-top-color: var(--tc-primary, #1a7a6d);
    width: 24px;
    height: 24px;
    margin-right: 10px;
}

/* ── QR-Code (Step 2) ─────────────────────── */

.tc-qr-container {
    text-align: center;
    padding: 20px 0;
}

.tc-qr-code {
    display: inline-block;
    padding: 16px;
    background: #fff;
    border: 2px solid #dfe6e9;
    border-radius: 12px;
    margin-bottom: 16px;
}

.tc-qr-code svg {
    display: block;
    max-width: 100%;
    height: auto;
}

.tc-qr-instruction {
    color: #636e72;
    font-size: 14px;
    max-width: 360px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ── Status-Box (Warte-Anzeige) ──────────── */

.tc-status-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 24px;
    font-size: 14px;
    color: #636e72;
}

.tc-status-box.tc-status-done {
    background: #e8f5e9;
    color: #2e7d32;
}

.tc-spinner-dark {
    border-color: rgba(26, 122, 109, 0.2);
    border-top-color: var(--tc-primary, #1a7a6d);
}

/* ── Step-Beschreibung ────────────────────── */

.tc-step-desc {
    color: #636e72;
    font-size: 15px;
    line-height: 1.6;
    margin: 0 0 20px 0;
}

/* ── Checklist (Step 3) ───────────────────── */

.tc-checklist {
    margin: 20px 0;
}

.tc-check-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 15px;
    transition: background 0.3s;
}

.tc-check-item:last-child {
    margin-bottom: 0;
}

.tc-check-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.tc-check-pending {
    color: #b2bec3;
}

.tc-check-done {
    color: #27ae60;
}

/* ── Positionierungs-Hint (Step 4) ────────── */

.tc-positioning-hint {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px 24px;
    margin: 20px 0;
}

.tc-hint-icon {
    font-size: 40px;
    text-align: center;
    margin-bottom: 12px;
}

.tc-positioning-hint ul {
    margin: 0;
    padding: 0 0 0 20px;
    line-height: 2;
    color: var(--tc-text, #2d3436);
    font-size: 14px;
}

/* ── Test-Topbar (Step 5) ────────────────── */

.tc-test-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 24px;
}

.tc-timer {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-weight: 700;
    font-size: 24px;
    color: var(--tc-text, #2d3436);
}

.tc-timer-label {
    font-size: 13px;
    font-weight: 400;
    color: #636e72;
}

.tc-timer.tc-timer-warn {
    color: #d63031;
}

.tc-timer.tc-timer-warn .tc-timer-value {
    animation: tc-pulse 1s ease-in-out infinite;
}

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

.tc-test-progress {
    font-size: 14px;
    color: #636e72;
}

.tc-test-progress strong {
    color: var(--tc-text, #2d3436);
}

/* ── Frage-Bereich ───────────────────────── */

.tc-question-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #636e72;
    margin-bottom: 12px;
}

.tc-question-number {
    font-weight: 600;
    color: var(--tc-text, #2d3436);
}

.tc-question-subject {
    background: #f0f0f0;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.tc-question-text {
    font-size: 16px;
    line-height: 1.6;
    color: var(--tc-text, #2d3436);
    padding: 16px 20px;
    border-left: 3px solid var(--tc-primary, #1a7a6d);
    background: #f8f9fa;
    border-radius: 0 8px 8px 0;
    margin-bottom: 20px;
}

/* ── Antwort-Optionen ────────────────────── */

.tc-answers {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.tc-answer-label {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 2px solid #dfe6e9;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.tc-answer-label:hover {
    border-color: var(--tc-primary, #1a7a6d);
    background: rgba(26, 122, 109, 0.04);
}

.tc-answer-label.tc-answer-selected {
    border-color: var(--tc-primary, #1a7a6d);
    background: rgba(26, 122, 109, 0.08);
}

.tc-answer-label input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tc-answer-letter {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #dfe6e9;
    color: #636e72;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
}

.tc-answer-selected .tc-answer-letter {
    background: var(--tc-primary, #1a7a6d);
    color: #fff;
}

.tc-answer-text {
    font-size: 15px;
    line-height: 1.5;
    color: var(--tc-text, #2d3436);
}

/* ── Auswahl aufheben ────────────────────── */

.tc-deselect {
    display: inline-block;
    background: none;
    border: none;
    color: #636e72;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 24px;
    font-family: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.tc-deselect:hover {
    color: var(--tc-text, #2d3436);
}

/* ── Navigation ──────────────────────────── */

.tc-question-nav {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
}

.tc-btn-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: 2px solid #dfe6e9;
    border-radius: 6px;
    background: #fff;
    color: var(--tc-text, #2d3436);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.tc-btn-nav:hover {
    border-color: var(--tc-primary, #1a7a6d);
    background: rgba(26, 122, 109, 0.04);
}

.tc-btn-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tc-btn-nav-next {
    background: var(--tc-primary, #1a7a6d);
    color: #fff;
    border-color: var(--tc-primary, #1a7a6d);
}

.tc-btn-nav-next:hover {
    opacity: 0.9;
    background: var(--tc-primary, #1a7a6d);
    border-color: var(--tc-primary, #1a7a6d);
}

/* ── Fragen-Grid ─────────────────────────── */

.tc-question-grid-section {
    border-top: 1px solid #dfe6e9;
    padding-top: 24px;
    margin-bottom: 24px;
}

.tc-grid-title {
    font-size: 13px;
    font-weight: 600;
    color: #636e72;
    margin: 0 0 12px 0;
}

.tc-question-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.tc-grid-btn {
    width: 36px;
    height: 36px;
    border: 2px solid #dfe6e9;
    border-radius: 6px;
    background: #fff;
    color: var(--tc-text, #2d3436);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    padding: 0;
}

.tc-grid-btn:hover {
    border-color: var(--tc-primary, #1a7a6d);
}

.tc-grid-btn.tc-grid-answered {
    background: #27ae60;
    border-color: #27ae60;
    color: #fff;
}

.tc-grid-btn.tc-grid-current {
    border-color: var(--tc-primary, #1a7a6d);
    box-shadow: 0 0 0 2px rgba(26, 122, 109, 0.3);
}

.tc-grid-legend {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #636e72;
}

.tc-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.tc-legend-dot-answered {
    background: #27ae60;
}

.tc-legend-dot-open {
    background: #fff;
    border: 2px solid #dfe6e9;
}

.tc-legend-dot-current {
    background: #fff;
    border: 2px solid var(--tc-primary, #1a7a6d);
    box-shadow: 0 0 0 1px rgba(26, 122, 109, 0.3);
}

/* ── Test beenden Button ─────────────────── */

.tc-finish-section {
    text-align: center;
    padding-top: 8px;
}

.tc-btn-finish {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 32px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    background: #d63031;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.tc-btn-finish:hover {
    opacity: 0.9;
}

.tc-btn-finish:active {
    transform: scale(0.98);
}

/* ── Bestätigungsdialog ──────────────────── */

.tc-confirm-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.tc-confirm-overlay.tc-confirm-visible {
    display: flex;
}

.tc-confirm-dialog {
    background: #fff;
    border-radius: 12px;
    padding: 28px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.tc-confirm-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--tc-text, #2d3436);
    margin: 0 0 12px 0;
}

.tc-confirm-text {
    font-size: 14px;
    line-height: 1.6;
    color: #636e72;
    margin: 0 0 24px 0;
}

.tc-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.tc-btn-cancel {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    background: #f8f9fa;
    color: var(--tc-text, #2d3436);
    border: 1px solid #dfe6e9;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.tc-btn-cancel:hover {
    background: #e9ecef;
}

.tc-btn-confirm-finish {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    background: #d63031;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.tc-btn-confirm-finish:hover {
    opacity: 0.9;
}

/* ── Ergebnis-Box (Step 6) ───────────────── */

.tc-result-box {
    text-align: center;
    padding: 40px 20px;
}

.tc-result-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.tc-result-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--tc-text, #2d3436);
    margin: 0 0 24px 0;
}

.tc-result-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 32px;
}

.tc-stat {
    text-align: center;
}

.tc-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--tc-primary, #1a7a6d);
    display: block;
}

.tc-stat-label {
    font-size: 13px;
    color: #636e72;
}

/* ── Abschluss-Box (Step 7) ──────────────── */

.tc-completion-box {
    text-align: center;
    padding: 40px 20px;
}

.tc-completion-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.tc-completion-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--tc-text, #2d3436);
    margin: 0 0 12px 0;
}

.tc-completion-text {
    font-size: 15px;
    line-height: 1.6;
    color: #636e72;
    max-width: 400px;
    margin: 0 auto 24px auto;
}

.tc-completion-hint {
    font-size: 13px;
    color: #b2bec3;
    font-style: italic;
}

/* ── Responsive ───────────────────────────── */

@media (max-width: 600px) {
    .tc-app {
        padding: 16px;
    }

    .tc-form-row-half {
        flex-direction: column;
        gap: 0;
    }

    .tc-progress-label {
        font-size: 9px;
    }

    .tc-progress-num {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .tc-step-title {
        font-size: 18px;
    }

    .tc-btn {
        padding: 12px 20px;
        font-size: 15px;
    }

    .tc-qr-code {
        padding: 12px;
    }

    /* Test-Topbar responsive */
    .tc-test-topbar {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .tc-timer {
        font-size: 28px;
    }

    /* Grid-Items kleiner */
    .tc-grid-btn {
        width: 32px;
        height: 32px;
        font-size: 11px;
    }

    /* Dialog-Buttons gestapelt */
    .tc-confirm-actions {
        flex-direction: column;
    }

    .tc-confirm-actions button {
        width: 100%;
    }

    /* Ergebnis-Stats */
    .tc-result-stats {
        gap: 24px;
    }
}
