/* =====================================================================
   Vokabel-Trainer – Latein & Englisch
   Design: hell, freundlich, motivierend · Desktop & Tablet optimiert
   ===================================================================== */

:root {
  --bg: #eef2fa;
  --card: #ffffff;
  --ink: #26304a;
  --muted: #7b859c;
  --primary: #4f6df5;
  --primary-dark: #3d56d4;
  --ok: #2fae6e;
  --ok-bg: #e5f7ee;
  --err: #e05252;
  --err-bg: #fdecec;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(38, 48, 74, .10);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

/* ---------------- Navigation ---------------- */
.nav { background: #fff; box-shadow: 0 2px 10px rgba(38,48,74,.06); }
.nav-inner {
  max-width: 1080px; margin: 0 auto;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .8rem 1.2rem;
}
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--ink); }
.nav-links { display: flex; gap: .4rem; flex: 1; }
.nav-links a {
  text-decoration: none; color: var(--muted);
  padding: .5rem .9rem; border-radius: 10px; font-weight: 600;
}
.nav-links a:hover { background: var(--bg); color: var(--ink); }
.nav-links a.active { background: #e8edff; color: var(--primary-dark); }
.nav-user { display: flex; align-items: center; gap: .7rem; }
.user-chip {
  font-size: .85rem; font-weight: 600; color: var(--muted);
  background: var(--bg); padding: .35rem .8rem; border-radius: 999px;
}

/* ---------------- Layout ---------------- */
.container { max-width: 1080px; margin: 2rem auto 4rem; padding: 0 1.2rem; }
h1 { font-size: 1.7rem; margin: .4rem 0; }
h2 { font-size: 1.2rem; margin: .6rem 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.inline { display: inline; }

/* Vokabel-Tabelle: Aktions-Spalte (Bearbeiten / ⧉ kopieren / 🗑️ löschen) */
.row-actions { text-align: right; white-space: nowrap; vertical-align: middle; }
.row-copy { display: inline-block; margin-left: 4px; vertical-align: middle; position: relative; }
.row-copy summary {
  cursor: pointer; list-style: none; user-select: none;
  padding: .35rem .6rem; border: 1px solid #d8deeb; border-radius: 9px;
  background: var(--card); font-size: .95rem; line-height: 1;
}
.row-copy summary::-webkit-details-marker { display: none; }
.row-copy summary:hover { border-color: var(--primary); color: var(--primary); }
.row-copy[open] summary { border-color: var(--primary); color: var(--primary); }
.row-copy form { display: flex; gap: 6px; margin-top: 6px; justify-content: flex-end; align-items: center; }
@media (max-width: 700px) {
  .row-actions { white-space: normal; }
  .row-actions > * { margin-left: 4px; margin-bottom: 4px; }
}

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.4rem;
}
.admin-full { margin-top: 1.6rem; }
.cards-row {
  display: flex; gap: 1.4rem; flex-wrap: wrap; margin-top: 1.2rem;
}
.lang-card { flex: 1 1 300px; }
.lang-head { display: flex; align-items: center; gap: .9rem; margin-bottom: 1rem; }
.lang-emoji { font-size: 2.4rem; }

/* ---------------- Buttons & Forms ---------------- */
.btn {
  display: inline-block; border: none; cursor: pointer;
  font: inherit; font-weight: 600; text-decoration: none; text-align: center;
  padding: .7rem 1.3rem; border-radius: 12px;
  transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid #d4dae8; }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-danger { background: var(--err-bg); color: var(--err); }
.btn-danger:hover { background: #f9d7d7; }
.btn-sm { padding: .4rem .8rem; font-size: .85rem; border-radius: 9px; }
.btn-lg { padding: .9rem 2.2rem; font-size: 1.05rem; }
.btn-block { display: block; width: 100%; margin-top: .8rem; }
.btn-row { display: flex; gap: .7rem; margin-top: 1.1rem; flex-wrap: wrap; }
.btn-row.center { justify-content: center; }

label {
  display: block; font-weight: 600; font-size: .92rem;
  margin: .8rem 0; color: var(--ink);
}
input[type=text], input[type=password], input[type=email], select, textarea {
  width: 100%; margin-top: .35rem;
  padding: .65rem .8rem; font: inherit;
  border: 1.5px solid #cdd5e4; border-radius: 10px; background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,109,245,.15);
}
textarea { min-height: 160px; resize: vertical; font-family: ui-monospace, Consolas, monospace; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .9rem; }

/* ---------------- Flash-Nachrichten ---------------- */
.flash {
  padding: .85rem 1.1rem; border-radius: 12px;
  font-weight: 600; margin-bottom: 1.2rem;
}
.flash.success { background: var(--ok-bg); color: #1d7a4b; }
.flash.error   { background: var(--err-bg); color: #a33434; }

/* ---------------- Auth-Seiten ---------------- */
.auth-wrap { display: flex; justify-content: center; padding-top: 2vh; }
.auth-card { width: 100%; max-width: 420px; text-align: center; }
.auth-card h1 { font-size: 1.5rem; }

/* ---------------- Fortschrittsbalken (Mastery) ---------------- */
.progress {
  height: 12px; border-radius: 999px; background: #dde3f0;
  overflow: hidden; margin: .4rem 0 .2rem;
}
.progress span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #57c98a, var(--primary));
  transition: width .6s ease;
}
.mastery-label {
  display: flex; justify-content: space-between;
  font-size: .82rem; font-weight: 600; color: var(--muted);
}
.mini-progress { display: inline-block; width: 90px; vertical-align: middle; margin-right: .5rem; height: 9px; }

/* ---------------- 3D Card-Flip ---------------- */
.flip {
  perspective: 1200px;
  position: relative;
  height: 170px;
}
.study-card.flip { height: 170px; }
.quiz-card.flip   { height: 230px; }
.flip-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .6s cubic-bezier(.4, .2, .2, 1);
}
/* Flip NUR über die Klasse .flipped (per JS beim Drücken) – kein Hover! */
.flip.flipped .flip-inner { transform: rotateY(180deg); }

.flip-face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .5rem; padding: 1.2rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.flip-front { background: #fff; }
.flip-back {
  background: linear-gradient(135deg, #4f6df5, #7a5df0);
  color: #fff; transform: rotateY(180deg);
}
.card-hint { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; opacity: .65; margin: 0; }
.word { font-size: 2.2rem; margin: 0; text-align: center; word-break: break-word; }

/* ---------------- Quiz ---------------- */
.quiz-top {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 560px; margin: 0 auto .8rem;
}
.chip {
  background: #e8edff; color: var(--primary-dark);
  font-weight: 700; font-size: .85rem;
  padding: .35rem .9rem; border-radius: 999px;
}
.quiz-progress { max-width: 560px; margin: 0 auto 1.4rem; }
.quiz-card { max-width: 560px; margin: 0 auto; }
.quiz-card.is-correct .flip-front { background: var(--ok-bg); box-shadow: 0 8px 30px rgba(47,174,110,.25); }
.quiz-card.is-wrong   .flip-front { background: var(--err-bg); box-shadow: 0 8px 30px rgba(224,82,82,.25); }
.quiz-input-row { display: flex; gap: .7rem; max-width: 560px; margin: 1.3rem auto 0; }
.quiz-input-row input {
  font-size: 1.15rem; padding: .8rem 1rem;
}
#btn-check { min-width: 120px; }
.check-flash { max-width: 560px; margin: 1.3rem auto 0; }

.quiz-start {
  display: flex; flex-direction: column; gap: .4rem;
  max-width: 420px; margin: 1.2rem auto 0;
}
.center-card { max-width: 560px; margin: 0 auto; text-align: center; }

/* Quiz-Richtung (Fremdsprache→Deutsch / Deutsch→Fremdsprache) */
.dir-choice {
  display: grid; gap: .5rem;
  margin: .4rem 0 .2rem;
  text-align: left;
}
.dir-opt {
  display: flex; gap: .6rem; align-items: flex-start;
  border: 1px solid #d8def0; border-radius: 12px;
  padding: .65rem .9rem; cursor: pointer; background: #fff;
  transition: border-color .15s, background .15s;
}
.dir-opt:hover { border-color: #4f6df5; }
.dir-opt:has(input:checked) { border-color: #4f6df5; background: #eef1ff; }
.dir-opt input { margin-top: .3rem; accent-color: #4f6df5; }
.dir-opt span { font-size: .92rem; line-height: 1.35; }

/* ---------------- Ergebnis-Ring ---------------- */
.result .ring {
  --p: 0;
  width: 150px; height: 150px; border-radius: 50%;
  margin: 1rem auto 1.4rem;
  display: flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--ok) calc(var(--p) * 1%), #dde3f0 0);
}
.result .ring span {
  width: 112px; height: 112px; border-radius: 50%;
  background: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 800;
}

/* ---------------- Lernmodus (Card-Grid) ---------------- */
.study-grid {
  display: grid; gap: 1.2rem; margin-top: 1.4rem;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.study-card { cursor: pointer; outline: none; }
@media (max-width: 760px) {
  .study-card.flip { height: 150px; }
  .quiz-card.flip   { height: 200px; }
}
.study-card .flip-face { box-shadow: var(--shadow); }
.study-card h3 { margin: 0; font-size: 1.4rem; text-align: center; }
.diff { color: #f5a623; letter-spacing: .1em; font-size: .8rem; }

/* ---------------- Tabellen (Admin & Historie) ---------------- */
.table-wrap { overflow-x: auto; margin-top: 1rem; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th {
  text-align: left; color: var(--muted); font-size: .8rem;
  text-transform: uppercase; letter-spacing: .05em;
  padding: .6rem .7rem; border-bottom: 2px solid #e4e9f3;
}
.table td { padding: .65rem .7rem; border-bottom: 1px solid #edf0f7; vertical-align: middle; }
.table tr:hover td { background: #f7f9fe; }

/* ---------------- Admin-Layout ---------------- */
.admin-grid {
  display: grid; gap: 1.4rem; margin-top: 1.2rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

/* ---------------- Tabs (Sprache / Admin-Bereiche) ---------------- */
.tabs { display: flex; gap: .4rem; margin-top: 1.1rem; flex-wrap: wrap; }
.tab {
  text-decoration: none; color: var(--muted); font-weight: 600;
  padding: .5rem 1rem; border-radius: 10px; border: 1.5px solid transparent;
}
.tab:hover { background: #fff; color: var(--ink); }
.tab.active { background: #e8edff; color: var(--primary-dark); border-color: #c9d4ff; }
.tabs.sub-tabs { margin-top: .2rem; }

/* ---------------- Badges & Werkzeugleiste ---------------- */
.badge {
  display: inline-block; font-size: .75rem; font-weight: 700;
  padding: .15rem .6rem; border-radius: 999px; vertical-align: middle;
}
.badge-ok   { background: var(--ok-bg); color: #1d7a4b; }
.badge-warn { background: #fff3e0; color: #b26a00; }
.toolbar-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem;
}
.user-select-form label { display: flex; align-items: center; gap: .6rem; margin: 0; font-weight: 600; }
.user-select-form select { width: auto; min-width: 240px; margin-top: 0; }

/* ---------------- Responsiv (Tablet / klein) ---------------- */
@media (max-width: 760px) {
  .nav-inner { flex-wrap: wrap; gap: .8rem; }
  .container { margin-top: 1.2rem; }
  h1 { font-size: 1.4rem; }
  .word { font-size: 1.7rem; }
  .quiz-input-row { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Duplikate & Inline-Bearbeitung */
.badge-dup { background:#fdecec; color:#b02a37; border:1px solid #f3c1c6; border-radius:999px; padding:1px 8px; font-size:.75rem; font-weight:600; white-space:nowrap; }
tr.row-dupe > td { background:#fff6f6; }
.dup-bar { margin-bottom:12px; }
.inline-edit { display:block; padding:4px 0; }
.inline-edit .form-grid { grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); align-items:end; margin-bottom:8px; }
tr.row-edit > td { background:#f5f9ff; }
