/* ===========================================================
   pokecard — main.css
   Dark mode · Pikachu yellow accent · mobile-first
   =========================================================== */

/* ---------- Reset minimal ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input { font: inherit; color: inherit; }
code, .mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Tokens ---------- */
:root {
  /* base */
  --bg:           #0e0e10;
  --bg-elev-1:    #15151a;
  --bg-card:      #17171c;
  --bg-card-hov:  #1c1c22;
  --bg-input:     #1a1a20;
  --border:       #26262e;
  --border-soft:  #1f1f26;
  --text:         #ebebef;
  --text-soft:    #a4a4ad;
  --text-mute:    #6c6c75;

  /* accent : jaune Pikachu */
  --accent:        #f7d51d;
  --accent-strong: #ffe14d;
  --accent-dim:    rgba(247, 213, 29, 0.12);
  --accent-ring:   rgba(247, 213, 29, 0.35);

  --danger:    #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --success:   #22c55e;
  --success-bg:rgba(34, 197, 94, 0.12);
  --info:      #38bdf8;
  --warning:   #f59e0b;

  /* rarity chips */
  --r-sir:    #a855f7;   /* Special Illustration Rare */
  --r-ir:     #3b82f6;   /* Illustration Rare */
  --r-mhr:    #d4af37;   /* Mega Hyper Rare */
  --r-default:#52525b;

  --radius:    14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow:    0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);

  --max-w:    1200px;
}

/* ---------- Layout ---------- */
.main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 28px 20px 48px;
}
.main-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(14, 14, 16, 0.85);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 18px;
}
.brand:hover { text-decoration: none; color: var(--accent); }
.brand-emoji { font-size: 22px; line-height: 1; }
.brand-name { font-weight: 700; }

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
  flex: 1;
}
.nav-link {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-weight: 500;
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
}
.nav-link:hover { color: var(--text); background: var(--bg-elev-1); text-decoration: none; }
.nav-link.active { color: var(--accent); background: var(--accent-dim); }

.userbox {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  background: var(--bg-elev-1);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-soft);
}
.user-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px var(--success-bg);
}
.logout-form { display: inline; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  border: 1px solid transparent;
  transition: transform 0.05s, background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #1a1a1a;
}
.btn-primary:hover { background: var(--accent-strong); color: #1a1a1a; }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-soft);
}
.btn-ghost:hover { background: var(--bg-elev-1); color: var(--text); border-color: var(--border); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.25);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.18); }

.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-success { background: var(--success-bg); color: var(--success); border-color: rgba(34, 197, 94, 0.25); }

