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

:root {
  --bg:         #07071a;
  --bg2:        #0d0d24;
  --bg3:        #111130;
  --card:       rgba(255,255,255,0.04);
  --card-hover: rgba(255,255,255,0.07);
  --border:     rgba(255,255,255,0.08);
  --border-h:   rgba(255,255,255,0.18);
  --gold:       #c89b3c;
  --gold2:      #f0c060;
  --purple:     #9c5df5;
  --purple2:    #c084fc;
  --blue:       #60a5fa;
  --green:      #34d399;
  --red:        #f87171;
  --text:       #e8eaf6;
  --text2:      #94a3b8;
  --text3:      #4b5577;
  --radius:     16px;
  --radius-sm:  10px;
  --radius-xs:  6px;
  --shadow:     0 8px 32px rgba(0,0,0,0.6);
  --shadow-sm:  0 2px 12px rgba(0,0,0,0.4);
  --glow-gold:  0 0 40px rgba(200,155,60,0.25);
  --glow-purple:0 0 40px rgba(156,93,245,0.25);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse 90% 50% at 50% -5%, rgba(156,93,245,0.15), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(96,165,250,0.08), transparent),
    radial-gradient(ellipse 40% 30% at 10% 70%, rgba(200,155,60,0.06), transparent);
}

/* ─── SCROLLBAR ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border-h); border-radius: 99px; }

/* ─── HEADER ───────────────────────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(7,7,26,0.8);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; gap: 12px;
}
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; flex-shrink: 0; }
.logo-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--purple), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
  box-shadow: var(--glow-purple);
}
.logo-title {
  display: block; font-family: 'Rajdhani', sans-serif;
  font-size: 18px; font-weight: 700;
  background: linear-gradient(90deg, var(--gold2), var(--purple2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  white-space: nowrap;
}
.logo-sub { display: block; font-size: 10px; color: var(--text3); letter-spacing: 2px; text-transform: uppercase; }

.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.wpp-status {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 20px;
  background: var(--card); border: 1px solid var(--border);
  font-size: 12px; color: var(--text2);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text3); transition: all 0.3s; }
.status-dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse-green 2s infinite; }
.status-dot.offline { background: var(--red); }

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 4px var(--green); }
  50%       { box-shadow: 0 0 12px var(--green); }
}

.btn-refresh, .btn-add {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; border: none; font-family: inherit;
}
.btn-refresh {
  background: var(--card); border: 1px solid var(--border);
  color: var(--text2);
}
.btn-refresh:hover { border-color: var(--gold); color: var(--gold); background: rgba(200,155,60,0.06); }
.btn-refresh.spinning svg { animation: spin 0.8s linear infinite; }
.btn-add {
  background: linear-gradient(135deg, var(--purple), #6d28d9);
  color: #fff; font-weight: 700;
  box-shadow: 0 2px 12px rgba(156,93,245,0.3);
}
.btn-add:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(156,93,245,0.5); }

/* ─── MAIN ─────────────────────────────────────────────────────────────────── */
.main { max-width: 1200px; margin: 0 auto; padding: 28px 20px 60px; }

/* ─── SUMMARY ROW ───────────────────────────────────────────────────────────── */
.summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 24px;
}
.summary-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  display: flex; align-items: center; gap: 14px;
  transition: all 0.25s; cursor: default; position: relative; overflow: hidden;
}
.summary-card::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.04), transparent 60%);
  pointer-events: none;
}
.summary-card:hover { border-color: var(--border-h); transform: translateY(-2px); box-shadow: var(--shadow-sm); background: var(--card-hover); }
.summary-icon { font-size: 28px; flex-shrink: 0; line-height: 1; }
.summary-info { display: flex; flex-direction: column; gap: 2px; overflow: hidden; min-width: 0; }
.summary-label { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 1.2px; }
.summary-value { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-sub { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── CONTENT GRID ──────────────────────────────────────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px; align-items: start;
}

/* ─── PLAYER CARDS ───────────────────────────────────────────────────────────── */
.table-section {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  gap: 12px;
}
.section-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; color: var(--text);
}
.title-icon { font-size: 18px; }
.player-count {
  font-size: 11px; color: var(--text3);
  background: rgba(255,255,255,0.05); padding: 4px 10px;
  border-radius: 20px; border: 1px solid var(--border); white-space: nowrap;
}

/* Player list cards (replaces table) */
.player-list { display: flex; flex-direction: column; }
.player-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  transition: background 0.15s; position: relative;
}
.player-card:last-child { border-bottom: none; }
.player-card:hover { background: var(--card-hover); }

