/* Sorare Gallery - Thème sombre gaming */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2332;
  --bg-hover: #243044;
  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --gold: #f59e0b;
  --green: #10b981;
  --red: #ef4444;
  --purple: #8b5cf6;
  --border: #1f2937;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Header */
header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#user-info { display: flex; align-items: center; gap: 1rem; }
#username { color: var(--text-secondary); font-size: 0.9rem; }

/* Boutons */
.btn {
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: white;
  width: 100%;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-small:hover { background: var(--bg-hover); }

/* Login */
#login-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
  padding: 1rem;
}

.login-card {
  background: var(--bg-card);
  padding: 3rem;
  border-radius: var(--radius);
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
}

.login-logo { font-size: 3rem; margin-bottom: 1rem; }

.login-card h2 {
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
}

.login-card p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

#login-form { display: flex; flex-direction: column; gap: 0.8rem; }

#login-form input,
#otp-code {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1rem;
}

#login-form input:focus,
#otp-code:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

#otp-code {
  text-align: center;
  letter-spacing: 0.3em;
  font-size: 1.2rem;
  margin-bottom: 0.8rem;
}

#twofa-section { margin-top: 1.5rem; }
#twofa-section p { margin-bottom: 1rem; font-size: 1rem; color: var(--gold); }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 2rem;
}

.stat-card {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid var(--border);
}

.stat-card.highlight {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
}

.stat-value { font-size: 2rem; font-weight: 700; margin-bottom: 0.3rem; }
.stat-card.highlight .stat-value { color: var(--gold); }
.stat-label { color: var(--text-secondary); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* Charts */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto 2rem;
  padding: 0 2rem;
}

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

.chart-card h3 { margin-bottom: 1rem; font-size: 1rem; color: var(--text-secondary); }

.chart-bar { display: flex; align-items: center; margin-bottom: 0.8rem; gap: 0.8rem; }
.chart-bar-label { min-width: 100px; font-size: 0.85rem; color: var(--text-secondary); }

.chart-bar-track {
  flex: 1;
  height: 24px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.chart-bar-value { min-width: 80px; text-align: right; font-size: 0.85rem; font-weight: 500; }

.rarity-limited { background: linear-gradient(90deg, #d4a843, #c9952e); }
.rarity-rare { background: linear-gradient(90deg, #e74c3c, #c0392b); }
.rarity-super_rare { background: linear-gradient(90deg, #3498db, #2980b9); }
.rarity-unique { background: linear-gradient(90deg, #8b5cf6, #7c3aed); }

/* Filtres */
.filters {
  display: flex;
  gap: 1rem;
  max-width: 1400px;
  margin: 0 auto 1.5rem;
  padding: 0 2rem;
  flex-wrap: wrap;
}

.filters select,
.filters input {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.9rem;
  min-width: 180px;
}

.filters select:focus,
.filters input:focus { outline: none; border-color: var(--accent); }

/* Cartes */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.2rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem 3rem;
}

.card-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.3s;
}

.card-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.card-image {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: contain;
  object-position: center;
  background: var(--bg-secondary);
  display: block;
  padding: 8px;
}

.card-info { padding: 1rem; }
.card-player { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-player a { color: inherit; text-decoration: none; }
.card-player a:hover { color: var(--accent-primary); text-decoration: underline; }
.card-club { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 0.5rem; }
.card-meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.3rem; }

.card-rarity {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.card-rarity.limited { background: rgba(212, 168, 67, 0.2); color: #d4a843; }
.card-rarity.rare { background: rgba(231, 76, 60, 0.2); color: #e74c3c; }
.card-rarity.super_rare { background: rgba(52, 152, 219, 0.2); color: #3498db; }
.card-rarity.unique { background: rgba(139, 92, 246, 0.2); color: #8b5cf6; }

.card-price { font-weight: 700; color: var(--green); font-size: 0.95rem; }
.card-prices-detail { padding: 0 0.75rem; }
.card-listed-price { font-size: 0.75rem; color: var(--text-muted); font-style: italic; }
.card-season { color: var(--text-muted); font-size: 0.75rem; margin-top: 0.3rem; }

.card-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-inseason {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.badge-classic {
  background: rgba(107, 114, 128, 0.2);
  color: #9ca3af;
}

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

/* États */
.hidden { display: none !important; }
.loading { text-align: center; padding: 3rem; color: var(--text-secondary); font-size: 1.1rem; }
.loading::before { content: '⏳ '; }
.error { text-align: center; padding: 1rem; color: var(--red); background: rgba(239, 68, 68, 0.1); border-radius: 8px; margin: 1rem 0; }

footer { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--border); }

/* Responsive */
@media (max-width: 768px) {
  header { padding: 0.8rem 1rem; }
  .login-card { padding: 2rem 1.5rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); padding: 0 1rem; }
  .charts-grid { grid-template-columns: 1fr; padding: 0 1rem; }
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); padding: 0 1rem 2rem; }
  .filters { padding: 0 1rem; }
  .filters select, .filters input { min-width: 140px; flex: 1; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.8rem; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
  .stat-value { font-size: 1.5rem; }
  .login-card { padding: 1.5rem 1rem; }
}

/* Sync status bar */
.sync-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.sync-indicator { font-size: 0.9rem; }
.sync-indicator.syncing { color: var(--accent-primary); }
.sync-indicator.done { color: #10b981; }
.sync-indicator.error { color: #ef4444; }
.btn-resync { background: var(--accent-primary) !important; color: #fff !important; border: none; cursor: pointer; white-space: nowrap; }
.btn-resync:hover { opacity: 0.85; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 0;
  flex-wrap: wrap;
}
.page-info {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-right: 1rem;
}
.page-buttons {
  display: flex;
  gap: 0.3rem;
}
.page-buttons .btn.active {
  background: var(--accent-primary);
  color: #fff;
}

/* Top Performers */
.top-performers {
  max-width: 1400px;
  margin: 0 auto 1.5rem;
  padding: 0 2rem;
}
.top-performers h3 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}
.top-performers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.top-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.top-list h4 { margin-bottom: 0.8rem; font-size: 0.95rem; }
.top-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.top-item:last-child { border-bottom: none; }
.top-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-item-name a { color: inherit; text-decoration: none; }
.top-item-name a:hover { color: var(--accent-primary); text-decoration: underline; }
.top-item-meta { color: var(--text-muted); font-size: 0.75rem; margin-left: 0.5rem; }
.top-item-change { font-weight: 700; margin-left: 1rem; white-space: nowrap; }
.top-item-change.positive { color: var(--green); }
.top-item-change.negative { color: var(--red); }

/* Position Summary */
.position-summary {
  max-width: 1400px;
  margin: 0 auto 1rem;
  padding: 0 2rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.position-badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.position-badge .pos-count {
  font-weight: 700;
  color: var(--accent);
  margin-left: 0.3rem;
}

/* Price History Modal */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none !important; }
.modal-backdrop {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
}
.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-close {
  position: absolute;
  top: 0.5rem; right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.8rem;
  cursor: pointer;
}
.modal-close:hover { color: var(--text-primary); }
.modal-content h3 { margin-bottom: 1rem; }

/* Card clickable */
.card-item { cursor: pointer; }

@media (max-width: 768px) {
  .top-performers-grid { grid-template-columns: 1fr; }
  .top-performers { padding: 0 1rem; }
  .position-summary { padding: 0 1rem; }
}

/* Collapsible sections */
.collapsible-section {
  margin: 1rem;
}

.collapsible-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.collapsible-toggle:hover {
  background: var(--bg-hover);
}

.collapsible-section.open .collapsible-toggle {
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom-color: transparent;
}

.collapsible-arrow {
  font-size: 1.1rem;
  transition: transform 0.2s;
}

.collapsible-body {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.collapsible-body .chart-card {
  border-radius: 0;
  margin: 0;
  border: none;
}

/* Deals section */
.deals-container { padding: 1rem 1.5rem; }
.deals-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.sortable-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}
.sortable-table th.sortable:hover {
  color: var(--accent);
}
.deals-config-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Portfolio chart */
.portfolio-chart-card {
  margin: 1rem;
  grid-column: 1 / -1;
}

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

.portfolio-chart-header h3 { margin: 0; }

.portfolio-chart-controls {
  display: flex;
  gap: 4px;
}

.portfolio-chart-controls .btn {
  padding: 4px 12px;
  font-size: 0.8rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.portfolio-chart-controls .btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Tab navigation */
.tab-nav {
  display: flex;
  gap: 0;
  margin: 1.5rem 1rem 0;
  border-bottom: 2px solid var(--border);
}

.tab-btn {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content.hidden { display: none; }

/* Optimisation section */
.optim-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1rem;
}

.optim-section h3 {
  margin: 0 0 1rem;
  color: var(--text-primary);
  font-size: 1.1rem;
}

.optim-subtitle {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.optim-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.optim-table th {
  text-align: left;
  padding: 0.6rem 0.8rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}

.optim-table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-primary);
}

.optim-table tr:hover { background: var(--bg-hover); }

.optim-table a {
  color: var(--accent);
  text-decoration: none;
}
.optim-table a:hover { text-decoration: underline; }

.optim-table small { color: var(--text-muted); }

.optim-table .positive { color: var(--green); font-weight: 600; }
.optim-table .negative { color: var(--red); font-weight: 600; }

.optim-empty, .optim-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  font-size: 0.9rem;
}

.optim-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.optim-stat {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.optim-stat.danger { border: 1px solid rgba(239, 68, 68, 0.3); }

.optim-stat-value {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.optim-stat.danger .optim-stat-value { color: var(--red); }

.optim-stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.optim-table-wrap { overflow-x: auto; }

@media (max-width: 768px) {
  .tab-btn { padding: 0.5rem 0.8rem; font-size: 0.85rem; }
  .optim-section { margin: 0.5rem; padding: 1rem; }
  .optim-table { font-size: 0.75rem; }
  .optim-table th, .optim-table td { padding: 0.4rem; }
}

/* Score badges (L5 / L10 / L40) */
.card-scores {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.score-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  white-space: nowrap;
}

.score-badge.score-high {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.score-badge.score-mid {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.score-badge.score-low {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.score-badge.score-na {
  opacity: 0.5;
}

/* Wallet Display in Header */
.wallet-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.wallet-display:hover {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.2));
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.wallet-display.refreshing {
  opacity: 0.6;
  pointer-events: none;
}

.wallet-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.wallet-icon {
  font-size: 0.9rem;
}

.wallet-value {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.wallet-eur .wallet-value {
  color: var(--green);
}

.wallet-eth .wallet-value {
  color: var(--purple);
}

.wallet-total .wallet-value {
  color: var(--gold);
  font-weight: 700;
}

.wallet-sep {
  color: var(--text-muted);
  font-size: 0.75rem;
  opacity: 0.4;
}

@media (max-width: 768px) {
  .wallet-display {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
    gap: 0.3rem;
  }
  .wallet-sep { display: none; }
  .wallet-display { flex-wrap: wrap; justify-content: center; }
}


/* Score pills for deals table */
.score-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: bold;
  font-size: 0.95em;
  min-width: 45px;
  text-align: center;
}
.score-pill.score-must-buy { background: #22c55e; color: #fff; }
.score-pill.score-interesting { background: #eab308; color: #000; }
.score-pill.score-correct { background: #94a3b8; color: #fff; }
.score-pill.score-weak { background: #ef4444; color: #fff; }
.score-pill.score-na { background: #334155; color: #94a3b8; }
.score-grade { color: #94a3b8; font-size: 0.75em; }
tr.score-must-buy { background: rgba(34, 197, 94, 0.05); }
tr.score-interesting { background: rgba(234, 179, 8, 0.05); }
tr.score-weak { background: rgba(239, 68, 68, 0.05); }
