:root {
  --blue: #00426D;
  --blue-dark: #002f4f;
  --blue-light: #e6f0f7;
  --black: #1A1A1A;
  --white: #ffffff;
  --gray: #F5F5F5;
  --gray-mid: #e0e0e0;
  --green: #28A745;
  --red: #DC3545;
  --yellow: #FFC107;
  --radius: 12px;
}

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

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--gray);
  color: var(--black);
  min-height: 100vh;
}

/* ── Logo ───────────────────────────────────────────────────── */
.logo-bar {
  background: var(--blue);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo-bar img { height: 40px; object-fit: contain; }
.logo-bar span {
  color: var(--white);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
}

/* ── Language buttons ───────────────────────────────────────── */
.lang-btns {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.lang-btn {
  padding: 18px 36px;
  font-size: 22px;
  font-weight: 700;
  border: 3px solid var(--blue);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--blue);
  cursor: pointer;
  transition: all 0.2s;
  min-width: 120px;
}
.lang-btn:hover, .lang-btn.active {
  background: var(--blue);
  color: var(--white);
}

/* ── Primary button ─────────────────────────────────────────── */
.btn-primary {
  display: inline-block;
  background: var(--blue);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 16px 32px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
  text-align: center;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
  display: inline-block;
  background: transparent;
  color: var(--blue);
  border: 2px solid var(--blue);
  border-radius: var(--radius);
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  text-align: center;
}
.btn-outline:hover { background: var(--blue); color: var(--white); }

/* ── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  padding: 32px;
}

/* ── Hidden util ────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ════════════════════════════════════════════════════════════ */
/*  SCREEN PAGE                                                 */
/* ════════════════════════════════════════════════════════════ */
body.screen-page {
  background: var(--blue);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.screen-logo {
  position: absolute;
  top: 24px;
  left: 32px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.95);
  padding: 8px 16px;
  border-radius: 10px;
}
.screen-logo img { height: 44px; object-fit: contain; }
.screen-logo span { color: var(--blue); font-size: 20px; font-weight: 700; letter-spacing: 1px; }

/* Step: language selection */
#step-lang {
  text-align: center;
  color: var(--white);
}
#step-lang h1 { font-size: 48px; margin-bottom: 16px; }
#step-lang p { font-size: 24px; margin-bottom: 48px; opacity: 0.9; max-width: 600px; }
#step-lang .lang-btn {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.5);
  color: var(--white);
  font-size: 28px;
  padding: 20px 44px;
}
#step-lang .lang-btn:hover {
  background: var(--white);
  color: var(--blue);
  border-color: var(--white);
}

/* Step: video */
#step-video {
  width: 100%;
  max-width: 1200px;
  text-align: center;
}
#safety-video {
  width: 100%;
  border-radius: var(--radius);
  max-height: 80vh;
}

/* Step: QR + dots */
#step-qr {
  text-align: center;
  color: var(--white);
  width: 100%;
  max-width: 900px;
}
#step-qr h2 { font-size: 36px; margin-bottom: 8px; }
#step-qr p { font-size: 20px; opacity: 0.85; margin-bottom: 32px; }
#qr-image {
  width: 260px;
  height: 260px;
  background: white;
  border-radius: 16px;
  padding: 12px;
  display: inline-block;
  margin-bottom: 16px;
}
#qr-url { font-size: 16px; opacity: 0.7; margin-bottom: 40px; }

/* Participant dots grid */
#participants-area { margin-top: 24px; }
#participants-area h3 { font-size: 20px; margin-bottom: 16px; opacity: 0.8; }
#dots-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  max-width: 700px;
  margin: 0 auto;
}
.participant-dot {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--yellow);
  border: 3px solid rgba(255,255,255,0.3);
  transition: background 0.4s, transform 0.3s;
  animation: dotPop 0.3s ease;
}
.participant-dot.passed { background: var(--green); }
.participant-dot.failed { background: var(--red); }
@keyframes dotPop {
  0% { transform: scale(0); }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ════════════════════════════════════════════════════════════ */
/*  QUIZ PAGE                                                   */
/* ════════════════════════════════════════════════════════════ */
body.quiz-page {
  background: var(--gray);
  padding: 0;
}

.quiz-container {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 0 40px;
}

/* Step: language */
#q-step-lang {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  text-align: center;
  background: var(--blue);
  color: var(--white);
}
#q-step-lang img { height: 56px; margin-bottom: 24px; background: white; border-radius: 8px; padding: 6px 10px; object-fit: contain; }
#q-step-lang h1 { font-size: 28px; margin-bottom: 12px; }
#q-step-lang p { font-size: 16px; opacity: 0.85; margin-bottom: 36px; }
#q-step-lang .lang-btns { flex-direction: column; gap: 12px; width: 100%; max-width: 280px; }
#q-step-lang .lang-btn {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.4);
  color: var(--white);
  font-size: 20px;
  width: 100%;
}
#q-step-lang .lang-btn:hover { background: var(--white); color: var(--blue); }

/* Step: registration */
#q-step-reg {
  min-height: 100vh;
  padding: 24px;
}
#q-step-reg .card { margin-top: 0; }

.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 15px;
  color: var(--blue);
}
.form-group input {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  border: 2px solid var(--gray-mid);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--blue); }

/* Progress bar */
.progress-bar {
  background: var(--blue);
  height: 6px;
  transition: width 0.4s;
}
.progress-track {
  background: var(--gray-mid);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 24px;
}

/* Question card */
.question-counter {
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
}
.question-text {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 24px;
  color: var(--black);
}

/* Option buttons */
.options-list { display: flex; flex-direction: column; gap: 12px; }
.option-btn {
  padding: 16px 20px;
  border: 2px solid var(--gray-mid);
  border-radius: 10px;
  background: var(--white);
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.4;
}
.option-btn:hover { border-color: var(--blue); background: var(--blue-light); }
.option-btn.selected { border-color: var(--blue); background: var(--blue); color: var(--white); }

/* Result screen */
#q-step-result {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}
.result-icon { font-size: 72px; margin-bottom: 16px; }
.result-title { font-size: 32px; font-weight: 700; margin-bottom: 8px; }
.result-score { font-size: 48px; font-weight: 700; margin: 16px 0; }
.result-score span { font-size: 24px; font-weight: 400; }
.result-note { font-size: 14px; color: #888; margin-bottom: 32px; }
.passed-card { background: #e8f5e9; border: 2px solid var(--green); color: var(--green); }
.failed-card { background: #fdecea; border: 2px solid var(--red); color: var(--red); }

/* ════════════════════════════════════════════════════════════ */
/*  ADMIN PAGE                                                  */
/* ════════════════════════════════════════════════════════════ */
body.admin-page { background: var(--gray); }

.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 220px;
  background: var(--blue);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  flex-shrink: 0;
}
.admin-sidebar .logo { padding: 0 20px 24px; border-bottom: 1px solid rgba(255,255,255,0.15); }
.admin-sidebar .logo img { height: 36px; background: white; border-radius: 6px; padding: 4px 8px; object-fit: contain; }
.admin-sidebar .logo span { display: block; font-size: 12px; opacity: 0.7; margin-top: 4px; }

.admin-nav { margin-top: 16px; }
.admin-nav a {
  display: block;
  padding: 14px 20px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}
.admin-nav a:hover, .admin-nav a.active {
  background: rgba(255,255,255,0.12);
  color: var(--white);
  border-left: 3px solid var(--white);
}
.admin-nav a.active { border-left: 3px solid var(--white); }

.admin-main { flex: 1; padding: 32px; overflow-y: auto; }
.admin-main h2 { font-size: 24px; margin-bottom: 24px; color: var(--blue); }

/* Login */
#admin-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue);
}
.login-box {
  background: var(--white);
  border-radius: 16px;
  padding: 40px;
  width: 360px;
  text-align: center;
}
.login-box img { height: 48px; margin-bottom: 24px; }
.login-box h2 { font-size: 22px; margin-bottom: 8px; color: var(--blue); }
.login-box p { color: #666; margin-bottom: 24px; font-size: 14px; }
.login-box input {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  border: 2px solid var(--gray-mid);
  border-radius: 8px;
  margin-bottom: 16px;
  outline: none;
}
.login-box input:focus { border-color: var(--blue); }
.login-error { color: var(--red); font-size: 13px; margin-top: 8px; }

/* Results table */
.results-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green { background: #d4edda; color: #155724; }
.badge-red { background: #f8d7da; color: #721c24; }

table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--gray-mid); font-size: 14px; }
th { background: var(--blue); color: var(--white); font-weight: 600; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray); }

/* Questions editor */
.question-item {
  background: var(--white);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 12px;
  border-left: 4px solid var(--blue);
}
.question-item.inactive { border-left-color: var(--gray-mid); opacity: 0.6; }
.question-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.question-item-header .qnum { font-weight: 700; color: var(--blue); font-size: 13px; }
.q-actions { display: flex; gap: 8px; }
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
.btn-edit { background: var(--blue-light); color: var(--blue); }
.btn-delete { background: #fdecea; color: var(--red); }
.btn-toggle { background: var(--gray); color: #555; }

/* Session selector */
.session-select {
  padding: 10px 14px;
  border: 2px solid var(--gray-mid);
  border-radius: 8px;
  font-size: 14px;
  background: var(--white);
  outline: none;
  cursor: pointer;
}
.session-select:focus { border-color: var(--blue); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal {
  background: var(--white);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { font-size: 20px; color: var(--blue); margin-bottom: 24px; }
.modal-footer { display: flex; gap: 12px; margin-top: 24px; }
.modal-footer button { flex: 1; }

.field-group { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.field-group label { font-size: 12px; font-weight: 600; color: #555; margin-bottom: 4px; display: block; }
.field-group input, .field-group select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--gray-mid);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}
.field-group input:focus, .field-group select:focus { border-color: var(--blue); }

.correct-select {
  padding: 10px 14px;
  border: 2px solid var(--blue);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-light);
  width: 100%;
  margin-bottom: 16px;
  outline: none;
}

/* ════════════════════════════════════════════════════════════ */
/*  RESPONSIVE — Tablet & Phone portrait                        */
/* ════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Admin layout: sidebar → top bar */
  .admin-layout { flex-direction: column; }

  .admin-sidebar {
    width: 100%;
    padding: 0;
    flex-direction: column;
  }

  .admin-sidebar .logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
  }
  .admin-sidebar .logo img { height: 30px; }
  .admin-sidebar .logo span { font-size: 13px; margin-top: 0; }

  /* Nav items: horizontal scrollable row */
  .admin-nav {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    margin-top: 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .admin-nav::-webkit-scrollbar { display: none; }

  .admin-nav a {
    flex-shrink: 0;
    padding: 13px 16px;
    font-size: 13px;
    border-left: none !important;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
  }
  .admin-nav a:hover, .admin-nav a.active {
    border-left: none !important;
    border-bottom: 3px solid var(--white);
    background: rgba(255,255,255,0.12);
  }

  /* Main content: full width, less padding */
  .admin-main { padding: 16px; }
  .admin-main h2 { font-size: 20px; margin-bottom: 16px; }

  /* Login box: full width */
  .login-box { width: 100%; max-width: 360px; padding: 28px 20px; }

  /* Results toolbar: stack */
  .results-toolbar { flex-direction: column; align-items: stretch; }
  .results-toolbar select,
  .results-toolbar button { width: 100%; }

  /* Table: scrollable, larger touch targets */
  table { font-size: 13px; }
  th, td { padding: 10px 12px; }

  /* Hide # column and Valoda column on small screens */
  table th:first-child,
  table td:first-child,
  table th:nth-child(6),
  table td:nth-child(6) { display: none; }

  /* Questions list */
  .question-item { padding: 14px; }
  .question-item-header { flex-direction: column; gap: 10px; }
  .q-actions { width: 100%; justify-content: flex-end; }
  .btn-sm { padding: 8px 14px; font-size: 13px; }

  /* Modal: full screen */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    padding: 24px 16px;
  }

  /* field-group: single column */
  .field-group { grid-template-columns: 1fr; gap: 10px; }

  /* Sessions new session row */
  #section-sessions > div:first-of-type { flex-direction: column; }

  /* Session select full width */
  .session-select { width: 100%; }
}

@media (max-width: 480px) {
  .admin-main { padding: 12px; }
  th, td { padding: 9px 10px; font-size: 12px; }

  /* On very small screens also hide Datums column */
  table th:last-child,
  table td:last-child { font-size: 11px; }
}
