/* Reset und Basis-Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #4f46e5;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 1.8rem;
}

.nav {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.nav-btn {
    background: transparent;
    border: 2px solid #e5e7eb;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    color: #6b7280;
}

.nav-btn:hover {
    border-color: #4f46e5;
    color: #4f46e5;
    transform: translateY(-2px);
}

.nav-btn.active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: white;
}

/* User Selection */
.user-selection {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    padding-left: 1rem;
    border-left: 1px solid #e5e7eb;
}

.user-btn {
    background: #10b981;
    border: 2px solid #10b981;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    color: white;
    font-size: 0.9rem;
}

.user-btn:hover {
    background: #059669;
    border-color: #059669;
    transform: translateY(-2px);
}

.current-user {
    font-size: 0.9rem;
    color: #374151;
    font-weight: 500;
    white-space: nowrap;
}

/* User Modal */
.user-modal-content {
    max-width: 500px;
    width: 90%;
}

.user-list {
    margin-bottom: 2rem;
}

.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: #f9fafb;
    border-radius: 0.5rem;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 1;
}

.user-item:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.user-item.active {
    background: #eff6ff;
    border-color: #3b82f6;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-item {
    pointer-events: auto;
}

.user-item:active {
    background: #e5e7eb;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: #4f46e5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
}

.user-details h4 {
    margin: 0;
    font-size: 1rem;
    color: #111827;
}

.user-details p {
    margin: 0;
    font-size: 0.875rem;
    color: #6b7280;
}

.user-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #6b7280;
}

.new-user-section {
    border-top: 1px solid #e5e7eb;
    padding-top: 1.5rem;
}

.new-user-section h3 {
    margin: 0 0 1rem 0;
    color: #374151;
    font-size: 1.1rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

.input-group input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
}

.input-group input:focus {
    outline: none;
    border-color: #4f46e5;
}

.input-group .btn {
    padding: 0.75rem 1.5rem;
    white-space: nowrap;
}

/* Main Content */
.main {
    padding: 2rem 0;
    min-height: calc(100vh - 80px);
}

.section {
    display: none;
    animation: fadeIn 0.5s ease;
}

.section.active {
    display: block;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-header h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.section-header p {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Topic Grid */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.topic-card {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.topic-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border-color: #4f46e5;
}

.topic-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    text-align: center;
}

.topic-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #1f2937;
}

.topic-card p {
    color: #6b7280;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.topic-stats {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.9rem;
    color: #8b5cf6;
    font-weight: 500;
}

/* Test Configuration */
.test-config {
    max-width: 600px;
    margin: 0 auto;
}

.config-card {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.config-card h3 {
    font-size: 1.8rem;
    margin-bottom: 2rem;
    color: #1f2937;
    text-align: center;
}

.config-group {
    margin-bottom: 2rem;
}

.config-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #374151;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#question-count {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
}

#question-count::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4f46e5;
    cursor: pointer;
}

#question-count::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4f46e5;
    cursor: pointer;
    border: none;
}

#question-count-value {
    font-weight: 600;
    color: #4f46e5;
    min-width: 60px;
}

.topic-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: normal !important;
    margin-bottom: 0 !important;
}

.checkbox-label:hover {
    border-color: #4f46e5;
    background: rgba(79, 70, 229, 0.05);
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
}

.checkbox-label input[type="checkbox"]:checked + span {
    color: #4f46e5;
    font-weight: 600;
}

.start-test-btn {
    width: 100%;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    border: none;
    border-radius: 0.75rem;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.start-test-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(79, 70, 229, 0.3);
}

/* Test Interface */
.test-interface {
    max-width: 800px;
    margin: 0 auto;
}

