/* ============================================
   German Grammar Trainer - Main Stylesheet
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: white;
    min-height: 100vh;
}

.container {
    background: white;
    padding: clamp(15px, 3vw, 35px);
    max-width: 1200px;
    width: 100%;
    min-height: 750px;
    margin: 0 auto;
}

/* ---------- Header ---------- */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    color: #333;
    font-size: 2.2em;
    margin-bottom: 10px;
}

/* ---------- Selectors ---------- */
.selectors {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.difficulty-selector,
.category-selector {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    flex: 1;
    min-width: 300px;
}

.selector-title {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: 600;
    text-align: center;
}

/* ---------- Difficulty Buttons ---------- */
.difficulty-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.difficulty-btn {
    padding: 10px 16px;
    border: 2px solid #ddd;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 14px;
}

.difficulty-btn.easy {
    border-color: #27ae60;
    color: #27ae60;
}
.difficulty-btn.easy.active,
.difficulty-btn.easy:hover {
    background: #27ae60;
    color: white;
    transform: translateY(-2px);
}

.difficulty-btn.medium {
    border-color: #f39c12;
    color: #f39c12;
}
.difficulty-btn.medium.active,
.difficulty-btn.medium:hover {
    background: #f39c12;
    color: white;
    transform: translateY(-2px);
}

.difficulty-btn.hard {
    border-color: #e74c3c;
    color: #e74c3c;
}
.difficulty-btn.hard.active,
.difficulty-btn.hard:hover {
    background: #e74c3c;
    color: white;
    transform: translateY(-2px);
}

/* ---------- Category Dropdown ---------- */
.category-dropdown {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}
.category-dropdown:focus {
    outline: none;
    border-color: #3498db;
}

/* ---------- Topic Picker ---------- */
.topic-picker {
    position: relative;
}
.topic-picker-display {
    width: 100%;
    padding: 12px 36px 12px 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 15px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.topic-picker-display:hover {
    border-color: #3498db;
}
.topic-picker-display.open {
    border-color: #3498db;
    border-radius: 10px 10px 0 0;
}
.topic-picker-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.topic-picker-arrow {
    font-size: 12px;
    color: #888;
    transition: transform 0.2s;
    margin-left: 8px;
}
.topic-picker-display.open .topic-picker-arrow {
    transform: rotate(180deg);
}
.topic-picker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #3498db;
    border-top: none;
    border-radius: 0 0 10px 10px;
    z-index: 100;
    max-height: 400px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}
.topic-search-input {
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}
.topic-search-input::placeholder {
    color: #aaa;
}
.topic-sort-bar {
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}
.topic-sort-btn {
    padding: 4px 10px;
    border: 1px solid #ddd;
    border-radius: 12px;
    background: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: #555;
}
.topic-sort-btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}
.topic-sort-btn:hover:not(.active) {
    background: #eef5fb;
    border-color: #3498db;
}
.topic-list {
    overflow-y: auto;
    max-height: 320px;
}
.topic-list-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.topic-list-item:hover {
    background: #eef5fb;
}
.topic-list-item.selected {
    background: #d6eaf8;
    font-weight: 600;
}
.topic-list-item .topic-count {
    color: #999;
    font-size: 12px;
    margin-left: auto;
    white-space: nowrap;
}
.topic-category-header {
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 700;
    color: #3498db;
    background: #f0f7fd;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 1;
}
.topic-list-item .topic-cat-badge {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 8px;
    background: #eee;
    color: #666;
    white-space: nowrap;
}
.topic-no-results {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* ---------- Stats ---------- */
.stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.stat-item {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 600;
    color: #555;
    font-size: 14px;
}

.stat-item.streak {
    background: linear-gradient(145deg, #ff9a9e, #fecfef);
    color: #d63384;
}
.stat-item.high-score {
    background: linear-gradient(145deg, #ffecd2, #fcb69f);
    color: #fd7e14;
}

.timer {
    color: #e74c3c;
}

/* ---------- Sentence Info ---------- */
.sentence-info {
    text-align: center;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-arrow {
    background: #3498db;
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
}
.nav-arrow:hover:not(:disabled) {
    background: #2980b9;
}
.nav-arrow:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    opacity: 0.5;
}

.sentence-jump {
    padding: 6px 10px;
    border-radius: 8px;
    border: 2px solid #3498db;
    font-size: 13px;
    max-width: 200px;
    background: white;
    cursor: pointer;
}

.sentence-counter {
    background: #3498db;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
}

.mastery-indicator {
    color: #27ae60;
    font-size: 20px;
    font-weight: bold;
}

/* ---------- Instructions ---------- */
.difficulty-instructions {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 10px;
    padding: 15px;
    margin: 20px 0;
    font-size: 14px;
    color: #1565c0;
}

/* ---------- Grammar Notes Box ---------- */
.grammar-notes {
    background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
    border: 1px solid #81c784;
    border-left: 5px solid #43a047;
    border-radius: 12px;
    padding: 0;
    margin: 0 0 20px;
    overflow: hidden;
    transition: all 0.3s ease;
}
.grammar-notes-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
}
.grammar-notes-icon {
    font-size: 20px;
    margin-right: 8px;
}
.grammar-notes-title {
    font-weight: 700;
    font-size: 15px;
    color: #2e7d32;
    flex: 1;
}
.grammar-notes-toggle {
    background: none;
    border: none;
    font-size: 16px;
    color: #2e7d32;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: transform 0.3s ease;
}
.grammar-notes-toggle.collapsed {
    transform: rotate(-90deg);
}
.grammar-notes-body {
    padding: 0 16px 14px;
    font-size: 14px;
    line-height: 1.7;
    color: #33691e;
}
.grammar-notes-body.hidden {
    display: none;
}
.grammar-notes-body ul {
    margin: 0;
    padding-left: 20px;
}
.grammar-notes-body li {
    margin-bottom: 4px;
}
.grammar-notes-body li::marker {
    color: #43a047;
}
.grammar-notes-body code {
    background: rgba(67, 160, 71, 0.13);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: #1b5e20;
}
.grammar-notes-body strong {
    color: #1b5e20;
}
.grammar-notes-body .note-section {
    margin-bottom: 8px;
}
.grammar-notes-body .note-section:last-child {
    margin-bottom: 0;
}

/* ---------- Question Context (Q&A mode) ---------- */
#question-context {
    background: linear-gradient(135deg, #fff8e1, #ffecb3);
    border-left: 5px solid #ffa000;
    border-radius: 10px;
    padding: 14px 20px;
    margin: 10px 0 5px;
    font-size: 17px;
    font-weight: 600;
    color: #e65100;
    line-height: 1.5;
}
#question-context .context-label {
    display: inline-block;
    background: #ff8f00;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 8px;
    vertical-align: middle;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
#question-context.context-antwort {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    border-left-color: #2e7d32;
    color: #1b5e20;
}
#question-context .context-label.label-antwort {
    background: #2e7d32;
}

