/* =====================================================================
   DeutschVokabeln — main stylesheet
   RTL-first (Arabic UI), calm colors, light/dark themes, fully responsive
   ===================================================================== */

:root {
  --font-arabic: "Cairo", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-german: "Segoe UI", "Helvetica Neue", Arial, sans-serif;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --transition: 0.18s ease;
}

/* ---------- Light theme (default) ---------- */
:root,
[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-soft: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --primary-strong: #1d4ed8;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --info: #0e7490;
  --info-soft: #cffafe;
  --header-bg: rgba(255, 255, 255, 0.85);
  --code-bg: #f1f5f9;
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] {
  --bg: #0f172a;
  --bg-soft: #172032;
  --surface: #1e293b;
  --surface-2: #24324a;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --border-strong: #475569;
  --primary: #3b82f6;
  --primary-soft: #1e3a5f;
  --primary-strong: #60a5fa;
  --success: #22c55e;
  --success-soft: #14532d;
  --danger: #ef4444;
  --danger-soft: #450a0a;
  --warning: #f59e0b;
  --warning-soft: #451a03;
  --info: #22d3ee;
  --info-soft: #164e63;
  --header-bg: rgba(30, 41, 59, 0.85);
  --code-bg: #0f172a;
}

/* ---------- Base ---------- */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-arabic);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  direction: rtl;
  text-align: right;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* German text is always LTR */
.german {
  font-family: var(--font-german);
  direction: ltr;
  unicode-bidi: embed;
  display: inline-block;
}

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

h1, h2, h3, h4 {
  margin: 0 0 0.5rem;
  line-height: 1.3;
  font-weight: 700;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  min-height: 44px; /* comfortable touch target */
  user-select: none;
}
.btn:hover {
  background: var(--primary-strong);
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.btn-success {
  background: var(--success);
}
.btn-success:hover {
  background: #15803d;
}
.btn-danger {
  background: var(--danger);
}
.btn-danger:hover {
  background: #b91c1c;
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.btn-sm {
  padding: 6px 12px;
  min-height: 36px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}
.btn-block {
  width: 100%;
}
.btn-icon {
  width: 44px;
  padding: 0;
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 18px;
}
label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input.is-invalid {
  border-color: var(--danger);
}
.field-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 4px;
}
.hint {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox input {
  width: auto;
}

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}
.alert-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: var(--success);
}
.alert-info {
  background: var(--info-soft);
  color: var(--info);
  border-color: var(--info);
}
.alert-warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: var(--warning);
}

