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

:root {
    --primary: #3498db;
    --secondary: #95a5a6;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --dark: #2c3e50;
    --light: #ecf0f1;
    --bg: #f5f7fa;
    --white: #ffffff;
    --text: #333333;
    --text-light: #7f8c8d;
    --border: #ddd;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background: var(--white);
    box-shadow: 0 2px 4px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.navbar-brand {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand:hover {
    opacity: 0.8;
}

.navbar-menu {
    display: flex;
    gap: 10px;
    align-items: center;
}

.nav-link {
    color: var(--text);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--bg);
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary);
    color: var(--white);
}

/* Footer */
.footer {
    background: var(--white);
    border-top: 1px solid var(--light);
    margin-top: auto;
    padding: 20px 0;
}

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

.footer-text {
    color: var(--text-light);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.footer-heart {
    color: var(--danger);
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    10%, 30% { transform: scale(1.1); }
    20%, 40% { transform: scale(1); }
}

/* Main Content */
.main-content {
    flex: 1;
    width: 100%;
}

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

/* Typography */
h1 {
    font-size: 28px;
    margin-bottom: 20px;
    color: var(--dark);
    font-weight: 700;
}

h2 {
    font-size: 22px;
    margin-bottom: 15px;
    color: #34495e;
    font-weight: 600;
}

h3 {
    font-size: 18px;
    margin-bottom: 10px;
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    margin: 4px;
    white-space: nowrap;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary { background: var(--primary); }
.btn-secondary { background: var(--secondary); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { display: block; width: 100%; text-align: center; }

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

/* Header (for pages) */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--light);
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 6px;
    font-size: 14px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-success {
    background: #d5f4e6;
    color: var(--success);
    border: 1px solid var(--success);
}

.alert-error {
    background: #fadbd8;
    color: var(--danger);
    border: 1px solid var(--danger);
}

/* Quiz Grid */
.quiz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.quiz-card {
    background: var(--white);
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow);
    transition: all 0.3s;
    border: 1px solid transparent;
}

.quiz-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px var(--shadow);
    border-color: var(--primary);
}

.quiz-card h3 {
    margin-bottom: 12px;
    color: var(--dark);
}

.quiz-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 14px;
    color: var(--text-light);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: var(--dark);
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: var(--white);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

textarea {
    min-height: 150px;
    font-family: 'Courier New', monospace;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
}

/* Auth Container */
.auth-container {
    max-width: 400px;
    margin: 50px auto;
    background: var(--white);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow);
}

/* Admin Sections */
.admin-section {
    background: var(--white);
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin-top: 15px;
    border-radius: 8px;
    border: 1px solid var(--light);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

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

th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 14px;
    color: var(--dark);
}

td {
    font-size: 14px;
}

tr:last-child td {
    border-bottom: none;
}

.text-success { color: var(--success); font-weight: 600; }
.text-danger { color: var(--danger); font-weight: 600; }

