/* app.css - Qcollect Stylesheet */
:root {
  --header-bg: #1e3a5f;
  --accent: #f59e0b;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.12);
  --font-main: 'Inter', sans-serif;
  --font-display: 'Syne', sans-serif;
  --transition: 0.2s ease;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── NAVBAR ───────────────────────────────────── */
.navbar {
  background: var(--header-bg);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  flex-shrink: 0;
}
.nav-logo { height: 32px; border-radius: 4px; }
.nav-icon { font-size: 1.4rem; }
.nav-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  letter-spacing: -.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex: 1;
  padding-left: 1rem;
}
.nav-link {
  color: rgba(255,255,255,.75);
  text-decoration: none;
  padding: .35rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  transition: var(--transition);
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.12);
  color: #fff;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}
.nav-username { font-size: .8rem; color: rgba(255,255,255,.7); }

.nav-badge {
  font-size: .7rem;
  font-weight: 600;
  padding: .2rem .5rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.role-admin { background: #dc2626; color: #fff; }
.role-schuladmin { background: #7c3aed; color: #fff; }
.role-lehrer { background: #059669; color: #fff; }

/* ── LAYOUT ───────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

.app-footer {
  text-align: center;
  padding: 1rem;
  color: var(--text-muted);
  font-size: .8rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ── PAGE HEADER ──────────────────────────────── */
.page-header {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}
.page-header p { color: var(--text-muted); font-size: .9rem; margin-top: .25rem; }

/* ── CARDS ────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  background: #fafbfc;
}
.card-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.card-body { padding: 1.25rem; }

/* ── GRID ─────────────────────────────────────── */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* ── STAT CARDS ───────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin: .5rem 0 .25rem;
}
.stat-label { color: var(--text-muted); font-size: .85rem; }
.stat-icon { font-size: 1.5rem; margin-bottom: .25rem; }

/* ── BUTTONS ──────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  font-family: var(--font-main);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--info); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-secondary { background: #64748b; color: #fff; }
.btn-ghost { background: transparent; color: rgba(255,255,255,.8); border: 1px solid rgba(255,255,255,.3); }
.btn-outline { background: transparent; color: var(--info); border: 1px solid var(--info); }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }

/* ── FORMS ────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: .35rem;
  color: var(--text);
}
.form-label .required { color: var(--danger); margin-left: .2rem; }

.form-control {
  width: 100%;
  padding: .55rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: var(--font-main);
  background: var(--surface);
  color: var(--text);
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--info);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Checkboxes */
.check-group {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.check-group:hover { background: var(--bg); }
.check-group input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--success); }
.check-group label { cursor: pointer; font-size: .9rem; }

/* ── TABLES ───────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th {
  background: #f8fafc;
  padding: .65rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

/* ── BADGES ───────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .55rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ── ALERTS ───────────────────────────────────── */
.alert {
  padding: .85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border-left: 4px solid;
  font-size: .9rem;
}
.alert-success { background: #f0fdf4; border-color: var(--success); color: #166534; }
.alert-error { background: #fef2f2; border-color: var(--danger); color: #991b1b; }
.alert-info { background: #eff6ff; border-color: var(--info); color: #1e40af; }
.alert-warning { background: #fffbeb; border-color: var(--warning); color: #92400e; }

/* ── QUESTION CARD (Student) ──────────────────── */
.question-entry {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  transition: var(--transition);
}
.question-entry:hover { border-color: var(--info); box-shadow: var(--shadow-md); }
.question-entry .qe-number {
  position: absolute;
  top: -12px; left: 16px;
  background: var(--header-bg);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  padding: .1rem .55rem;
  border-radius: 20px;
}

.answers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .75rem; }
.answer-option {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.answer-option:hover { border-color: var(--success); background: #f0fdf4; }
.answer-option.correct { border-color: var(--success); background: #f0fdf4; }
.answer-option input[type="checkbox"] { margin-top: .15rem; flex-shrink: 0; accent-color: var(--success); }
.answer-option textarea { flex: 1; border: none; background: transparent; resize: none; outline: none; font-family: var(--font-main); font-size: .875rem; min-height: 40px; }

.answer-label {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
  flex-shrink: 0;
  margin-top: .1rem;
}
.answer-a { background: #dbeafe; color: #1e40af; }
.answer-b { background: #fce7f3; color: #9d174d; }
.answer-c { background: #dcfce7; color: #166534; }
.answer-d { background: #fef9c3; color: #854d0e; }

/* ── SESSION CODE DISPLAY ─────────────────────── */
.session-code-display {
  font-family: 'Courier New', monospace;
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: .3em;
  color: var(--header-bg);
  background: var(--bg);
  padding: 1rem 2rem;
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  text-align: center;
  margin: 1rem 0;
}

/* ── QUESTION REVIEW (Lehrer) ─────────────────── */
.q-review-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}
.q-review-header {
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
}
.q-review-body { padding: 1rem; }
.q-review-answers { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .75rem; }
.q-answer-pill {
  padding: .4rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.q-answer-pill.correct { background: #dcfce7; border: 1px solid #86efac; }
.q-answer-pill.wrong { background: #f8fafc; border: 1px solid var(--border); color: var(--text-muted); }

/* ── LOGIN PAGE ───────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--header-bg) 0%, #2d5282 50%, #1a3050 100%);
  padding: 1.5rem;
}
.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-logo .logo-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: .5rem;
}
.login-logo h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--header-bg);
}
.login-logo p { color: var(--text-muted); font-size: .9rem; }

/* ── STUDENT ENTRY PAGE ───────────────────────── */
.student-page {
  background: linear-gradient(135deg, #0f2044 0%, #1e3a5f 60%, #234876 100%);
  min-height: 100vh;
}
.student-page .main-content { padding: 1rem; }
.student-header {
  text-align: center;
  color: #fff;
  padding: 1.5rem 0 1rem;
}
.student-header h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
}
.student-header .session-info {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: rgba(255,255,255,.1);
  padding: .35rem .85rem;
  border-radius: 20px;
  margin-top: .5rem;
  font-size: .85rem;
}

/* ── MODALS ───────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: slideUp .25s ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-header h3 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 1.25rem; cursor: pointer;
  padding: .25rem; border-radius: 4px; color: var(--text-muted);
}
.modal-close:hover { background: var(--bg); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── EMPTY STATE ──────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: .5rem; color: var(--text); }

/* ── TABS ─────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; gap: 0; }
.tab {
  padding: .65rem 1.25rem;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  text-decoration: none;
  color: var(--text-muted);
  transition: var(--transition);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--info); border-bottom-color: var(--info); }

/* ── UTILITIES ────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-sm { font-size: .85rem; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.w-full { width: 100%; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── RESPONSIVE ───────────────────────────────── */
@media (max-width: 768px) {
  .navbar { padding: 0 1rem; }
  .nav-links { display: none; }
  .nav-links.open { display: flex; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0; background: var(--header-bg); padding: 1rem; z-index: 99; gap: .25rem; }
  .nav-username { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .answers-grid, .q-review-answers { grid-template-columns: 1fr; }
  .main-content { padding: 1rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .session-code-display { font-size: 1.8rem; letter-spacing: .2em; }
  .btn-group-mobile { flex-direction: column; }
  .hamburger { display: block !important; }
}
.hamburger {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  margin-left: auto;
}
