/* Quiz Maker — Stylesheet */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Noto Sans Arabic', 'Noto Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 920px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* ---- Cards ---- */

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.center-card {
    max-width: 440px;
    margin: 4rem auto;
    text-align: center;
}

.center-card h1 { margin-bottom: 0.5rem; font-size: 1.8rem; }
.center-card p  { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ---- Forms ---- */

.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

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

.input-large { font-size: 1.25rem; padding: 1rem; }
.text-center  { text-align: center; }
.mono         { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-size: 0.88rem; }

/* ---- Buttons ---- */

.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-primary       { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-hover); }
.btn-secondary       { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger          { background: var(--danger); color: #fff; }
.btn-block           { display: block; width: 100%; }
.btn-large           { padding: 0.9rem 1.5rem; font-size: 1.1rem; }
.btn-sm              { padding: 0.35rem 0.75rem; font-size: 0.85rem; }

/* ---- Flash Messages ---- */

.flash-messages { margin-bottom: 1.5rem; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.flash-error   { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.flash-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

/* ---- Quiz ---- */

.quiz-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.quiz-header h1 { margin-bottom: 0.25rem; }

.student-name { color: var(--text-muted); font-size: 0.95rem; }

.question-card {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border);
}
.question-card:last-of-type { border-bottom: none; }

.question-number {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
}

.question-text-ar {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.8;
}

.options { display: flex; flex-direction: column; gap: 0.5rem; }

.option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}
.option:hover { background: #f1f5f9; border-color: var(--primary); }
.option input[type="radio"] { width: 18px; height: 18px; accent-color: var(--primary); }

.submit-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}
.submit-section .text-muted { text-align: center; margin-bottom: 1rem; }

/* ---- Results (student view) ---- */

.result-header {
    text-align: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.score-display { margin-top: 1.5rem; }

.score-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px; height: 80px;
    border-radius: 50%;
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
}
.score-good { background: var(--success); }
.score-ok   { background: var(--warning); }
.score-bad  { background: var(--danger); }

.result-item { padding: 1rem 0; border-bottom: 1px solid var(--border); }

.answer { margin-top: 0.5rem; color: var(--text-muted); }

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 0.5rem;
}
.badge-correct { background: #dcfce7; color: var(--success); }
.badge-wrong   { background: #fef2f2; color: var(--danger); }
.badge-active  { background: #dcfce7; color: var(--success); padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.8rem; }
.badge-inactive { background: #fef2f2; color: var(--danger); padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.8rem; }

.correct-answer { color: var(--success); font-size: 0.85rem; margin-left: 0.5rem; }

.back-link { margin-top: 2rem; text-align: center; }

/* ---- Admin ---- */

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.admin-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.projects-grid { display: grid; gap: 1rem; }

.project-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 1.25rem;
}
.project-inactive { opacity: 0.6; }

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.project-card-header h2 { font-size: 1.15rem; margin: 0; }

.project-code {
    font-family: monospace;
    font-size: 0.9rem;
    background: #f1f5f9;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.project-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0.75rem 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.project-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.inline-form { display: inline; }

.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }

.help-text { margin-top: 0.5rem; font-size: 0.85rem; color: var(--text-muted); }
.help-text pre {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    font-size: 0.8rem;
    margin: 0.5rem 0;
}
.help-text details summary { cursor: pointer; color: var(--primary); font-weight: 500; }

/* ---- Results table (admin) ---- */

.results-table-wrapper {
    overflow-x: auto;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.results-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

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

.results-table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.results-table tbody tr:hover { background: #f8fafc; }

.student-name-cell { font-weight: 500; white-space: nowrap; }
.answer-cell { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.score-cell  { white-space: nowrap; }
.date-cell   { white-space: nowrap; font-size: 0.8rem; color: var(--text-muted); }

.mini-badge { display: inline-block; font-size: 0.7rem; font-weight: 700; margin-left: 2px; }
.mini-badge.correct { color: var(--success); }
.mini-badge.wrong   { color: var(--danger); }

.text-muted  { color: var(--text-muted); }
.empty-state { text-align: center; padding: 3rem; color: var(--text-muted); }

/* ---- Save indicator ---- */

.save-indicator {
    text-align: center;
    font-size: 0.85rem;
    color: var(--success);
    padding: 0.5rem;
    margin-bottom: 0.75rem;
    opacity: 0;
    transition: opacity 0.3s;
}
.save-indicator.visible { opacity: 1; }

/* ---- Responsive ---- */

@media (max-width: 600px) {
    .container { padding: 1rem 0.75rem; }
    .card { padding: 1.25rem; }
    .center-card { margin: 2rem auto; }
    .admin-header { flex-direction: column; }
    .project-card-header { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
    .project-actions { flex-wrap: wrap; }
    .form-actions { flex-direction: column; }
}
