/* ============================================================
   Portal Edukacyjny CKZiU w Międzyrzeczu — style
   ============================================================ */
:root {
  --brand: #1d4ed8;
  --brand-600: #2563eb;
  --brand-700: #1e40af;
  --brand-soft: #eff6ff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-600); text-decoration: none; }
img { max-width: 100%; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.main { padding: 28px 20px 56px; min-height: 60vh; }
.muted { color: var(--ink-soft); }
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff;
  padding: 8px 14px; z-index: 999;
}
.skip-link:focus { left: 0; }

/* ---------- Nagłówek ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.header-inner { display: flex; align-items: center; gap: 24px; min-height: 68px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-badge {
  background: linear-gradient(135deg, var(--brand), #7c3aed);
  color: #fff; font-weight: 800; font-size: .78rem; letter-spacing: .04em;
  padding: 9px 8px; border-radius: 10px; text-align: center; line-height: 1;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1.05rem; font-weight: 800; }
.brand-text span { color: var(--ink-soft); font-weight: 600; font-size: .9rem; }
.brand-text small { color: var(--ink-soft); font-size: .72rem; letter-spacing: .02em; }
.main-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.main-nav a {
  color: var(--ink-soft); font-weight: 600; font-size: .92rem;
  padding: 8px 12px; border-radius: 9px;
}
.main-nav a.active { background: var(--brand); color: #fff; }
.header-user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-700);
  display: grid; place-items: center; font-weight: 800; font-size: .8rem;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { font-size: .88rem; }
.user-meta small { color: var(--ink-soft); font-size: .72rem; }

/* ---------- Przyciski ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  font-family: var(--font); font-weight: 600; font-size: .92rem;
  padding: 10px 18px; transition: all .15s ease; white-space: nowrap;
}
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .84rem; }
.btn-lg { padding: 13px 26px; font-size: 1rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Karty i siatka ---------- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.section-title { font-size: 1.3rem; font-weight: 800; margin: 0 0 6px; }
.section-sub { color: var(--ink-soft); margin: 0 0 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }

/* ---------- Alerty ---------- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; font-size: .92rem; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid #a7f3d0; }
.alert-info { background: var(--brand-soft); color: var(--brand-700); border: 1px solid #bfdbfe; }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 700;
  padding: 4px 10px; border-radius: 999px; letter-spacing: .02em;
}
.badge-blue { background: var(--brand-soft); color: var(--brand-700); }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-amber { background: var(--warning-soft); color: var(--warning); }
.badge-gray { background: #f1f5f9; color: var(--ink-soft); }

/* ---------- Formularze ---------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-family: var(--font); font-size: .94rem; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-600); outline-offset: 1px; border-color: var(--brand-600); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.help-text { font-size: .8rem; color: var(--ink-soft); margin-top: 4px; }
.checkbox-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.checkbox-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.checkbox-item input { width: auto; }
.checkbox-item label { margin: 0; font-weight: 500; cursor: pointer; }

/* ---------- Tabele ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f8fafc; font-weight: 700; color: var(--ink-soft); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Materiały ---------- */
.material-card { display: flex; flex-direction: column; gap: 10px; height: 100%; }
.material-icon {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; font-size: .8rem; background: var(--brand-soft); color: var(--brand-700); text-transform: uppercase;
}
.material-card h3 { margin: 0; font-size: 1.02rem; font-weight: 700; }
.material-card p { margin: 0; color: var(--ink-soft); font-size: .86rem; flex: 1; }
.material-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; align-items: end; }
.filters .form-group { margin: 0; flex: 0 0 auto; min-width: 150px; }

