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

:root {
  --bg: #1a1c20;
  --surface: #23262d;
  --surface2: #2c2f38;
  --border: #383c47;
  --accent: #e8c84a;
  --text: #d4d6dc;
  --text-dim: #8a8f9e;
  --text-bright: #f0f2f5;
  --type-normal: #9fa19f; --type-fire: #e6533e; --type-water: #559edf;
  --type-grass: #62b957; --type-electric: #f0d050; --type-ice: #78c4da;
  --type-fighting: #ce4069; --type-poison: #a43ec4; --type-ground: #d78855;
  --type-flying: #8fa8dd; --type-psychic: #f85888; --type-bug: #8fd752;
  --type-rock: #b6aa6d; --type-ghost: #705898; --type-dragon: #3461d1;
  --type-dark: #5c5061; --type-steel: #60a1b8; --type-fairy: #ef70ef;
  --radius: 6px;
}

body {
  font-family: 'Roboto Condensed', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Top Nav ─── */
.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  height: 48px;
}
.topnav-inner {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 0 80px;
  display: flex;
  align-items: center;
  gap: 0;
  height: 100%;
}
.topnav .logo {
  font-family: 'Pragati Narrow', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--accent);
  letter-spacing: 1px;
  margin-right: 16px;
  white-space: nowrap;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 14px;
  height: 48px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Nav divider */
.nav-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 12px;
  flex-shrink: 0;
}

/* Search in nav */
.nav-search {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 0.88rem;
  padding: 5px 10px;
  width: 180px;
  outline: none;
  transition: border-color 0.15s;
}
.nav-search:focus { border-color: var(--accent); }
.nav-search::placeholder { color: var(--text-dim); }

/* Origin buttons in nav */
.origin-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 11px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  height: 28px;
  display: flex;
  align-items: center;
}
.origin-btn.all   { color: var(--text-dim); margin-left: 8px; }
.origin-btn.all.active { background: var(--surface2); color: var(--text-bright); border-color: #555; }
.origin-btn.stunderian { color: #c47fd4; border-color: #5a3068; margin-left: 4px; }
.origin-btn.stunderian.active { background: #c47fd4; color: #111; border-color: #c47fd4; }
.origin-btn.vanguard { color: #e88040; border-color: #7a4010; margin-left: 4px; }
.origin-btn.vanguard.active { background: #e88040; color: #111; border-color: #e88040; }
.origin-btn.delta { color: #62b957; border-color: #2a6020; margin-left: 4px; }
.origin-btn.delta.active { background: #62b957; color: #111; border-color: #62b957; }
.origin-btn.kazeran { color: #e6533e; border-color: #ce4069; margin-left: 4px; }
.origin-btn.kazeran.active { background: #e6533e; color: #111; border-color: #ce4069; }
.origin-btn.twilight { color: #3dc3d5; border-color: #2f8c98; margin-left: 4px; }
.origin-btn.twilight.active { background: #2fa6b6; color: #111; border-color: #2f8c98; }
.origin-btn.lostlore { color: #e840c4; border-color: #7a1078; margin-left: 4px; }
.origin-btn.lostlore.active { background: #e840c4; color: #111; border-color: #7a1078; }
.origin-btn:hover { opacity: 0.85; }

/* Hide origin controls when not on species tab */
.origin-controls { display: flex; align-items: center; }
.origin-controls.hidden { display: none !important; }

/* ─── Main Layout ─── */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 48px);
  margin-top: 48px;
}
/* ─── Content Area ─── */
.content-area {
  flex: 1;
  overflow-y: auto;
  position: relative;
  margin-right: 0;
  transition: margin-right 0.25s ease;
}
.content-area.panel-open {
  margin-right: 320px;
}
.content-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 80px;
}

/* ─── Type chip ─── */
.type-chip {
  display: inline-block;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ─── Species Table ─── */
.species-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.species-table thead {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
}
.species-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  border-bottom: 2px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.species-table th:hover { color: var(--text); }
.species-table th.sorted { color: var(--accent); }
.sort-arrow { margin-left: 4px; opacity: 0.5; }
.sort-arrow.active { opacity: 1; }

.species-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.species-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}
.species-table tbody tr:hover { background: var(--surface2); }
.species-table tbody tr.selected { background: #2d3040; }

.id-cell { color: var(--text-dim); font-size: 0.8rem; }
.name-cell { color: var(--text-bright); font-weight: 700; }
.origin-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.origin-tag.stunderian { background: #3a1a50; color: #c47fd4; }
.origin-tag.Meri       { background: #3a1a50; color: #c47fd4; }
.origin-tag.vanguard   { background: #4a2808; color: #e88040; }
.origin-tag.delta      { background: #1a3a18; color: #62b957; }
.origin-tag.kazeran    { background: #3b131e; color: #ce4069; }
.origin-tag.twilight   { background: #132a3b; color: #2f8c98; }
.origin-tag.lostlore   { background: #3b1336; color: #e840c4; }



/* ─── Stat bar ─── */
.stat-row { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; }
.stat-label { width: 28px; text-align: right; color: var(--text-dim); font-size: 0.72rem; }
.stat-val { width: 26px; text-align: right; }
.stat-bar-bg { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.stat-bar { height: 100%; border-radius: 3px; transition: width 0.4s; }

/* ─── Detail Panel (side drawer) ─── */
.detail-panel {
  position: fixed;
  top: 48px;
  right: 0;
  width: 0;
  min-width: 0;
  height: calc(100vh - 48px);
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
  transition: width 0.25s ease, min-width 0.25s ease;
  display: flex;
  flex-direction: column;
  z-index: 10;
}
.detail-panel.open {
  width: 320px;
  min-width: 320px;
}
.detail-inner {
  width: 320px;
  padding: 16px;
  overflow-y: auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-sprite {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 12px 0 4px;
  height: 350px;
}
.detail-sprite img {
  max-width: 250px;
  max-height: 325px;
  image-rendering: smooth;
  object-fit: contain;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.detail-name {
  font-family: 'Pragati Narrow', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1.1;
}
.detail-id { font-size: 0.85rem; color: var(--text-dim); margin-top: 2px; }
.close-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  width: 28px; height: 28px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.close-btn:hover { background: var(--border); color: var(--text); }

.detail-types { display: flex; gap: 5px; flex-wrap: wrap; }

.detail-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 6px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.detail-row .key { color: var(--text-dim); }
.detail-row .val { color: var(--text-bright); font-weight: 700; text-align: right; max-width: 60%; }

.ability-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 9px;
  font-size: 0.8rem;
  margin: 2px 2px 2px 0;
}
.ability-pill .ha-badge {
  font-size: 0.65rem;
  background: #3a3a20;
  color: var(--accent);
  border-radius: 3px;
  padding: 1px 4px;
  font-weight: 700;
}

.learnset-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.learnset-table th {
  text-align: left; padding: 3px 6px;
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.learnset-table td { padding: 4px 6px; border-bottom: 1px solid #2a2d35; }
.learnset-table tr:hover td { background: var(--surface2); }

/* ─── Empty state ─── */
.no-results {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
}
.no-results .big { font-size: 2.5rem; margin-bottom: 8px; }
.hidden { display: none !important; }

/* ─── Other tabs placeholder ─── */
.placeholder-view {
  padding: 40px;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.7;
}
.placeholder-view h2 {
  color: var(--text-bright);
  font-family: 'Pragati Narrow', sans-serif;
  font-size: 1.4rem;
  margin-bottom: 10px;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }
