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

:root {
  --primary: #25d366;
  --primary-dark: #1da851;
  --danger: #e74c3c;
  --success: #27ae60;
  --bg: #f0f2f5;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #6c757d;
  --border: #dee2e6;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

/* ── Navbar ───────────────────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.nav-links a {
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text);
  transition: background .15s;
}

.nav-links a:hover { background: var(--bg); text-decoration: none; }
.nav-links a.active { background: #e6f9f0; color: var(--primary-dark); font-weight: 600; }
.nav-links a.logout { color: var(--danger); }

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

.page-title { font-size: 1.6rem; font-weight: 700; margin-bottom: 1.25rem; }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

/* ── Flash messages ───────────────────────────────────────────── */
.flash-messages { margin-bottom: 1rem; }
.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.flash-success { background: #d4edda; color: #155724; }
.flash-error   { background: #f8d7da; color: #721c24; }
.flash-info    { background: #d1ecf1; color: #0c5460; }

/* ── Stats grid ───────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  text-align: center;
}

.stat-value { font-size: 2.5rem; font-weight: 800; color: var(--primary-dark); }
.stat-label { font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem; }

/* ── Two-column layout ────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 720px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ── Data table ───────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.data-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }
.struggling-row td { background: #fff8f0; }
.example-cell { color: var(--muted); font-style: italic; max-width: 260px; }

/* ── Mistake list ─────────────────────────────────────────────── */
.mistake-list { list-style: none; }
.mistake-list li { padding: 0.6rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.mistake-list li:last-child { border-bottom: none; }
.wrong { color: var(--danger); text-decoration: line-through; }
.correct { color: var(--success); font-weight: 600; }
.explanation { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  text-align: center;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-full { width: 100%; display: block; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.mt-1 { margin-top: 0.75rem; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus { outline: none; border-color: var(--primary); }

/* ── Login ────────────────────────────────────────────────────── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 40px);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  text-align: center;
}

.login-card h1 { font-size: 1.6rem; margin-bottom: 0.4rem; }
.subtitle { color: var(--muted); margin-bottom: 1.5rem; font-size: 0.95rem; }
.login-form { text-align: left; }

/* ── Filter bar ───────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.search-input {
  flex: 1;
  min-width: 180px;
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.search-input:focus { outline: none; border-color: var(--primary); }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

/* ── Quiz ─────────────────────────────────────────────────────── */
.quiz-card { text-align: center; max-width: 560px; margin: 0 auto; }
.quiz-prompt { color: var(--muted); font-size: 0.95rem; margin-bottom: 0.5rem; }
.quiz-word { font-size: 2.5rem; font-weight: 800; margin-bottom: 0.5rem; }
.quiz-example { color: var(--muted); margin-bottom: 1.25rem; }

.quiz-input {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.quiz-input:focus { outline: none; border-color: var(--primary); }

.quiz-result { text-align: center; max-width: 560px; margin: 0 auto; }
.result-correct { border-left: 4px solid var(--success); }
.result-wrong   { border-left: 4px solid var(--danger); }
.quiz-actions { margin-top: 1rem; }

/* ── Settings ─────────────────────────────────────────────────── */
.settings-card { max-width: 500px; }

.toggle-group { display: flex; flex-direction: column; gap: 0.25rem; }
.toggle-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-weight: 600; }
.hint { font-size: 0.8rem; color: var(--muted); }

/* ── Mistake meta ─────────────────────────────────────────────── */
.mistake-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.category-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

.mistake-date { font-size: 0.75rem; color: var(--muted); }

/* ── Lang toggle ──────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.section-header h3 { margin-bottom: 0; }

.lang-toggle {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.lang-btn {
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.lang-btn.active {
  background: var(--primary);
  color: #fff;
}

.lang-btn:hover:not(.active) { background: var(--bg); }

/* ── Admin / forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.3rem; color: var(--muted); }
.form-input {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--surface);
}
.form-input:focus { outline: none; border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn-danger:hover { background: #c0392b; }

/* ── Misc ─────────────────────────────────────────────────────── */
.empty-msg { color: var(--muted); font-style: italic; padding: 0.5rem 0; }
.text-center { text-align: center; }
.total-count { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