/* ---------- Egzamin / pytania ---------- */
.question-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.question-num { font-weight: 800; color: var(--brand-600); font-size: .82rem; letter-spacing: .04em; text-transform: uppercase; }
.question-text { font-size: 1.05rem; font-weight: 600; margin: 8px 0 16px; }
.question-image { margin: 12px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.answer-option {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 16px; border: 1.5px solid var(--line);
  border-radius: 11px; margin-bottom: 10px; cursor: pointer; transition: border-color .12s, background .12s;
}
.answer-option.selected { border-color: var(--brand-600); background: var(--brand-soft); }
.answer-option input { width: auto; margin-top: 3px; }
.answer-letter { font-weight: 800; color: var(--ink-soft); min-width: 24px; }
.answer-option.correct { border-color: var(--success); background: var(--success-soft); }
.answer-option.wrong { border-color: var(--danger); background: var(--danger-soft); }

/* ---------- Live / tablica ---------- */
.live-stage { background: var(--ink); color: #fff; border-radius: 20px; padding: 34px; text-align: center; }
.live-code {
  font-size: 3.2rem; font-weight: 800; letter-spacing: .3em; color: #fbbf24;
  background: #1e293b; display: inline-block; padding: 10px 26px; border-radius: 14px;
}
.live-question { font-size: 1.6rem; font-weight: 700; margin: 20px 0; }
.live-answers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.live-answer {
  background: #1e293b; border: 2px solid #334155; border-radius: 14px; padding: 20px;
  font-size: 1.15rem; font-weight: 600; text-align: left;
}
.live-answer.correct { border-color: #34d399; background: #064e3b; }
.live-answer .count { float: right; color: #94a3b8; font-size: .9rem; }
.leaderboard { list-style: none; padding: 0; margin: 16px 0 0; }
.leaderboard li {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 14px;
  border-radius: 10px; background: #1e293b; margin-bottom: 8px;
}
.leaderboard .rank { font-weight: 800; color: #fbbf24; width: 30px; }
.leaderboard .pts { font-weight: 800; color: #34d399; }
.leaderboard li.me { outline: 2px solid #60a5fa; }
.answered-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0 14px; }
.answered-chip {
  background: #f1f5f9; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: .84rem; font-weight: 600; color: var(--ink-soft);
}
.answered-chip.ok { background: var(--success-soft); color: var(--success); border-color: #a7f3d0; }

/* ---------- Mobile: odpowiedzi w jednej kolumnie ---------- */
@media (max-width: 640px) {
  .live-answers { grid-template-columns: 1fr; }
  .live-question { font-size: 1.25rem; }
  .live-answer { padding: 14px; font-size: 1rem; }
  .live-stage { padding: 20px 14px; }
  .live-code { font-size: 2.2rem; letter-spacing: .2em; }
}

/* ---------- Pasek aktywnej sesji ---------- */
.active-session-banner {
  background: linear-gradient(135deg, var(--brand-700), #7c3aed); color: #fff;
  border-radius: 14px; padding: 18px 22px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.active-session-banner .countdown { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.timer-pill { position: sticky; top: 80px; z-index: 40; }

/* ---------- Statystyki ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-card .stat-value { font-size: 1.9rem; font-weight: 800; }
.stat-card .stat-label { color: var(--ink-soft); font-size: .82rem; }

/* ---------- Pusty stan / misc ---------- */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state h1 { font-size: 2.4rem; margin-bottom: 8px; }
.empty-state p { color: var(--ink-soft); margin-bottom: 20px; }
.footer { margin-top: 40px; }
.site-footer { border-top: 1px solid var(--line); background: var(--card); margin-top: 40px; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; padding: 22px 20px; font-size: .86rem; color: var(--ink-soft); flex-wrap: wrap; }
.footer-inner p { margin: 0; }

.progress { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand-600); border-radius: 999px; transition: width .2s; }

.kbd { background:#f1f5f9; border:1px solid var(--line); border-bottom-width:2px; border-radius:6px; padding:2px 7px; font-family:monospace; font-size:.85rem; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-muted { color: var(--ink-soft); }
.hidden { display: none !important; }



/* --- Statystyki egzaminu --- */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat { background: var(--surface, #f8fafc); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.stat-val { font-size: 1.55rem; font-weight: 800; }
.stat-lab { font-size: .85rem; color: var(--ink-soft, #64748b); }
.stat-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.stat-row:last-child { border-bottom: 0; }
.stat-bar { flex: 1; height: 10px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.stat-bar > span { display: block; height: 100%; background: var(--brand-600, #4f46e5); border-radius: 999px; }
.stat-bar > span.bar-green { background: var(--success, #16a34a); }
.stat-bar > span.bar-amber { background: #d97706; }
.stat-bar > span.bar-red { background: var(--danger, #dc2626); }

/* --- Podgląd materiałów (modal) --- */
.pv-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .62); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.pv-box { background: #fff; border-radius: 14px; width: min(1100px, 96vw); height: 92vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.pv-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.pv-body { flex: 1; overflow: hidden; background: #525659; }
.pv-body iframe, .pv-body object { width: 100%; height: 100%; border: 0; display: block; }

/* --- Tryb ćwiczeń: feedback --- */
.answer-option.correct { border-color: var(--success, #16a34a) !important; background: rgba(22, 163, 74, .08); }
.answer-option.wrong { border-color: var(--danger, #dc2626) !important; background: rgba(220, 38, 38, .08); }

/* --- LIVE: widoczne zaznaczenie odpowiedzi ucznia --- */
.live-answer.selected { border-color: #60a5fa; background: #1e3a8a; }
.live-answer input { accent-color: #3b82f6; }

/* --- Hover WYŁĄCZNIE dla urządzeń z kursorem — na dotyku „przyklejony"
       hover mylił (opcje wyglądały jak zaznaczone, choć nie były) --- */
@media (hover: hover) and (pointer: fine) {
  a:hover { text-decoration: underline; }
  .brand:hover { text-decoration: none; }
  .main-nav a:hover { background: var(--brand-soft); color: var(--brand-700); text-decoration: none; }
  .btn:hover { text-decoration: none; }
  .btn-primary:hover { background: var(--brand-700); }
  .btn-ghost:hover { background: var(--bg); }
  .btn-danger:hover { background: #b91c1c; }
  .checkbox-item:hover { border-color: var(--brand-600); }
  tbody tr:hover { background: #fafbfc; }
  .answer-option:hover { border-color: var(--brand-600); }
  .live-answer:hover { border-color: #64748b; }
}

/* Dotyk: krótkie sprzężenie przy tapnięciu (zamiast hover) */
.answer-option:active, .live-answer:active { background: var(--brand-soft); }
