/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  --bg-deep: #0a0c1a;
  --bg-card: #12152b;
  --bg-card-hover: #1a1e3a;
  --bg-surface: #181c35;
  --border: #252a4a;
  --text: #e8eaf6;
  --text-muted: #8891b0;
  --poke-yellow: #ffcc00;
  --poke-red: #ff3860;
  --electric-blue: #00d4ff;
  --psychic-purple: #b388ff;
  --green: #00e676;
  --font-display: 'Bungee', cursive;
  --font-body: 'Sora', sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);
  --transition: 0.2s ease;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(255, 56, 96, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(0, 212, 255, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(179, 136, 255, 0.06) 0%, transparent 50%);
  background-attachment: fixed;
}

a { color: var(--electric-blue); text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; }

.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ============================================================
   FOIL / SHIMMER ANIMATION
   ============================================================ */
@keyframes foilShimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.foil-border {
  height: 4px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, var(--poke-yellow), var(--poke-red), var(--electric-blue), var(--psychic-purple), var(--poke-yellow));
  background-size: 300% 100%;
  animation: foilShimmer 4s ease infinite;
}

.foil-text {
  background: linear-gradient(90deg, var(--poke-yellow), var(--poke-red), var(--electric-blue), var(--psychic-purple), var(--poke-yellow));
  background-size: 300% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: foilShimmer 4s ease infinite;
}

/* ============================================================
   LOGO
   ============================================================ */
.logo-text, .header-logo {
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: 2px;
  line-height: 1;
  user-select: none;
}
.header-logo { font-size: 1.25rem; white-space: nowrap; }
.logo-poke { color: #fff; }

/* ============================================================
   AVATARS
   ============================================================ */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: #fff;
  flex-shrink: 0;
}
.avatar-lg { width: 64px; height: 64px; font-size: 1.5rem; }
.avatar-jarrod { background: linear-gradient(135deg, var(--poke-yellow), #ff9800); }
.avatar-thatcher { background: linear-gradient(135deg, var(--electric-blue), var(--psychic-purple)); }

.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: #fff;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 2px solid transparent;
}
.avatar-btn:hover { transform: scale(1.1); }
.avatar-btn.active { border-color: var(--poke-yellow); box-shadow: 0 0 12px rgba(255, 204, 0, 0.4); }

/* ============================================================
   PROFILE PICKER
   ============================================================ */
.picker-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse at 30% 30%, rgba(255, 56, 96, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 60%, rgba(0, 212, 255, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 90%, rgba(179, 136, 255, 0.1) 0%, transparent 50%);
  z-index: 1000;
}

.picker-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 440px;
  overflow: hidden;
}

.picker-content {
  padding: 2.5rem 2rem;
  text-align: center;
}

.picker-subtitle {
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-size: 1rem;
}

.picker-profiles {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin-top: 2rem;
}

.profile-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 2rem;
  border-radius: var(--radius);
  background: var(--bg-surface);
  border: 2px solid var(--border);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.profile-btn:hover {
  border-color: var(--poke-yellow);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(255, 204, 0, 0.15);
}
.profile-name { font-family: var(--font-display); font-size: 1rem; }

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: rgba(18, 21, 43, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { flex-shrink: 0; }

.header-nav {
  display: flex;
  gap: 0.25rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-btn {
  font-family: var(--font-display);
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
  letter-spacing: 0.5px;
}
.nav-btn:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.nav-btn.active { color: var(--poke-yellow); background: rgba(255, 204, 0, 0.1); }

/* Mobile Nav */
.mobile-nav {
  display: none;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  font-family: var(--font-display);
  background: var(--poke-yellow);
  color: #0a0c1a;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(255, 204, 0, 0.3); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-ghost {
  font-family: var(--font-display);
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  letter-spacing: 0.5px;
}
.btn-ghost:hover { border-color: var(--text-muted); color: var(--text); background: rgba(255,255,255,0.03); }

.btn-danger {
  font-family: var(--font-display);
  background: var(--poke-red);
  color: #fff;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  transition: opacity var(--transition);
}
.btn-danger:hover { opacity: 0.85; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.75rem; }

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.tab-section { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tab-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 1px;
}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text);
  transition: border-color var(--transition);
  outline: none;
}
.search-input:focus { border-color: var(--electric-blue); }
.search-input::placeholder { color: var(--text-muted); }

/* ============================================================
   PHOTO PREVIEW
   ============================================================ */
.photo-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
}
.photo-preview img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.photo-note { font-size: 0.8rem; color: var(--text-muted); flex: 1; }

/* ============================================================
   LOADING / EMPTY STATES
   ============================================================ */
.loading, .empty-state, .welcome-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.loading { display: flex; align-items: center; justify-content: center; gap: 0.75rem; }

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

.welcome-state { padding: 4rem 1rem; }
.welcome-title { font-family: var(--font-display); font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--text); }
.welcome-sub { font-size: 0.9rem; }

/* ============================================================
   CARD GRID & TILES
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.card-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
}
.card-tile:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: rgba(255, 255, 255, 0.1);
}
.card-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.card-tile:hover::after { opacity: 1; }

.tile-image-wrap {
  aspect-ratio: 5/7;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.tile-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.5rem;
}

.tile-info {
  padding: 0.75rem;
}

.tile-name {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.3px;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-set {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
}

.tile-price {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--green);
}

.tile-grade {
  font-family: var(--font-display);
  font-size: 0.6rem;
  color: var(--electric-blue);
  background: rgba(0, 212, 255, 0.1);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

/* ============================================================
   RARITY BADGES
   ============================================================ */
.rarity-badge {
  font-family: var(--font-display);
  font-size: 0.6rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.rarity-common { background: rgba(107, 114, 128, 0.2); color: #9ca3af; border: 1px solid rgba(107, 114, 128, 0.3); }
.rarity-rare { background: rgba(0, 212, 255, 0.1); color: var(--electric-blue); border: 1px solid rgba(0, 212, 255, 0.3); }
.rarity-holo { background: rgba(179, 136, 255, 0.1); color: var(--psychic-purple); border: 1px solid rgba(179, 136, 255, 0.3); }
.rarity-ultra { background: rgba(255, 204, 0, 0.1); color: var(--poke-yellow); border: 1px solid rgba(255, 204, 0, 0.3); }

/* ============================================================
   STATS ROW
   ============================================================ */
.stats-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 140px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text);
}

.stat-delta {
  font-size: 0.8rem;
  font-weight: 600;
}
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--poke-red); }

/* ============================================================
   ALERT BADGES (Wishlist)
   ============================================================ */
.alert-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-family: var(--font-display);
  font-size: 0.55rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  z-index: 2;
  letter-spacing: 0.3px;
}
.alert-buy { background: var(--green); color: #0a0c1a; }
.alert-sell { background: var(--poke-yellow); color: #0a0c1a; }

/* ============================================================
   COMPARE
   ============================================================ */
.compare-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.compare-col {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.compare-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.compare-header h3 { font-family: var(--font-display); font-size: 1.1rem; }

.compare-vs {
  display: flex;
  align-items: center;
  padding-top: 3rem;
  flex-shrink: 0;
}

.vs-text {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--poke-red);
  text-shadow: 0 0 20px rgba(255, 56, 96, 0.4);
}

.compare-stats { display: flex; flex-direction: column; gap: 0.75rem; }

.compare-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.compare-label { font-size: 0.8rem; color: var(--text-muted); }
.compare-value { font-family: var(--font-display); font-size: 0.9rem; }

.compare-topcard {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
}
.compare-topcard img {
  width: 120px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-container {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-sm { max-width: 400px; }

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 1.5rem;
  color: var(--text-muted);
  z-index: 10;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: rgba(255,255,255,0.1); color: var(--text); }

.modal-body { padding: 2rem; }

/* Card Detail */
.card-detail {
  display: flex;
  gap: 2rem;
}

.detail-image-col {
  flex-shrink: 0;
  width: 260px;
}

.detail-image {
  width: 100%;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.detail-info-col {
  flex: 1;
  min-width: 0;
}

.detail-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.detail-set { font-size: 0.85rem; color: var(--electric-blue); }
.detail-number { font-size: 0.85rem; color: var(--text-muted); }

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.85rem;
}

.detail-label {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.detail-price-section {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.price-main, .price-trend, .price-projection {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.detail-price {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--green);
}

.detail-trend { font-family: var(--font-display); font-size: 0.9rem; }
.detail-trend.up { color: var(--green); }
.detail-trend.down { color: var(--poke-red); }
.detail-trend.neutral { color: var(--text-muted); }

.detail-projection { font-family: var(--font-display); font-size: 0.9rem; color: var(--electric-blue); }

.detail-grade {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.grade-select {
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text);
  outline: none;
}
.grade-select option { background: var(--bg-card); }

.detail-actions {
  margin-top: 1.25rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Wishlist Modal */
.wl-modal-image {
  width: 100px;
  margin: 0 auto 1rem;
  border-radius: 8px;
}

.wl-field {
  margin-bottom: 1rem;
}
.wl-field label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.input-prefix {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.input-prefix span {
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  background: rgba(255,255,255,0.03);
  border-right: 1px solid var(--border);
}
.input-prefix input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: none;
  font-size: 0.9rem;
  outline: none;
}
.input-prefix input::placeholder { color: rgba(255,255,255,0.2); }

.wl-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 720px) {
  .header-nav { display: none; }
  .mobile-nav { display: flex; }
  .header-logo { font-size: 1rem; }

  .card-detail { flex-direction: column; }
  .detail-image-col { width: 100%; max-width: 280px; margin: 0 auto; }

  .compare-layout { flex-direction: column; }
  .compare-vs { padding-top: 0; justify-content: center; }

  .card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (max-width: 640px) {
  .app-main { padding: 1rem 0.75rem; }
  .search-bar { flex-direction: column; }
  .search-input { min-width: 0; }
  .stats-row { flex-direction: column; }
  .stat-card { min-width: 0; }
  .picker-content { padding: 1.5rem 1rem; }
  .logo-text { font-size: 1.5rem; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.75rem; }
  .modal-body { padding: 1.25rem; }
  .detail-actions { flex-direction: column; }
  .detail-actions button { width: 100%; }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