/* Quiz Taking */
.quiz-header {
    background: var(--white);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.quiz-info {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 14px;
    color: var(--text-light);
}

.question-counter {
    font-weight: 600;
    color: var(--primary);
}

.timer {
    font-weight: 600;
    color: var(--danger);
    display: flex;
    align-items: center;
    gap: 6px;
}

.timer.warning {
    animation: pulse 1s ease-in-out infinite;
}

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

.progress-bar {
    height: 6px;
    background: var(--light);
    border-radius: 3px;
    margin-bottom: 20px;
    overflow: hidden;
}

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

.question-card {
    background: var(--white);
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.question-text {
    font-size: 18px;
    line-height: 1.8;
    margin-bottom: 25px;
    color: var(--dark);
}

.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-label {
    display: flex;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border: 2px solid var(--light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.option-label:hover {
    border-color: var(--primary);
    background: #eef6fc;
    transform: translateX(4px);
}

.option-label.selected {
    border-color: var(--primary);
    background: #eef6fc;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
}

.option-label input[type="radio"] {
    width: 18px;
    height: 18px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: var(--primary);
}

.option-text {
    flex: 1;
    font-size: 15px;
}

.navigation-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    gap: 10px;
}

.nav-btn-group {
    display: flex;
    gap: 10px;
}

/* Results */
.result-container {
    max-width: 600px;
    margin: 50px auto;
    text-align: center;
}

.result-card {
    background: var(--white);
    padding: 40px;
    border-radius: 8px;
    margin: 30px 0;
    box-shadow: 0 4px 12px var(--shadow);
}

.result-card.pass {
    border: 3px solid var(--success);
}

.result-card.fail {
    border: 3px solid var(--danger);
}

.score-display {
    margin-bottom: 20px;
}

.score-number {
    font-size: 48px;
    font-weight: bold;
    color: var(--dark);
}

.score-percentage {
    font-size: 32px;
    color: var(--text-light);
    margin-top: 10px;
}

.result-status {
    font-size: 24px;
    font-weight: 600;
    margin-top: 15px;
}

.result-card.pass .result-status { color: var(--success); }
.result-card.fail .result-status { color: var(--danger); }

.status-icon {
    font-size: 36px;
    display: block;
    margin-bottom: 10px;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Review */
.review-container {
    max-width: 900px;
    margin: 0 auto;
}

.review-summary {
    background: var(--white);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.review-questions {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.review-item {
    background: var(--white);
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border-left: 4px solid var(--light);
}

.review-item.correct {
    border-left-color: var(--success);
}

.review-item.incorrect {
    border-left-color: var(--danger);
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.question-number {
    font-weight: 600;
    color: var(--dark);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
}

.review-item.correct .status-badge {
    background: #d5f4e6;
    color: var(--success);
}

.review-item.incorrect .status-badge {
    background: #fadbd8;
    color: var(--danger);
}

.review-question {
    font-size: 16px;
    margin-bottom: 15px;
    line-height: 1.6;
}

.review-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.review-option {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 6px;
    background: #f8f9fa;
    gap: 10px;
}

.review-option.correct-answer {
    background: #d5f4e6;
    border: 1px solid var(--success);
}

.review-option.user-answer:not(.correct-answer) {
    background: #fadbd8;
    border: 1px solid var(--danger);
}

.option-indicator {
    font-size: 18px;
    font-weight: bold;
    min-width: 20px;
}

.review-option.correct-answer .option-indicator {
    color: var(--success);
}

.review-option.user-answer:not(.correct-answer) .option-indicator {
    color: var(--danger);
}

.option-label-text {
    font-size: 12px;
    color: var(--text-light);
    font-style: italic;
}

.review-note {
    margin-top: 10px;
    padding: 10px;
    background: #fff3cd;
    border: 1px solid var(--warning);
    border-radius: 4px;
    color: #856404;
    font-size: 14px;
}

/* Code Blocks */
pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 10px 0;
}

code {
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

p code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--danger);
    font-size: 13px;
}

/* Help Section */
.help-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-top: 30px;
}

details {
    margin: 10px 0;
}

summary {
    cursor: pointer;
    font-weight: 600;
    padding: 10px;
    background: var(--white);
    border-radius: 4px;
}

details[open] summary {
    margin-bottom: 10px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--light);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .navbar-container {
        padding: 0 15px;
    }
    
    .navbar-brand {
        font-size: 20px;
    }
    
    .navbar-menu {
        gap: 5px;
    }
    
    .nav-link {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .container {
        padding: 20px 15px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .quiz-grid {
        grid-template-columns: 1fr;
    }
    
    .navigation-buttons {
        flex-direction: column;
    }
    
    .nav-btn-group {
        width: 100%;
        justify-content: space-between;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .result-card {
        padding: 30px 20px;
    }
    
    .score-number {
        font-size: 36px;
    }
    
    .score-percentage {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .quiz-card {
        padding: 20px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    h2 {
        font-size: 20px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }
}