/* ── Reset & Variables ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface2:  #334155;
  --border:    #475569;
  --text:      #f1f5f9;
  --text-muted:#94a3b8;
  --primary:   #f59e0b;
  --primary-d: #d97706;
  --success:   #10b981;
  --danger:    #ef4444;
  --warn:      #f59e0b;
  --info:      #3b82f6;
  --purple:    #8b5cf6;
  --gold:      #fbbf24;
  --radius:    .6rem;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
}

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ─────────────────────────────────────────────────────── */
.topnav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.admin-tag {
  font-size: .65rem;
  background: var(--danger);
  color: #fff;
  padding: .1rem .4rem;
  border-radius: 999px;
  vertical-align: middle;
  font-weight: 700;
  letter-spacing: .05em;
}

.nav-links {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin-left: auto;
  flex-wrap: wrap;
}
.nav-links a {
  color: var(--text-muted);
  padding: .3rem .6rem;
  border-radius: var(--radius);
  font-size: .9rem;
  transition: color .15s, background .15s;
}
.nav-links a:hover { color: var(--text); background: var(--surface2); text-decoration: none; }
.nav-links a.active { color: var(--primary); }
.nav-user { color: var(--text-muted); font-size: .85rem; padding: .3rem .5rem; }

.btn-nav {
  padding: .35rem .8rem !important;
  border-radius: 999px !important;
  font-size: .85rem !important;
}
.btn-learn {
  background: var(--primary) !important;
  color: #000 !important;
  font-weight: 700;
  position: relative;
}
.btn-learn:hover { background: var(--primary-d) !important; }
.btn-ghost {
  border: 1px solid var(--border) !important;
  color: var(--text-muted) !important;
}
.badge-nav {
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  padding: .1rem .4rem;
  font-size: .7rem;
  font-weight: 700;
  margin-left: .3rem;
}

.nav-toggle, .nav-mobile { display: none; }

/* ── Container ───────────────────────────────────────────────── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: .8rem;
}
.collapsible > summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.collapsible > summary::-webkit-details-marker { display: none; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.2rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: filter .15s, transform .1s;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn:active { transform: scale(.97); }

.btn-primary  { background: var(--primary); color: #000; }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-secondary{ background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost    { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-warn     { background: #854d0e; color: #fef3c7; }
.btn-full     { width: 100%; justify-content: center; }
.btn-sm       { padding: .3rem .7rem; font-size: .8rem; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: .8rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-success { background: #052e16; border: 1px solid var(--success); color: #a7f3d0; }
.alert-error   { background: #450a0a; border: 1px solid var(--danger); color: #fca5a5; }
.alert-info    { background: #0c1a3a; border: 1px solid var(--info); color: #93c5fd; }

/* ── Auth pages ──────────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}
.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo h1 { font-size: 2rem; font-weight: 900; color: var(--primary); }
.logo-icon { font-size: 2.5rem; display: block; }
.auth-subtitle { color: var(--text-muted); font-size: .9rem; }
.auth-form { display: flex; flex-direction: column; gap: .8rem; }
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
}
.auth-form input, .auth-form select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .6rem .8rem;
  font-size: .95rem;
  width: 100%;
  transition: border-color .15s;
}
.auth-form input:focus, .auth-form select:focus {
  outline: none;
  border-color: var(--primary);
}
.auth-link { text-align: center; margin-top: 1rem; font-size: .85rem; color: var(--text-muted); }

/* ── Dashboard ───────────────────────────────────────────────── */
.dashboard-header { margin-bottom: 1.25rem; }
.dashboard-header h2 { font-size: 1.5rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  text-align: center;
  transition: border-color .15s, transform .15s;
}
.stat-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.stat-icon { font-size: 1.8rem; }
.stat-value { font-size: 1.7rem; font-weight: 800; margin: .25rem 0; }
.stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat-sub { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }

.xp-card .stat-value { color: var(--gold); }
.streak-card .stat-value { color: #fb923c; }
.progress-card .stat-value { color: var(--success); }
.learn-card { border-color: var(--primary); }
.learn-card .stat-value { color: var(--primary); }

/* ── Progress bars ───────────────────────────────────────────── */
.progress-bar-bg {
  background: var(--surface2);
  border-radius: 999px;
  height: .5rem;
  overflow: hidden;
  margin: .4rem 0;
}
.progress-bar-bg.small { height: .3rem; margin: .3rem 0; }
.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width .4s;
}
.progress-pct { font-size: .75rem; color: var(--text-muted); }
.progress-label { font-size: .8rem; color: var(--text-muted); }
.progress-wrap { margin-bottom: .5rem; }