/* ---------- Sentence Translation (shown above exercise) ---------- */
#sentence-translation {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border-left: 5px solid #1976d2;
    border-radius: 10px;
    padding: 12px 18px;
    margin: 8px 0 4px;
    font-size: 15px;
    font-weight: 500;
    color: #0d47a1;
    line-height: 1.5;
    font-style: italic;
}
#sentence-translation .translation-label {
    display: inline-block;
    background: #1976d2;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 8px;
    vertical-align: middle;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-style: normal;
}

/* ---------- Drop Zone & Word Pool ---------- */
.drop-zone {
    min-height: 100px;
    border: 3px dashed #ddd;
    border-radius: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px;
    margin: 20px 0;
    transition: all 0.3s ease;
    align-items: flex-start;
    align-content: flex-start;
}
.drop-zone.drag-over {
    border-color: #3498db;
    background-color: #e3f2fd;
}

.word-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
    margin: 20px 0;
    min-height: 80px;
}

/* ---------- Word Cards ---------- */
.word-card {
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
    border: 2px solid #ddd;
    border-radius: 12px;
    padding: 12px 18px;
    cursor: move;
    user-select: none;
    font-size: 16px;
    font-weight: 500;
    color: #333;
    transition: all 0.2s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    min-width: 40px;
    text-align: center;
}

.word-card.punctuation {
    background: linear-gradient(145deg, #fff3cd, #ffeaa7);
    border-color: #fd79a8;
    color: #856404;
    font-weight: 700;
    min-width: 30px;
    font-size: 20px;
}

.word-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    border-color: #3498db;
}

.word-card.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.word-card.drop-before {
    border-left: 3px solid #3498db;
    padding-left: 9px;
}

