:root {
  color-scheme: light;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #d7dee8;
  --panel: #ffffff;
  --page: #f4f7fb;
  --brand: #176b87;
  --brand-dark: #0f5066;
  --accent: #d97706;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --shadow: 0 18px 45px rgba(30, 41, 59, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px clamp(18px, 4vw, 56px);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: clamp(28px, 4vw, 44px);
}

h2 {
  font-size: clamp(22px, 3vw, 34px);
}

main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.view {
  display: block;
}

.hidden {
  display: none !important;
}

/* ── Yükleme ekranı (giriş sonrası konular çekilirken) ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244, 247, 251, 0.85);
  z-index: 2000;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.eyebrow {
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.section-title p {
  color: var(--muted);
}

.topic-list {
  display: grid;
  gap: 30px;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.topic-group {
  display: block;
}

.topic-group h3 {
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--brand-dark);
  font-size: 24px;
}

.topic-card,
.login-panel,
.setup-panel,
.question-card,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel {
  display: grid;
  gap: 12px;
  width: min(420px, 100%);
  margin: 24px auto 0;
  padding: 24px;
}

.login-panel h2 {
  margin-bottom: 8px;
}

.login-panel label {
  font-weight: 700;
}

.login-panel input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.login-message {
  min-height: 22px;
  color: var(--danger);
  font-weight: 700;
}

.topic-card {
  display: grid;
  gap: 10px;
  min-height: 150px;
  padding: 20px;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.topic-card:hover,
.answer-option:hover {
  border-color: var(--brand);
}

.topic-card > span {
  color: var(--muted);
}

.topic-card strong {
  font-size: 22px;
}

/* Konu kartı: onaylı / onaysız rozet grubu */
.topic-counts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.count-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.count-approved {
  background: var(--ok-soft);
  color: var(--ok);
}

.count-unapproved {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Setup: filtre buton grubu */
.filter-label {
  font-weight: 700;
  margin-bottom: 8px;
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-btn {
  min-height: 38px;
  padding: 6px 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.filter-btn:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand-dark);
}

.filter-btn.active {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
}

.filter-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.setup-panel {
  width: min(520px, 100%);
  padding: 22px;
}

.setup-panel label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.count-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 16px;
}

input[type="number"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.mock-topic-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  max-height: 450px;
  overflow-y: auto;
  padding-right: 8px;
}

.mock-topic-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mock-topic-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mock-topic-info strong {
  font-size: 16px;
  color: var(--ink);
}

.mock-topic-info small {
  color: var(--muted);
  font-size: 13px;
}

.mock-counts {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 2px;
}

/* Mock ekranında filtre select + sayı input yan yana */
.mock-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.mock-filter-select {
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.mock-topic-input {
  width: 72px !important;
  text-align: center;
}

.mock-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  color: white;
  background: var(--brand);
}

.primary-button:hover {
  background: var(--brand-dark);
}

.primary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-button,
.ghost-button {
  color: var(--brand-dark);
  background: white;
  border-color: var(--line);
}

.secondary-button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.65;
}

.exam-header,
.exam-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.exam-header {
  margin-bottom: 16px;
}

.score-pill {
  min-width: 96px;
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--ok);
  background: #dcfce7;
  font-weight: 700;
  text-align: center;
}