/* ── Unidad progress ─────────────────────────────────────────── */
.unidad-list { display: flex; flex-direction: column; gap: .8rem; }
.unidad-item { }
.unidad-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
.unidad-name { font-size: .9rem; font-weight: 600; }
.unidad-pct { font-size: .85rem; color: var(--text-muted); font-weight: 700; }
.unidad-pct.done { color: var(--success); }
.unidad-meta { display: flex; gap: 1rem; font-size: .75rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Milestones ──────────────────────────────────────────────── */
.milestone-list { display: flex; flex-direction: column; gap: .6rem; }
.milestone-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .7rem 1rem;
  background: var(--surface2);
  border-radius: var(--radius);
  border-left: 3px solid var(--info);
}
.milestone-item.soon { border-left-color: var(--warn); }
.milestone-item.urgent { border-left-color: var(--danger); }
.ms-info { display: flex; align-items: center; gap: .5rem; }
.ms-deadline { text-align: right; }
.days-left { font-weight: 700; font-size: .9rem; color: var(--text-muted); }
.days-left.soon { color: var(--warn); }
.days-left.urgent { color: var(--danger); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text-muted);
}
.badge-ok   { background: #052e16; color: #a7f3d0; }
.badge-warn { background: #3b1202; color: #fde68a; }
.badge.dringend { background: #450a0a; color: #fca5a5; }
.badge.bald     { background: #3b1202; color: #fde68a; }
.badge.abgelaufen { background: var(--surface2); color: var(--text-muted); }

/* ── Learn page ──────────────────────────────────────────────── */
.learn-container { max-width: 640px; }

.learn-meta {
  display: flex;
  gap: .6rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.mode-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .25rem .75rem;
  font-size: .8rem;
  font-weight: 700;
  color: var(--primary);
}
.xp-info {
  font-size: .8rem;
  color: var(--gold);
  font-weight: 600;
}
.vocab-unit { font-size: .8rem; color: var(--text-muted); margin-left: auto; }

/* Learn cards */
.learn-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  box-shadow: var(--shadow);
}
.card-hint { font-size: .85rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.card-word { font-size: 2.2rem; font-weight: 800; }
.card-word.es { color: var(--primary); }
.card-word.de { color: var(--success); }
.card-sentence { font-size: .95rem; color: var(--text-muted); font-style: italic; }
.card-sentence-hint { font-size: .85rem; color: var(--text-muted); font-style: italic; }
.es-sentence { font-size: 1.2rem; color: var(--primary); font-weight: 600; }
.de-sentence { font-size: 1rem; color: var(--text-muted); }
.fill-sentence { font-size: 1.2rem; }
.es-sentence.big { font-size: 1.5rem; }
.blank { color: var(--primary); font-weight: 800; border-bottom: 2px solid var(--primary); padding: 0 .2rem; }
.hidden { display: none !important; }
.card-back { display: flex; flex-direction: column; align-items: center; gap: 1rem; width: 100%; }

.answer-btns { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }

/* Multiple choice */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; width: 100%; }
.choice-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .75rem 1rem;
  font-size: .95rem;
  cursor: pointer;
  text-align: center;
  transition: background .15s, border-color .15s;
}
.choice-btn:hover { background: var(--border); border-color: var(--primary); }

/* Typing input */
.type-form { display: flex; gap: .6rem; width: 100%; flex-wrap: wrap; justify-content: center; }
.type-input {
  flex: 1;
  min-width: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .65rem 1rem;
  font-size: 1rem;
  text-align: center;
  transition: border-color .15s;
}
.type-input:focus { outline: none; border-color: var(--primary); }

.learn-nav { display: flex; justify-content: space-between; margin-top: 1.25rem; }

/* Flash result */
.flash-result { }
.flash-top { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.xp-badge {
  background: var(--gold);
  color: #000;
  border-radius: 999px;
  padding: .15rem .6rem;
  font-size: .8rem;
  font-weight: 800;
}
.mode-tag {
  background: var(--surface2);
  border-radius: 999px;
  padding: .1rem .5rem;
  font-size: .75rem;
  color: var(--text-muted);
  margin-left: auto;
}
.correct-answer { margin-top: .4rem; font-size: .9rem; }

/* Done card */
.done-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem;
  display: inline-block;
  margin: 0 auto;
}

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { background: var(--surface2); color: var(--text-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; padding: .6rem .8rem; text-align: left; }
td { padding: .55rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.inactive-row td { opacity: .5; }
.text-muted { color: var(--text-muted); }

/* ── Forms (admin) ───────────────────────────────────────────── */
.inline-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 180px; }
.filter-form select { padding: .4rem .7rem; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: .85rem; }

.edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .5rem;
  margin-bottom: .75rem;
}
.edit-grid input, .edit-grid select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .5rem .7rem;
  font-size: .85rem;
  width: 100%;
}
.edit-grid input:focus, .edit-grid select:focus { outline: none; border-color: var(--primary); }
.edit-form { padding-top: .75rem; }
.edit-details summary { font-size: .8rem; }
.vocab-add-form { }

/* CSV file upload */
.csv-upload-form { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.file-upload-label { display: flex; flex-direction: column; gap: .3rem; }
.file-upload-label input[type="file"] {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .6rem;
  font-size: .9rem;
  cursor: pointer;
}
.file-upload-label input[type="file"]::-webkit-file-upload-button {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: .25rem .6rem;
  margin-right: .5rem;
  cursor: pointer;
}
.file-upload-hint { font-size: .8rem; color: var(--text-muted); }
.milestone-form { }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: .5rem; }
.page-header h2 { margin: 0; }

/* ── Admin body ──────────────────────────────────────────────── */
.admin-body { }
.admin-nav { border-bottom-color: #7c2d12; }

/* ── Misc ────────────────────────────────────────────────────── */
code {
  background: var(--surface2);
  padding: .15rem .4rem;
  border-radius: .3rem;
  font-size: .85em;
  font-family: monospace;
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .topnav { flex-wrap: wrap; }
  .nav-links { display: none; }
  .nav-toggle {
    display: block;
    margin-left: auto;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: .3rem .6rem;
    cursor: pointer;
    font-size: 1.1rem;
  }
  .nav-mobile {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: .3rem;
    padding-top: .5rem;
  }
  .nav-mobile.open { display: flex; }
  .nav-mobile a { padding: .5rem; border-radius: var(--radius); color: var(--text-muted); }

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .card-word { font-size: 1.6rem; }
  .choices { grid-template-columns: 1fr; }
  .learn-card { padding: 1.25rem; min-height: 220px; }
  .type-form { flex-direction: column; }
  .type-input { min-width: unset; width: 100%; }
  .edit-grid { grid-template-columns: 1fr; }
  .auth-box { padding: 1.25rem; }
  .container { padding: 1rem .75rem; }
}