/* Position */
.pos-badge {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.pos-1 { background: linear-gradient(135deg, #c89b3c, #f0c060); color: #000; box-shadow: 0 0 14px rgba(200,155,60,0.4); }
.pos-2 { background: linear-gradient(135deg, #9ca3af, #d1d5db); color: #000; }
.pos-3 { background: linear-gradient(135deg, #b45309, #d97706); color: #000; }
.pos-n { background: rgba(255,255,255,0.07); color: var(--text3); }

/* Avatar */
.player-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #fff;
  overflow: hidden; border: 2px solid rgba(255,255,255,0.1);
  box-shadow: var(--shadow-sm);
}
.player-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Player info */
.player-info { flex: 1; min-width: 0; }
.player-name { font-weight: 700; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-tag  { font-size: 11px; color: var(--text3); margin-top: 1px; }

/* Elo badge */
.elo-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--radius-xs);
  font-size: 11px; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent;
}
.elo-CHALLENGER  { background: rgba(240,192,96,0.12); color: #f0c060; border-color: rgba(240,192,96,0.3); }
.elo-GRANDMASTER { background: rgba(255,68,51,0.12);  color: #ff7766; border-color: rgba(255,68,51,0.3); }
.elo-MASTER      { background: rgba(170,68,255,0.12); color: #cc88ff; border-color: rgba(170,68,255,0.3); }
.elo-DIAMOND     { background: rgba(68,136,255,0.12); color: #88bbff; border-color: rgba(68,136,255,0.3); }
.elo-EMERALD     { background: rgba(34,221,136,0.12); color: #55ffaa; border-color: rgba(34,221,136,0.3); }
.elo-PLATINUM    { background: rgba(0,204,221,0.12);  color: #55eeff; border-color: rgba(0,204,221,0.3); }
.elo-GOLD        { background: rgba(200,155,60,0.12); color: var(--gold2); border-color: rgba(200,155,60,0.3); }
.elo-SILVER      { background: rgba(148,163,184,0.12);color: #cbd5e1;  border-color: rgba(148,163,184,0.3); }
.elo-BRONZE      { background: rgba(180,83,9,0.12);   color: #d97706;  border-color: rgba(180,83,9,0.3); }
.elo-IRON        { background: rgba(107,114,128,0.12);color: #9ca3af;  border-color: rgba(107,114,128,0.3); }
.elo-UNRANKED    { background: rgba(255,255,255,0.04);color: var(--text3); border-color: var(--border); }

/* Stats column */
.player-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.lp-value { font-size: 13px; font-weight: 800; color: var(--text); }
.wl-row { display: flex; gap: 6px; align-items: center; font-size: 11px; }
.wl-win  { color: var(--green); font-weight: 700; }
.wl-loss { color: var(--red);   font-weight: 700; }
.wl-rate { color: var(--text3); }

/* Actions */
.btn-matches {
  padding: 6px 12px; border-radius: var(--radius-xs);
  background: transparent; border: 1px solid var(--border);
  color: var(--text2); font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
  white-space: nowrap; flex-shrink: 0;
}
.btn-matches:hover { border-color: var(--purple); color: var(--purple2); background: rgba(156,93,245,0.08); }

/* loading */
.loading-row { text-align: center; padding: 60px 20px !important; color: var(--text3); display: flex !important; align-items: center; justify-content: center; gap: 12px; }

/* ─── BAGRE SECTION ─────────────────────────────────────────────────────────── */
.bagre-section { position: sticky; top: 80px; }
.bagre-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  position: relative;
}
.bagre-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--purple));
}
.bagre-header {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.bagre-fish { font-size: 24px; animation: swim 3s ease-in-out infinite; }
.bagre-title { font-size: 15px; font-weight: 700; color: var(--text); font-family: 'Rajdhani', sans-serif; letter-spacing: 0.5px; }

.bagre-body {
  padding: 24px 20px; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; min-height: 200px;
}
.bagre-avatar {
  width: 140px; height: 140px; border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  display: flex; align-items: center; justify-content: center;
  font-size: 52px; font-weight: 700; color: #fff;
  border: 4px solid rgba(59,130,246,0.3);
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(59,130,246,0.25);
}
.bagre-avatar img { width: 100%; height: 100%; object-fit: cover; }
.bagre-name { font-size: 18px; font-weight: 800; color: var(--text); margin-top: 8px; }
.bagre-tag  { font-size: 12px; color: var(--text3); }
.bagre-rank { margin-top: 6px; }
.bagre-stats { display: flex; gap: 20px; margin-top: 12px; }
.bagre-stat { text-align: center; }
.bagre-stat-val { display: block; font-size: 20px; font-weight: 800; color: var(--text); }
.bagre-stat-lbl { display: block; font-size: 9px; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
.bagre-footer { padding: 12px 20px; border-top: 1px solid var(--border); text-align: center; color: var(--text3); font-size: 11px; }
.bagre-loading { display: flex; align-items: center; justify-content: center; height: 100px; }

/* ─── MODAL ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.2s ease; }
.modal {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 640px;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.8);
}
.modal-sm { max-width: 420px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,0.07); border: none; color: var(--text2);
  cursor: pointer; font-size: 14px; transition: all 0.2s;
}
.modal-close:hover { background: rgba(255,255,255,0.14); color: var(--text); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }

/* Match list */
.match-list { display: flex; flex-direction: column; gap: 10px; }
.match-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  transition: border-color 0.2s;
}
.match-item:hover { border-color: var(--border-h); }
.match-placement {
  width: 48px; height: 48px; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; flex-shrink: 0;
}
.place-1   { background: rgba(200,155,60,0.15);  color: var(--gold2);  border: 1px solid rgba(200,155,60,0.3); }
.place-2   { background: rgba(156,163,175,0.12); color: #d1d5db;       border: 1px solid rgba(156,163,175,0.3); }
.place-3   { background: rgba(180,83,9,0.12);    color: #d97706;       border: 1px solid rgba(180,83,9,0.3); }
.place-4   { background: rgba(59,130,246,0.12);  color: #60a5fa;       border: 1px solid rgba(59,130,246,0.3); }
.place-bad { background: rgba(239,68,68,0.12);   color: #f87171;       border: 1px solid rgba(239,68,68,0.3); }
.match-info { flex: 1; }
.match-date  { font-size: 12px; color: var(--text3); margin-bottom: 5px; }
.match-traits { display: flex; flex-wrap: wrap; gap: 4px; }
.trait-badge {
  padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 600;
  background: rgba(255,255,255,0.07); color: var(--text2);
}

/* Form */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 7px; font-weight: 500; }
.form-group input {
  width: 100%; padding: 11px 14px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 14px; font-family: inherit; transition: border-color 0.2s;
}
.form-group input:focus { outline: none; border-color: var(--purple); }
.form-hint  { font-size: 12px; color: var(--text3); margin-bottom: 16px; }
.form-error {
  font-size: 13px; color: var(--red); padding: 10px 14px;
  background: rgba(248,113,113,0.08); border-radius: var(--radius-sm);
  border: 1px solid rgba(248,113,113,0.2); margin-bottom: 12px;
}
.btn-submit {
  width: 100%; padding: 12px; border: none; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--purple), #6d28d9);
  color: #fff; font-weight: 700; font-size: 15px; cursor: pointer;
  transition: all 0.2s; font-family: inherit;
  box-shadow: 0 2px 14px rgba(156,93,245,0.3);
}
.btn-submit:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(156,93,245,0.5); }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ─── TOAST ─────────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  padding: 12px 18px; border-radius: var(--radius-sm);
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow); animation: slideIn 0.3s ease;
  max-width: 300px;
}
.toast.success { border-color: rgba(52,211,153,0.4); }
.toast.error   { border-color: rgba(248,113,113,0.4); }

/* ─── LOADING ─────────────────────────────────────────────────────────────── */
.loading-center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 48px 24px; color: var(--text3); }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--purple);
  animation: spin 0.8s linear infinite;
}
.spinner.small { width: 18px; height: 18px; }

/* ─── ANIMATIONS ────────────────────────────────────────────────────────────── */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes swim {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  30%  { transform: translateX(5px) rotate(8deg); }
  70%  { transform: translateX(-4px) rotate(-6deg); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

/* ─── RESPONSIVE ────────────────────────────────────────────────────────────── */
@media (max-width: 1050px) {
  .content-grid { grid-template-columns: 1fr; }
  .bagre-section { position: static; }
  .bagre-card { max-width: 500px; margin: 0 auto; }
}

@media (max-width: 768px) {
  .summary-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .logo-sub { display: none; }
  .wpp-status span.status-text { display: none; }
  .btn-add span { display: none; }
  .player-stats .wl-row { display: none; }
  .header-inner { height: 58px; }
  .main { padding: 16px 14px 50px; }
  .modal-body { padding: 16px; }
  .modal-header { padding: 16px 18px; }
}

@media (max-width: 480px) {
  .summary-row { grid-template-columns: 1fr 1fr; }
  .player-card { padding: 12px 14px; gap: 10px; }
  .player-avatar { width: 42px; height: 42px; font-size: 16px; }
  .pos-badge { width: 26px; height: 26px; font-size: 11px; }
  .btn-matches { padding: 5px 8px; font-size: 10px; }
  .elo-badge { font-size: 10px; padding: 3px 7px; }
  .bagre-avatar { width: 110px; height: 110px; }
}