.word-card.correct {
    background: linear-gradient(145deg, #d4edda, #c3e6cb);
    border-color: #28a745;
    color: #155724;
}

.word-card.incorrect {
    background: linear-gradient(145deg, #f8d7da, #f5c6cb);
    border-color: #dc3545;
    color: #721c24;
    animation: shake 0.5s ease-in-out;
}

.word-card.verb-highlight {
    background: linear-gradient(145deg, #fff3cd, #ffeaa7);
    border: 3px solid #fd79a8;
    color: #856404;
    font-weight: 700;
    position: relative;
}
.word-card.verb-highlight::after {
    content: "VERB";
    position: absolute;
    top: -8px;
    right: -8px;
    background: #fd79a8;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 600;
}

/* ---------- Text Input (Level 3) ---------- */
.text-input-area {
    display: none;
    margin: 20px 0;
}

.text-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.3s ease;
}
.text-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}
.text-input.error {
    border-color: #dc3545;
}

/* ---------- Error Analysis ---------- */
.error-analysis {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 10px;
    padding: 15px;
    margin: 15px 0;
    display: none;
}
.error-analysis h4 {
    color: #721c24;
    margin-bottom: 10px;
}

.error-text {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    background: white;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #dee2e6;
}

.error-misspell {
    text-decoration: underline;
    text-decoration-color: #dc3545;
    text-decoration-thickness: 2px;
}
.error-conjugation {
    text-decoration: underline;
    text-decoration-color: #0dcaf0;
    text-decoration-thickness: 2px;
}
.error-position {
    text-decoration: underline;
    text-decoration-color: #ffc107;
    text-decoration-thickness: 2px;
}

/* ---------- Tooltips ---------- */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    text-align: center;
    border-radius: 6px;
    padding: 10px;
    font-size: 12px;
    font-weight: normal;
    z-index: 1000;
    width: 250px;
    transition: opacity 0.3s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.tooltip-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}
.tooltip:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}

/* ---------- Audio Controls ---------- */
.audio-controls {
    display: none;
    text-align: center;
    margin: 15px 0;
}

.audio-btn {
    background: #3498db;
    color: white;
    border: none;
    border-radius: 25px;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.audio-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

/* ---------- Animations ---------- */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* ---------- Controls & Buttons ---------- */
.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 25px 0;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: linear-gradient(145deg, #95a5a6, #7f8c8d);
    color: white;
}
.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(149, 165, 166, 0.3);
}

.btn-success {
    background: linear-gradient(145deg, #27ae60, #229954);
    color: white;
}
.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(39, 174, 96, 0.3);
}

.btn-warning {
    background: linear-gradient(145deg, #f39c12, #e67e22);
    color: white;
}
.btn-warning:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(243, 156, 18, 0.3);
}

.btn-info {
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
}
.btn-info:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(52, 152, 219, 0.3);
}

/* ---------- Feedback ---------- */
.feedback {
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.3s ease;
}
.feedback.correct {
    background: #d4edda;
    color: #155724;
    border: 2px solid #28a745;
}
.feedback.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #dc3545;
}

/* ---------- Completion Screen ---------- */
.completion-screen {
    display: none;
    text-align: center;
    padding: 40px 20px;
}
.completion-screen h2 {
    color: #27ae60;
    font-size: 2.5em;
    margin-bottom: 20px;
}

.final-stats {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    margin: 20px 0;
}
.final-stats h3 {
    color: #333;
    margin-bottom: 15px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    font-size: 16px;
}

/* ---------- Large Screens ---------- */
@media (min-width: 1400px) {
    .container {
        max-width: 1400px;
    }
}

@media (min-width: 1800px) {
    .container {
        max-width: 1600px;
    }
}

/* ---------- Mobile Responsiveness ---------- */
@media (max-width: 768px) {
    .container {
        padding: 15px;
        margin: 5px;
        border-radius: 14px;
        min-height: auto;
    }
    .header h1 {
        font-size: 1.6em;
    }
    .header p {
        font-size: 13px;
    }
    .selectors {
        flex-direction: column;
        gap: 12px;
    }
    .difficulty-selector,
    .category-selector {
        min-width: auto;
        padding: 14px;
    }
    .difficulty-buttons {
        flex-direction: column;
        align-items: center;
    }
    .difficulty-btn {
        width: 100%;
        max-width: 200px;
    }
    .word-card {
        font-size: 14px;
        padding: 10px 14px;
    }
    .stats {
        justify-content: center;
        text-align: center;
    }
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    .completion-screen h2 {
        font-size: 2em;
    }
    .drop-zone,
    .word-pool {
        padding: 12px;
        margin: 12px 0;
    }
    .difficulty-instructions {
        padding: 10px;
        margin: 12px 0;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 4px;
    }
    .container {
        padding: 10px;
        margin: 2px;
        border-radius: 10px;
    }
    .header h1 {
        font-size: 1.3em;
    }
    .header {
        margin-bottom: 15px;
    }
    .word-pool,
    .drop-zone {
        padding: 10px;
        gap: 6px;
    }
    .word-card {
        font-size: 13px;
        padding: 8px 12px;
    }
    .controls {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
    .btn {
        width: 100%;
        max-width: 250px;
    }
    .tooltip-content {
        width: 200px;
        font-size: 11px;
    }
    .stats {
        gap: 6px;
    }
    .stat-item {
        padding: 6px 8px;
        font-size: 12px;
    }
    .sentence-counter {
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* ─── Footer ─────────────────────────────────────────────── */
.site-footer {
    text-align: center;
    padding: 20px 15px;
    margin-top: 40px;
    color: #555;
    font-size: 12px;
    width: 100%;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.site-footer p {
    margin: 0;
}