/* ---------- Flash messages ---------- */
.flash-stack {
  max-width: var(--max-w);
  margin: 12px auto 0;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flash {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 14px;
}
.flash-msg { flex: 1; }
.flash-close {
  font-size: 20px;
  line-height: 1;
  color: var(--text-mute);
  padding: 0 4px;
}
.flash-close:hover { color: var(--text); }
.flash-danger    { border-color: rgba(239,68,68,0.35);   background: var(--danger-bg); color: #fecaca; }
.flash-success   { border-color: rgba(34,197,94,0.35);   background: var(--success-bg); color: #bbf7d0; }
.flash-warning   { border-color: rgba(245,158,11,0.35);  background: rgba(245,158,11,0.10); color: #fde68a; }
.flash-info      { border-color: rgba(56,189,248,0.35);  background: rgba(56,189,248,0.10); color: #bae6fd; }

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 24px 20px;
  font-size: 12px;
  color: var(--text-mute);
  border-top: 1px solid var(--border-soft);
}
.footer-tag {
  display: inline-block;
  padding: 1px 7px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.footer-sep { margin: 0 8px; opacity: 0.5; }

/* ---------- Login ---------- */
.login-shell { width: 100%; display: flex; justify-content: center; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px 24px;
  box-shadow: var(--shadow);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-emoji { font-size: 44px; line-height: 1; }
.login-title {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.login-subtitle { color: var(--text-soft); font-size: 14px; margin-top: 4px; }

.login-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
}
.field input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.field input::placeholder { color: var(--text-mute); }
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.login-error {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.login-footnote {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--text-mute);
}

/* ---------- Pages ---------- */
.page-header { margin-bottom: 22px; }
.page-title-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-subtitle { color: var(--text-soft); font-size: 14px; margin-top: 4px; }
.page-subtitle code,
.page-header code {
  font-size: 12.5px;
  background: var(--bg-elev-1);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--accent);
  border: 1px solid var(--border-soft);
}
.counter {
  font-size: 13px;
  color: var(--text-soft);
  background: var(--bg-elev-1);
  border: 1px solid var(--border-soft);
  padding: 3px 10px;
  border-radius: 999px;
}

/* ---------- Search bar ---------- */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}
.search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 14px;
  font-size: 16px;
  opacity: 0.6;
  pointer-events: none;
}
.search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 38px 14px 40px;
  font-size: 15px;
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.search-input::placeholder { color: var(--text-mute); }
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.search-clear {
  position: absolute;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-elev-1);
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.search-clear:hover { color: var(--text); background: var(--border); }
.search-submit { padding: 14px 22px; }

/* ---------- Upload zone (screen Pokecardex) ---------- */
.upload-zone {
  margin: 12px 0 18px;
  padding: 22px 24px;
  border: 2px dashed var(--border);
  border-radius: 14px;
  background: var(--bg-elev-1);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.upload-zone:hover,
.upload-zone:focus-visible {
  border-color: var(--accent);
  background: var(--accent-dim);
  outline: none;
}
.upload-zone.is-dragover {
  border-color: var(--accent-strong);
  background: var(--accent-dim);
  transform: scale(1.01);
}
.upload-zone-content {
  display: flex;
  align-items: center;
  gap: 18px;
}
.upload-zone-icon {
  font-size: 38px;
  line-height: 1;
}
.upload-zone-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.upload-zone-text strong { color: var(--text); font-weight: 600; }
.upload-zone-hint { color: var(--text-soft); font-size: 13px; }
.match-status .muted { color: var(--text-soft); font-size: 12.5px; }
.match-status code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; }

/* ---------- Match status ---------- */
.match-status {
  min-height: 26px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-soft);
}
.match-status.is-error { color: #fecaca; }
.match-status .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(247,213,29,0.25);
}
.match-status .pill-warn { background: rgba(245,158,11,0.12); color: #fde68a; border-color: rgba(245,158,11,0.3); }

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards grid ---------- */
.match-results-grid,
.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.card:hover {
  transform: translateY(-2px);
  border-color: #33333d;
  background: var(--bg-card-hov);
  box-shadow: var(--shadow-sm);
}

.card-image-wrap {
  position: relative;
  display: block;
  background: #0a0a0c;
  aspect-ratio: 5 / 7;
  overflow: hidden;
}
.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s;
}
.card:hover .card-image { transform: scale(1.02); }
.card-image-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  color: var(--text-mute);
  background: linear-gradient(135deg, #15151a, #0a0a0c);
}
.card-image-wrap.has-image .card-image-fallback { display: none; }
.card-image-wrap.error .card-image { display: none; }

.card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.card-head { display: flex; flex-direction: column; gap: 8px; }
.card-title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px;
  background: var(--bg-elev-1);
  border: 1px solid var(--border-soft);
  color: var(--text-soft);
}
.chip-code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(247,213,29,0.25);
}
.chip-rarity { color: #fff; }
.chip-rarity[data-rarity-tier="sir"]     { background: rgba(168,85,247,0.18); border-color: rgba(168,85,247,0.4); color: #e9d5ff; }
.chip-rarity[data-rarity-tier="ir"]      { background: rgba(59,130,246,0.18); border-color: rgba(59,130,246,0.4); color: #bfdbfe; }
.chip-rarity[data-rarity-tier="mhr"]     { background: rgba(212,175,55,0.18); border-color: rgba(212,175,55,0.45); color: #fde68a; }
.chip-rarity[data-rarity-tier="default"] { background: rgba(82,82,91,0.25);   border-color: rgba(82,82,91,0.5);  color: #d4d4d8; }

/* ---------- Card prices ---------- */
.card-prices {
  margin: 4px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.price-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-soft);
}
.price-row dt { color: var(--text-mute); font-weight: 500; }
.price-row dd { margin: 0; font-weight: 600; color: var(--text); }
.price-row-main dt { color: var(--text-soft); }
.price-row-main dd.price-main {
  font-size: 18px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.price-row-offers dd {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.offers-count { color: var(--text); }
.offers-min { color: var(--text-mute); font-size: 11.5px; font-weight: 500; }

/* ---------- Card actions ---------- */
.card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}
.card-actions .btn { flex: 1; }

/* ---------- Watchlist card ---------- */
.card-watch .card-image-wrap { background: linear-gradient(135deg, #15151a, #0a0a0c); }
.card-note {
  font-size: 12.5px;
  color: var(--text-soft);
  background: var(--bg-elev-1);
  border-left: 3px solid var(--accent);
  padding: 6px 10px;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}
.card-meta { font-size: 11.5px; color: var(--text-mute); }

/* ---------- Empty states ---------- */
.match-empty {
  text-align: center;
  padding: 60px 20px 20px;
  color: var(--text-mute);
}
.match-empty[hidden] { display: none; }
.match-empty-icon { font-size: 56px; opacity: 0.4; margin-bottom: 10px; }
.match-empty p { font-size: 14px; }
.match-empty-hint { margin-top: 4px; font-size: 12.5px; color: var(--text-mute); }
.match-empty-hint code {
  background: var(--bg-elev-1);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--accent);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-state-icon { font-size: 56px; opacity: 0.5; }
.empty-state-title {
  margin-top: 12px;
  font-size: 18px;
  font-weight: 600;
}
.empty-state-text {
  margin-top: 8px;
  margin-bottom: 18px;
  color: var(--text-soft);
}

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  min-width: 220px;
  max-width: 340px;
  animation: toast-in 0.18s ease-out;
}
.toast-success { border-left-color: var(--success); color: #bbf7d0; }
.toast-error   { border-left-color: var(--danger);  color: #fecaca; }
.toast-info    { border-left-color: var(--info);    color: #bae6fd; }
@keyframes toast-in {
  from { transform: translateY(6px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .nav { order: 3; flex-basis: 100%; margin-left: 0; }
  .userbox { margin-left: auto; }
  .main { padding: 20px 14px 36px; }
  .search-bar { flex-direction: column; }
  .search-submit { width: 100%; }
  .page-title { font-size: 22px; }
}
@media (max-width: 480px) {
  .match-results-grid,
  .watchlist-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .card-body { padding: 10px; }
  .card-title { font-size: 13px; }
  .price-row-main dd.price-main { font-size: 15px; }
  .login-card { padding: 24px 20px; }
}