/* ── Onay barı (sadece admin) ─────────────────────────── */
.approve-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.approve-btn {
  min-height: 38px;
  padding: 7px 18px;
  border-radius: 999px;
  border: 2px solid transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.approve-btn.approve {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: var(--ok);
}

.approve-btn.approve:hover {
  background: var(--ok);
  color: white;
}

.approve-btn.unapprove {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

.approve-btn.unapprove:hover {
  background: var(--danger);
  color: white;
}

.approve-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── Düzenle butonu (sadece admin) ────────────────────── */
.edit-btn {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #1d4ed8;
}

.edit-btn:hover:not(:disabled) {
  background: #1d4ed8;
  color: white;
}

/* ── Soruyu Sil butonu (sadece admin) ─────────────────── */
.delete-btn {
  background: #fff1f2;
  color: #9f1239;
  border-color: #9f1239;
}

.delete-btn:hover:not(:disabled) {
  background: #9f1239;
  color: white;
}

.question-card {
  padding: clamp(18px, 4vw, 32px);
}

.question-text {
  margin-bottom: 20px;
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 700;
  line-height: 1.35;
}

.answer-list {
  display: grid;
  gap: 10px;
}

.answer-option {
  display: grid;
  grid-template-columns: auto 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  cursor: pointer;
}

.answer-option input {
  width: 18px;
  height: 18px;
}

.answer-option span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  color: white;
  background: var(--accent);
  font-weight: 700;
}

.answer-option strong {
  line-height: 1.35;
}

.answer-option em {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
  white-space: nowrap;
}

.answer-option.is-correct {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.answer-option.is-correct span,
.answer-option.is-correct em {
  color: white;
  background: var(--ok);
}

.answer-option.is-wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.answer-option.is-wrong span,
.answer-option.is-wrong em {
  color: white;
  background: var(--danger);
}

.exam-actions {
  margin-top: 16px;
}

.result-panel {
  width: min(620px, 100%);
  margin: 0 auto;
  padding: clamp(22px, 5vw, 40px);
  text-align: center;
}

.big-score {
  margin: 16px 0;
  color: var(--brand-dark);
  font-size: clamp(44px, 8vw, 78px);
  font-weight: 800;
}

.result-panel p {
  color: var(--muted);
  line-height: 1.6;
}

.result-details {
  margin: 18px 0 22px;
  color: var(--ink);
  font-weight: 700;
}

/* ── Düzenleme Modalı ─────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-card {
  display: flex;
  flex-direction: column;
  width: min(600px, 100%);
  max-height: 90vh;
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 16px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
  background: var(--page);
  color: var(--ink);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.modal-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  resize: vertical;
  line-height: 1.5;
  font-size: 15px;
  color: var(--ink);
}

.modal-textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.12);
}

.modal-opts {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-opt-row {
  display: flex;
  flex-direction: column;
}

.modal-opt-input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  color: var(--ink);
}

.modal-opt-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.12);
}

.modal-correct-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-correct-option label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}

.modal-correct-option input[type="radio"] {
  display: none;
}

.modal-correct-option input[type="radio"]:checked + span {
  color: white;
}

.modal-correct-option:has(input:checked) label {
  border-color: var(--ok);
  background: var(--ok);
  color: white;
}

.modal-correct-option label:hover {
  border-color: var(--brand);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.modal-error {
  flex: 1;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  min-height: 20px;
  margin: 0;
}

/* ── Flashcard (Bilgi Kartı) ────────────────────────────────── */
.flashcard-container {
  background-color: transparent;
  width: 100%;
  min-height: 350px;
  perspective: 1000px; /* 3D efekti için */
  margin-bottom: 24px;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 350px;
  text-align: center;
  transition: transform 0.6s;
  transform-style: preserve-3d;
  cursor: pointer;
}

.flashcard-container.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  min-height: 100%;
  -webkit-backface-visibility: hidden; /* Safari */
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.flashcard-back {
  transform: rotateY(180deg);
  background: var(--ok-soft);
  border-color: var(--ok);
}


@media (max-width: 640px) {
  .topbar,
  .section-title,
  .exam-header,
  .exam-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .count-row {
    grid-template-columns: 1fr;
  }

  .answer-option {
    grid-template-columns: auto 38px minmax(0, 1fr);
  }

  .answer-option em {
    grid-column: 2 / -1;
    justify-self: start;
  }

  .mock-topic-row {
    flex-direction: column;
    align-items: stretch;
  }

  .mock-filter-group {
    justify-content: flex-end;
  }

  .approve-bar {
    justify-content: stretch;
  }

  .approve-bar .approve-btn {
    flex: 1;
    text-align: center;
  }

  .modal-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-footer .modal-error {
    text-align: center;
  }
}