.test-progress {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.progress-bar {
    flex: 1;
    height: 10px;
    background: #e5e7eb;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    transition: width 0.3s ease;
    border-radius: 5px;
}

.progress-text {
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.test-timer {
    font-weight: 600;
    color: #8b5cf6;
    white-space: nowrap;
}

.question-card {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f3f4f6;
}

.question-topic {
    background: #e0e7ff;
    color: #3730a3;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.question-type {
    background: #fef3c7;
    color: #92400e;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.question-text {
    font-size: 1.3rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    color: #1f2937;
}

.answer-options {
    margin-bottom: 2rem;
}

.answer-option {
    display: block;
    width: 100%;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-size: 1rem;
    line-height: 1.5;
}

.answer-option:hover {
    border-color: #4f46e5;
    background: rgba(79, 70, 229, 0.05);
}

.answer-option.selected {
    border-color: #4f46e5;
    background: #4f46e5;
    color: white;
}

.answer-option.multiple.selected {
    border-color: #059669;
    background: #059669;
    color: white;
}

.fill-blank-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.fill-blank-input:focus {
    outline: none;
    border-color: #4f46e5;
}

.question-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.action-btn {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.action-btn.primary {
    background: #4f46e5;
    color: white;
}

.action-btn.primary:hover:not(:disabled) {
    background: #4338ca;
    transform: translateY(-2px);
}

.action-btn.secondary {
    background: #f3f4f6;
    color: #374151;
    border: 2px solid #e5e7eb;
}

.action-btn.secondary:hover:not(:disabled) {
    background: #e5e7eb;
    transform: translateY(-2px);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Test Results */
.test-results {
    max-width: 800px;
    margin: 0 auto;
}

.results-header {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    margin-bottom: 2rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.results-score {
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.results-score.excellent { color: #059669; }
.results-score.good { color: #0891b2; }
.results-score.average { color: #d97706; }
.results-score.poor { color: #dc2626; }

.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.result-stat {
    text-align: center;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 0.5rem;
}

.result-stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1f2937;
}

.result-stat-label {
    color: #6b7280;
    font-size: 0.9rem;
}

.results-details {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.result-question {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 1rem;
}

.result-question:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.result-question.correct {
    background: rgba(5, 150, 105, 0.05);
    border-left: 4px solid #059669;
}

.result-question.incorrect {
    background: rgba(220, 38, 38, 0.05);
    border-left: 4px solid #dc2626;
}

.result-question-text {
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1f2937;
}

.result-answers {
    margin-left: 1rem;
}

.result-answer {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    border-radius: 0.25rem;
}

.result-answer.user-answer {
    background: rgba(79, 70, 229, 0.1);
    color: #4f46e5;
    font-weight: 500;
}

.result-answer.correct-answer {
    background: rgba(5, 150, 105, 0.1);
    color: #059669;
    font-weight: 500;
}

.result-answer.user-incorrect {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
    font-weight: 500;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: #6b7280;
    font-weight: 500;
}

.detailed-stats {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.detailed-stats h3 {
    margin-bottom: 1.5rem;
    color: #1f2937;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    background: white;
    border-radius: 1rem;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    width: 100%;
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 2rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
    color: #1f2937;
    font-size: 1.8rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
    line-height: 1;
}

.close-btn:hover {
    color: #374151;
}

.modal-body {
    padding: 2rem;
    line-height: 1.8;
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #4f46e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.loading p {
    color: #6b7280;
    font-weight: 500;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

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

.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem 20px;
    }
    
    .user-selection {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid #e5e7eb;
        padding-top: 0.5rem;
        width: 100%;
        justify-content: center;
    }

    .logo {
        font-size: 1.2rem;
    }

    .nav {
        width: 100%;
        justify-content: center;
    }

    .nav-btn {
        flex: 1;
        text-align: center;
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }

    .section-header h2 {
        font-size: 2rem;
    }

    .section-header p {
        font-size: 1rem;
    }

    .topic-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .topic-card {
        padding: 1.5rem;
    }

    .topic-stats {
        flex-direction: column;
        gap: 0.5rem;
    }

    .config-card {
        padding: 1.5rem;
    }

    .topic-checkboxes {
        grid-template-columns: 1fr;
    }

    .test-progress {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .progress-bar {
        order: 2;
    }

    .question-card {
        padding: 1.5rem;
    }

    .question-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .question-text {
        font-size: 1.1rem;
    }

    .answer-option {
        padding: 1rem;
        font-size: 0.95rem;
    }

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

    .action-btn {
        width: 100%;
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stat-card {
        padding: 1.5rem;
    }

    .modal {
        padding: 1rem;
    }

    .modal-content {
        max-width: 95vw;
    }

    .modal-header {
        padding: 1.5rem 1.5rem 1rem;
    }

    .modal-body {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .header .container {
        padding: 1rem 15px;
    }

    .logo {
        font-size: 1.1rem;
    }

    .nav-btn {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
    }

    .section-header h2 {
        font-size: 1.8rem;
    }

    .topic-card {
        padding: 1rem;
    }

    .topic-icon {
        font-size: 2.5rem;
    }

    .config-card {
        padding: 1rem;
    }

    .test-progress {
        padding: 1rem;
    }

    .question-card {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }
}