/* ---------- Header / Navbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 62px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 19px;
  color: var(--text);
}
.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-inline-start: auto;
}
.nav-link {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover {
  color: var(--text);
  background: var(--bg-soft);
}
.nav-link.active {
  color: var(--primary);
  background: var(--primary-soft);
}
.nav-icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.nav-icon-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.badge {
  position: absolute;
  top: 2px;
  inset-inline-end: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}
.auth-card h1 {
  font-size: 24px;
  text-align: center;
}
.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 14px;
}
.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

/* ---------- Cards / panels ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card-title {
  font-size: 17px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------- Stats grid ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.stat-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.stat-label {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}
.stat-card.good .stat-value { color: var(--success); }
.stat-card.warn .stat-value { color: var(--warning); }
.stat-card.bad .stat-value { color: var(--danger); }

/* ---------- Progress bars ---------- */
.progress-wrap {
  margin-bottom: 10px;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.progress-bar {
  height: 10px;
  border-radius: 6px;
  background: var(--bg-soft);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  transition: width 0.5s ease;
}

/* ---------- Category tabs ---------- */
.tabs-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 20px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.tab {
  flex: 0 0 auto;
  padding: 10px 18px;
  border-radius: 30px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}
.tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.tab .tab-count {
  opacity: 0.75;
  font-size: 12px;
  margin-inline-start: 6px;
}

/* ---------- Word list ---------- */
.word-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.word-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), border-color var(--transition), background 0.6s ease;
  animation: slideIn 0.25s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.word-item.correct {
  border-color: var(--success);
  background: var(--success-soft);
  animation: flashGreen 0.8s ease;
}
.word-item.wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
  animation: flashRed 0.8s ease;
}
@keyframes flashGreen {
  0% { background: var(--success-soft); }
  60% { background: var(--success-soft); }
  100% { background: var(--surface); }
}
@keyframes flashRed {
  0% { background: var(--danger-soft); }
  60% { background: var(--danger-soft); }
  100% { background: var(--surface); }
}
.word-number {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.word-arabic {
  flex: 1 1 0;
  font-size: 17px;
  font-weight: 700;
  min-width: 0;
}
.word-german {
  flex: 1 1 0;
  text-align: center;
  min-width: 0;
}
.word-german .reveal-btn {
  background: var(--bg-soft);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 8px 22px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.word-german .reveal-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.word-german .revealed {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  padding: 6px 12px;
  border-radius: var(--radius);
  background: var(--primary-soft);
  animation: popIn 0.25s ease;
}
@keyframes popIn {
  from { transform: scale(0.92); opacity: 0.4; }
  to   { transform: scale(1); opacity: 1; }
}
.word-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  min-width: 160px;
}
.answer-btn {
  flex: 1;
  min-height: 48px;
  border-radius: var(--radius);
  border: 2px solid;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: all var(--transition);
  opacity: 0.5;
  pointer-events: none;
}
.answer-btn.enabled {
  opacity: 1;
  pointer-events: auto;
}
.answer-btn.correct-btn {
  border-color: var(--success);
  color: var(--success);
  background: var(--surface);
}
.answer-btn.correct-btn:hover {
  background: var(--success);
  color: #fff;
}
.answer-btn.wrong-btn {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--surface);
}
.answer-btn.wrong-btn:hover {
  background: var(--danger);
  color: #fff;
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .big-emoji {
  font-size: 46px;
  margin-bottom: 10px;
}

/* ---------- Notifications dropdown ---------- */
.notif-panel {
  position: absolute;
  inset-inline-end: 0;
  top: 48px;
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: none;
  padding: 6px;
}
.notif-panel.open {
  display: block;
  animation: popIn 0.2s ease;
}
.notif-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--border);
}
.notif-item.unread {
  background: var(--primary-soft);
}
.notif-item:last-child {
  border-bottom: none;
}
.notif-item .notif-title {
  font-weight: 700;
  font-size: 14px;
}
.notif-item .notif-msg {
  color: var(--text-muted);
  font-size: 13px;
}
.notif-item .notif-time {
  color: var(--text-muted);
  font-size: 11px;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th,
.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  vertical-align: middle;
}
.data-table th {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}
.data-table tr:hover td {
  background: var(--surface-2);
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}
.pagination button {
  min-width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.pagination button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}
.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.pagination .page-info {
  color: var(--text-muted);
  font-size: 13px;
  padding: 0 8px;
}

/* ---------- Toolbar / filters ---------- */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.toolbar .spacer {
  flex: 1;
}

/* ---------- Toggle switch (theme) ---------- */
.theme-toggle {
  position: relative;
  width: 56px;
  height: 30px;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  transition: background var(--transition);
}
.theme-toggle .knob {
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  transition: transform var(--transition), inset-inline-start var(--transition);
}
.theme-toggle.dark .knob {
  inset-inline-start: auto;
  inset-inline-end: 3px;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.25s ease;
}
.modal h3 {
  margin-bottom: 8px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
}

/* ---------- Success banner (category complete) ---------- */
.complete-banner {
  display: none;
  background: linear-gradient(135deg, var(--success-soft), var(--info-soft));
  border: 1px solid var(--success);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  margin-bottom: 20px;
  animation: popIn 0.4s ease;
}
.complete-banner h2 {
  color: var(--success);
}
.complete-banner p {
  color: var(--text-muted);
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 48px;
  padding: 24px 0 40px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  border-top: 1px solid var(--border);
}

/* ---------- Keyboard shortcuts hint ---------- */
.kbd-hint {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 12px;
  margin: 8px 0 16px;
}
kbd {
  background: var(--code-bg);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 2px 7px;
  font-family: var(--font-german);
  font-size: 11px;
}

/* ---------- Utility ---------- */
.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.center { text-align: center; }
.hidden { display: none !important; }
.rtl-toggle { display: flex; flex-direction: row; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  body {
    font-size: 15px;
  }
  .nav {
    height: 56px;
  }
  .nav-links .nav-link span.link-text {
    display: none;
  }
  .nav-link {
    padding: 8px;
    font-size: 17px;
  }
  .brand span.brand-text {
    display: none;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .word-item {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px;
  }
  .word-number {
    display: none;
  }
  .word-arabic {
    text-align: center;
    font-size: 18px;
  }
  .word-german {
    text-align: center;
  }
  .word-actions {
    min-width: 0;
    width: 100%;
  }
  .answer-btn {
    min-height: 52px;
    font-size: 16px;
  }
  .auth-card {
    padding: 26px 20px;
  }
  .notif-panel {
    position: fixed;
    inset-inline-start: 12px;
    inset-inline-end: 12px;
    top: 62px;
    width: auto;
  }
  .table-wrap {
    border-radius: var(--radius);
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar .spacer {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
