/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #22263a;
  --accent: #4f8ef7;
  --accent2: #a78bfa;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #2d3354;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
header {
  background: linear-gradient(135deg, #1e2240 0%, #2d1f6e 50%, #1a2a5e 100%);
  padding: 2.5rem 1.5rem 2rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(79,142,247,.18) 0%, transparent 70%);
  pointer-events: none;
}

.logo {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #60a5fa, #a78bfa, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: .4rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 400;
}

/* ===== MAIN ===== */
main {
  flex: 1;
  max-width: 1300px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

/* ===== CONTROLS ===== */
.controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.search-wrap {
  position: relative;
  max-width: 460px;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  pointer-events: none;
}

#searchInput {
  width: 100%;
  padding: .75rem 1rem .75rem 2.8rem;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,142,247,.2);
}

#searchInput::placeholder { color: var(--text-muted); }

.level-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.filter-btn {
  padding: .5rem 1.2rem;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text-muted);
  font-size: .88rem;
  cursor: pointer;
  transition: all .2s;
  font-weight: 500;
}

.filter-btn:hover { border-color: var(--accent); color: var(--text); }

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 14px rgba(79,142,247,.4);
}

.filter-btn.beginner.active { background: var(--green); border-color: var(--green); box-shadow: 0 0 14px rgba(34,197,94,.4); }
.filter-btn.intermediate.active { background: var(--yellow); border-color: var(--yellow); box-shadow: 0 0 14px rgba(234,179,8,.4); color: #1a1d27; }
.filter-btn.advanced.active { background: var(--red); border-color: var(--red); box-shadow: 0 0 14px rgba(239,68,68,.4); }

/* ===== CONTROLS ROW 2 ===== */
.controls-row2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.5rem;
}

/* ===== STATS ===== */
.stats {
  color: var(--text-muted);
  font-size: .9rem;
  padding-left: .25rem;
}

/* ===== PER PAGE ===== */
.perpage-wrap {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .88rem;
  color: var(--text-muted);
}

#perPageSelect {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: .3rem .6rem;
  font-size: .88rem;
  cursor: pointer;
  outline: none;
  transition: border-color .2s;
}

#perPageSelect:focus { border-color: var(--accent); }

/* ===== CARDS GRID ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

/* ===== WORD CARD ===== */
.word-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
  animation: fadeIn .35s ease both;
}

.word-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1.1rem .7rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
}

.card-translation {
  font-size: .9rem;
  color: var(--text-muted);
  margin-top: .1rem;
  font-style: italic;
}

.level-badge {
  font-size: .72rem;
  font-weight: 700;
  padding: .25rem .65rem;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: .5px;
  flex-shrink: 0;
}

.badge-beginner     { background: rgba(34,197,94,.15);  color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.badge-intermediate { background: rgba(234,179,8,.15);  color: var(--yellow); border: 1px solid rgba(234,179,8,.3); }
.badge-advanced     { background: rgba(239,68,68,.15);  color: var(--red);  border: 1px solid rgba(239,68,68,.3); }

/* ===== TENSE TABLE ===== */
.tense-table {
  width: 100%;
  border-collapse: collapse;
}

.tense-table th {
  padding: .5rem .9rem;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-muted);
  background: var(--bg3);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.tense-table td {
  padding: .65rem .9rem;
  border-bottom: 1px solid rgba(45,51,84,.6);
  vertical-align: middle;
}

.tense-table tr:last-child td { border-bottom: none; }

.tense-label {
  font-size: .78rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 6px;
  white-space: nowrap;
}

.tense-past    { background: rgba(168,85,247,.15);  color: #c084fc; border: 1px solid rgba(168,85,247,.25); }
.tense-present { background: rgba(79,142,247,.15);  color: #60a5fa; border: 1px solid rgba(79,142,247,.25); }
.tense-future  { background: rgba(34,197,94,.15);   color: #4ade80; border: 1px solid rgba(34,197,94,.25); }

.form-word {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

.form-ipa {
  font-size: .82rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: .05rem;
}

.form-lv {
  font-size: .85rem;
  color: #a5b4fc;
}

.speak-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: .3rem .55rem;
  transition: all .15s;
  line-height: 1;
}

.speak-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: scale(1.1);
}

/* ===== NO RESULTS ===== */
.no-results {
  grid-column: 1/-1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.no-results .emoji { font-size: 3rem; display: block; margin-bottom: .75rem; }
.no-results p { font-size: 1.1rem; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: 2rem;
}

.page-btn {
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0 .6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
  background: var(--bg3);
}

.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px rgba(79,142,247,.35);
}

.page-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.page-dots {
  color: var(--text-muted);
  padding: 0 .2rem;
  font-size: .9rem;
  user-select: none;
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 1.25rem;
  color: var(--text-muted);
  font-size: .85rem;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .logo { font-size: 1.6rem; }
  .cards-grid { grid-template-columns: 1fr; }
  .controls { gap: .75rem; }
  .search-wrap { max-width: 100%; }
}
