/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --light: #f1f5f9;
    --dark: #1e293b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-container {
    width: 100%;
    max-width: 450px;
}

.login-box {
    background: white;
    border-radius: 16px;
    padding: 3rem;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.login-header h2 {
    font-size: 1.1rem;
    color: var(--secondary);
    font-weight: 500;
}

.login-footer {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.875rem;
    color: var(--secondary);
}

.login-footer code {
    background: var(--light);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: monospace;
    color: var(--primary);
}

/* Navigation */
.navbar {
    background: white;
    box-shadow: var(--shadow);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand h1 {
    font-size: 1.5rem;
    color: var(--primary);
}

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

.user-info {
    color: var(--secondary);
    font-size: 0.9rem;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-outline {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-block {
    width: 100%;
}

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

.btn-icon {
    padding: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
}

.btn-delete:hover {
    transform: scale(1.2);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #3b82f6;
}

/* Dashboard Grid */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

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

.stat-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

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

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary);
}

.stat-label {
    color: var(--secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Section Card */
.section-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.section-card h2 {
    margin-bottom: 1.5rem;
    color: var(--dark);
}

.section-card h3 {
    margin-bottom: 1rem;
    color: var(--dark);
}

/* Mode Grid */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.mode-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
}

.mode-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.mode-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.mode-card h3 {
    color: white;
    margin-bottom: 0.5rem;
}

.mode-card p {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 1rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-easy {
    background: #d1fae5;
    color: #065f46;
}

.badge-medium {
    background: #fed7aa;
    color: #92400e;
}

.badge-hard {
    background: #fecaca;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-admin {
    background: #ddd6fe;
    color: #5b21b6;
}

.badge-user {
    background: #d1fae5;
    color: #065f46;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead {
    background: var(--light);
}

table th,
table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table th {
    font-weight: 600;
    color: var(--dark);
}

table tbody tr:hover {
    background: var(--light);
}

.score-badge {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
}

.score-pass {
    background: #d1fae5;
    color: #065f46;
}

.score-fail {
    background: #fee2e2;
    color: #991b1b;
}

/* Progress */
.progress-container {
    margin-top: 1rem;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--light);
    border-radius: 12px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--primary));
    transition: width 0.3s;
    border-radius: 12px;
}

.progress-text {
    text-align: center;
    margin-top: 0.5rem;
    color: var(--secondary);
    font-size: 0.9rem;
}

/* Admin Grid */
.admin-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.form-section {
    background: var(--light);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.stat-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.stat-mini {
    flex: 1;
    min-width: 120px;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-mini strong {
    display: block;
    font-size: 1.5rem;
    color: var(--primary);
}

.stat-mini span {
    font-size: 0.85rem;
    color: var(--secondary);
}

.help-text {
    color: var(--secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.link {
    color: var(--primary);
    text-decoration: underline;
}

.file-input-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-input-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    border: 2px dashed var(--border);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
}

.file-input-label:hover {
    border-color: var(--primary);
    background: var(--light);
}

.file-icon {
    font-size: 2rem;
}

.danger-zone {
    background: #fee2e2;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--danger);
    margin-top: 2rem;
}

.danger-zone h3 {
    color: var(--danger);
    margin-bottom: 0.5rem;
}

/* Test Container */
.test-container {
    display: flex;
    gap: 2rem;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.test-sidebar {
    width: 300px;
    flex-shrink: 0;
}

.test-info {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.test-info h3 {
    margin-bottom: 1rem;
    color: var(--dark);
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--secondary);
    font-size: 0.9rem;
}

.info-value {
    font-weight: 600;
    color: var(--dark);
}

.test-notice {
    background: #dbeafe;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #1e40af;
    margin-bottom: 1rem;
}

.question-nav {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.nav-pagination-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

.nav-range {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
}

.question-nav-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.question-nav-btn {
    aspect-ratio: 1;
    border: 1px solid var(--border);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s;
}

.question-nav-btn:hover {
    background: var(--light);
}

.question-nav-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.question-nav-btn.answered {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.nav-pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border);
}

.nav-page-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s;
    color: var(--dark);
}

.nav-page-btn:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-1px);
}

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

.nav-page-indicator {
    font-size: 0.85rem;
    color: var(--secondary);
    font-weight: 500;
}

.test-main {
    flex: 1;
}

#test-area {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    min-height: 400px;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.question-number {
    font-size: 0.9rem;
    color: var(--secondary);
    font-weight: 600;
}

.question-text {
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--dark);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.options-list {
    list-style: none;
}

.option-item {
    margin-bottom: 1rem;
}

.option-btn {
    width: 100%;
    text-align: left;
    padding: 1.25rem;
    border: 2px solid var(--border);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
}

.option-btn:hover {
    border-color: var(--primary);
    background: var(--light);
}

.option-btn.selected {
    border-color: var(--primary);
    background: #dbeafe;
}

.option-btn.correct {
    border-color: var(--success);
    background: #d1fae5;
    animation: pulse-green 0.5s;
}

.option-btn.wrong {
    border-color: var(--danger);
    background: #fee2e2;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

@keyframes pulse-green {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes blink-red {
    0%, 50%, 100% { background: #fee2e2; border-color: var(--danger); }
    25%, 75% { background: white; border-color: var(--border); }
}

.option-btn.blink {
    animation: blink-red 0.4s 2;
}

.test-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
}

.timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    color: var(--dark);
}

.timer.warning {
    background: #fed7aa;
    color: #92400e;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 2rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    color: var(--dark);
    text-align: center;
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.result-summary {
    text-align: center;
    margin-bottom: 2rem;
}

.result-score {
    font-size: 4rem;
    font-weight: bold;
    color: var(--primary);
    margin: 1rem 0;
}

.result-message {
    font-size: 1.2rem;
    color: var(--secondary);
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 2rem;
}

.result-stat {
    text-align: center;
    padding: 1rem;
    background: var(--light);
    border-radius: 8px;
}

.result-stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
}

.result-stat-label {
    font-size: 0.85rem;
    color: var(--secondary);
}

/* Flashcard */
.flashcard-container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.flashcard-header {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.flashcard-counter {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 1rem;
}

.flashcard-main {
    perspective: 1000px;
    margin-bottom: 2rem;
}

.flashcard {
    width: 100%;
    height: 400px;
    cursor: pointer;
    position: relative;
}

.flashcard-inner {
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    position: relative;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.flashcard-back {
    transform: rotateY(180deg);
}

.flashcard-label {
    font-size: 0.9rem;
    color: var(--secondary);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.flashcard-content {
    font-size: 1.4rem;
    color: var(--dark);
    text-align: center;
    line-height: 1.6;
}

.flashcard-hint {
    margin-top: 2rem;
    font-size: 0.85rem;
    color: var(--secondary);
    font-style: italic;
}

.flashcard-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.flashcard-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.action-btn {
    flex: 1;
    max-width: 150px;
    padding: 1rem;
    border: 2px solid var(--border);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.action-icon {
    font-size: 2rem;
}

.action-hard:hover {
    border-color: var(--danger);
}

.action-okay:hover {
    border-color: var(--warning);
}

.action-easy:hover {
    border-color: var(--success);
}

/* Responsive */
@media (max-width: 1024px) {
    .test-container {
        flex-direction: column;
    }
    
    .test-sidebar {
        width: 100%;
    }
    
    .question-nav-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }
    
    .stats-row {
        grid-template-columns: 1fr;
    }
    
    .mode-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .result-stats {
        grid-template-columns: 1fr;
    }
    
    .question-nav {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .flashcard {
        height: 300px;
    }
    
    .flashcard-front,
    .flashcard-back {
        padding: 2rem;
    }
    
    .flashcard-content {
        font-size: 1.1rem;
    }
}

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

.fade-in {
    animation: fadeIn 0.3s ease-in;
}
