@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Paytone+One&display=swap');

:root {
  --bg: #F0F2F5;
  --panel: #ffffff;
  --panel2: #f8f9fb;
  --primary: #379DE0;
  --primary-dark: #2b84bf;
  --primary-light: rgba(55,157,224,0.10);
  --accent: #D0E332;
  --action: #F5782B;
  --text: #1A1A1A;
  --muted: #7a8499;
  --border: rgba(0,0,0,0.07);
  --radius: 10px;
  --sidebar-w: 248px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
}

/* Anti-flicker instant render rules (Zero White Screen / Instant Sidebar) */
html.is-authenticated #sidebar { display: flex !important; }
html.is-authenticated #dashboard-section { display: block !important; }
html.is-authenticated #login-section { display: none !important; }

html:not(.is-authenticated) #sidebar { display: none !important; }
html:not(.is-authenticated) #dashboard-section { display: none !important; }
html:not(.is-authenticated) #login-section { display: block !important; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  min-height: 100vh;
  line-height: 1.6;
  display: flex;
}

h1, h2, h3, h4 { font-family: 'Paytone One', sans-serif; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(55,157,224,0.3); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ===== BUTTONS ===== */
.btn {
  background: var(--primary); color: #fff;
  border: none; border-radius: 8px;
  font-family: 'Paytone One', sans-serif;
  padding: 9px 18px; font-size: 13px;
  transition: all 0.18s;
  box-shadow: 0 2px 8px rgba(55,157,224,0.25);
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(55,157,224,0.35); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-ghost { background: transparent; color: var(--primary); box-shadow: none; border: 1.5px solid var(--primary); }
.btn-ghost:hover { background: var(--primary-light); box-shadow: none; transform: none; }
.btn-danger { background: #ef4444; box-shadow: 0 2px 8px rgba(239,68,68,0.25); }
.btn-danger:hover { background: #dc2626; box-shadow: 0 4px 12px rgba(239,68,68,0.35); }
.btn-success { background: #10b981; color: #fff; box-shadow: 0 2px 8px rgba(16,185,129,0.25); }
.btn-success:hover { background: #059669; box-shadow: 0 4px 12px rgba(16,185,129,0.35); }

/* ===== INPUTS ===== */
input, select, textarea {
  font-family: 'Nunito', sans-serif;
  background: var(--panel2); border: 1.5px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 9px 12px;
  font-size: 14px; font-weight: 700; width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(55,157,224,0.12);
  background: #fff;
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 800; font-size: 12px; margin-bottom: 6px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

/* ===== TOAST ===== */
#admin-toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--text); color: #fff;
  font-weight: 800; font-size: 14px; padding: 12px 24px;
  border-radius: 10px; z-index: 9999;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex; align-items: center; gap: 10px;
}
#admin-toast.show { transform: translateX(-50%) translateY(0); }
#admin-toast.success { background: #16a34a; }
#admin-toast.error { background: #dc2626; }

/* ===== TOPBAR (LOGIN PAGE) ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--panel);
  border-bottom: 1px solid rgba(26,26,26,0.12);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.topbar-in {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px;
}
.logo {
  display: flex; align-items: center; gap: 12px;
  font-size: 20px; color: var(--text);
  text-transform: uppercase;
  position: relative;
  text-decoration: none;
}
.logo img {
  height: 48px; width: auto; 
  display: block;
}
@keyframes spinBall {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(90deg) scale(1.1); }
  50% { transform: rotate(180deg) scale(1); }
  75% { transform: rotate(270deg) scale(1.15); }
  100% { transform: rotate(360deg) scale(1); }
}
.spinning-ball {
  position: absolute;
  top: 3px; 
  left: 100px;
  width: 42px;
  height: 42px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><circle cx='50' cy='50' r='46' fill='%23D2DB38' stroke='%231A1A1A' stroke-width='8'/><circle cx='40' cy='20' r='8' fill='%231A1A1A' transform='matrix(0.989173,0,0,1.025403,3.85711,2.791844)'/><circle cx='78' cy='36' r='8' fill='%231A1A1A'/><ellipse cx='13.387' cy='51.016' rx='4.4' ry='9.058' fill='%231A1A1A'/><circle cx='47.737' cy='52.154' r='10' fill='%231A1A1A'/><ellipse cx='76' cy='75' rx='10.803' ry='4.222' transform='matrix(0.707107,-0.707107,0.707107,0.707107,-30.631449,71.862922)' fill='%231A1A1A'/><ellipse cx='31' cy='80' rx='11.929' ry='4.696' transform='matrix(0.866025,0.5,-0.5,0.866025,48.72184,-4.065615)' fill='%231A1A1A'/></svg>");
  background-size: cover;
  border-radius: 50%;
  animation: spinBall 3s linear infinite;
  pointer-events: none;
}
.topnav { display: flex; gap: 8px; margin-left: auto; }
.topnav a {
  padding: 7px 14px; 
  border: 1.5px solid transparent;
  border-radius: 8px;
  font-size: 15px; font-weight: 800; color: var(--text);
  text-decoration: none;
  transition: all .2s;
}
.topnav a.active, .topnav a:hover { 
  background: var(--accent); 
  border-color: rgba(26,26,26,0.2);
}
.topnav a.active {
  background: var(--primary); color: #fff;
  border-color: transparent;
}

/* ===== HAMBURGER MENU BUTTON ===== */
.menu-toggle {
  display: none;
  background: #F1F5F9;
  border: 1.5px solid #E2E8F0;
  border-radius: 10px;
  cursor: pointer;
  padding: 8px 10px;
  margin-left: auto;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  z-index: 60;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.menu-toggle:hover {
  background: #E2E8F0;
  border-color: #CBD5E1;
}
.menu-toggle span {
  display: block;
  width: 20px;
  height: 2.2px;
  background: #1E293B;
  border-radius: 2px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease,
              background 0.2s ease;
}
.menu-toggle.active {
  background: var(--primary);
  border-color: var(--primary);
}
.menu-toggle.active span {
  background: #FFFFFF;
}
.menu-toggle.active span:nth-child(1) {
  transform: translateY(7.2px) rotate(45deg);
}
.menu-toggle.active span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.menu-toggle.active span:nth-child(3) {
  transform: translateY(-7.2px) rotate(-45deg);
}

/* ===== LOGIN ===== */
.login-wrap {
  width: 100%; min-height: 100vh;
  display: flex; flex-direction: column;
  background: radial-gradient(circle at 30% 50%, rgba(55,157,224,0.08) 0%, transparent 60%),
              radial-gradient(circle at 70% 50%, rgba(245,120,43,0.06) 0%, transparent 60%);
}
.login-body {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px;
}
.login-box {
  background: var(--panel); padding: 48px 40px; border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.1);
  width: 100%; max-width: 400px;
  border: 1px solid var(--border);
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; justify-content: center; }
.login-logo img { height: 40px; }
.login-logo span { font-family: 'Paytone One', sans-serif; font-size: 20px; }
.login-logo small { display: block; font-family: 'Nunito', sans-serif; font-size: 11px; color: var(--action); font-weight: 900; letter-spacing: 2px; text-transform: uppercase; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--text); /* Dark sidebar */
  height: 100vh; position: sticky; top: 0;
  display: flex; flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 24px 16px 20px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-brand img { height: 36px; }
.sidebar-brand-text span { font-size: 10px; color: var(--action); font-weight: 900; letter-spacing: 1.5px; text-transform: uppercase; }

.sidebar-section-label {
  padding: 20px 24px 8px;
  font-size: 11px; font-weight: 900;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase; letter-spacing: 1.2px;
}

.sidebar-nav { flex: 1; padding: 8px 12px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  border-radius: 8px;
  font-weight: 800; font-size: 14px;
  color: rgba(255,255,255,0.5);
  transition: all 0.18s; cursor: pointer;
  margin-bottom: 2px;
}
.sidebar-nav a .nav-icon { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }
.sidebar-nav a:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.85); }
.sidebar-nav a.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(55,157,224,0.35);
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.sidebar-footer a.home-link {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 8px;
  font-weight: 800; font-size: 13px;
  color: rgba(255,255,255,0.4);
  transition: all 0.18s;
  margin-bottom: 8px;
}
.sidebar-footer a.home-link:hover { color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.06); }
.btn-logout {
  width: 100%; background: rgba(239,68,68,0.12); color: #f87171;
  border: 1.5px solid rgba(239,68,68,0.25); border-radius: 8px;
  padding: 10px; font-family: 'Paytone One', sans-serif; font-size: 13px;
  transition: all 0.18s; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-logout:hover { background: rgba(239,68,68,0.22); border-color: rgba(239,68,68,0.5); color: #fca5a5; }

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1; padding: 32px 36px;
  min-width: 0; overflow-y: auto; height: 100vh;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 28px;
}
.page-title { font-size: 26px; color: var(--text); }
.page-sub { font-size: 14px; color: var(--muted); font-weight: 700; margin-top: 2px; }

/* ===== STAT CARDS ===== */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--panel); border-radius: var(--radius);
  padding: 20px 24px; border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue { background: rgba(55,157,224,0.12); }
.stat-icon.orange { background: rgba(245,120,43,0.12); }
.stat-icon.green { background: rgba(22,163,74,0.12); }
.stat-value { font-family: 'Paytone One', sans-serif; font-size: 26px; line-height: 1; margin-bottom: 2px; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 700; }

/* ===== CARDS & TABLES ===== */
.card {
  background: var(--panel); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  margin-bottom: 20px; overflow: hidden;
}
.card-head {
  padding: 18px 24px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 16px; }
.card-body { padding: 20px 24px; }

/* Tournament cards grid */
.tournament-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; padding: 20px 24px; }
.tournament-item {
  border: 1.5px solid var(--border); border-radius: 10px;
  padding: 18px; cursor: pointer;
  transition: all 0.2s; background: var(--panel2);
  position: relative;
}
.tournament-item:hover { border-color: var(--primary); box-shadow: 0 4px 16px rgba(55,157,224,0.12); transform: translateY(-2px); }
.tournament-item-title { font-family: 'Paytone One', sans-serif; font-size: 15px; margin-bottom: 6px; }
.tournament-item-desc { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 12px; line-height: 1.4; }
.tournament-item-foot { display: flex; align-items: center; justify-content: space-between; }
.t-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 900;
}
.t-badge.upcoming { background: rgba(55,157,224,0.12); color: var(--primary); }
.t-badge.ongoing { background: rgba(245,120,43,0.12); color: var(--action); }
.t-badge.done { background: rgba(0,0,0,0.06); color: var(--muted); }

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-family: 'Paytone One', sans-serif; font-size: 12px;
  padding: 12px 16px; border-bottom: 1.5px solid var(--border);
  color: var(--muted); background: var(--panel2); text-transform: uppercase; letter-spacing: 0.5px;
}
.tbl td {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 700;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--panel2); }

/* ===== ADD FORM (inline top bar) ===== */
.add-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 16px 24px; background: var(--panel2); border-bottom: 1px solid var(--border);
}
.add-bar input, .add-bar select {
  background: var(--panel); padding: 8px 12px; font-size: 13px;
}

/* ===== DETAIL LAYOUT ===== */
.detail-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ===== UTILS ===== */
.hidden { display: none !important; }
.text-muted { color: var(--muted); font-size: 13px; font-weight: 600; }
.mt-12 { margin-top: 12px; }
.player-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.player-row:last-child { border-bottom: none; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  :root { --sidebar-w: 220px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}

/* ===== MODAL POPUP ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-overlay.active {
  opacity: 1; pointer-events: auto;
}
.modal-container {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 900px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  transform: translateY(20px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow: hidden;
}
.modal-overlay.active .modal-container {
  transform: translateY(0) scale(1);
}
.modal-header {
  padding: 20px 28px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1.5px solid var(--border);
  background: var(--panel2);
}
.modal-header h2 { font-size: 20px; color: var(--text); }
.modal-close {
  background: transparent; border: none; font-size: 24px;
  line-height: 1; cursor: pointer; color: var(--muted);
  border-radius: 50%; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.modal-close:hover { background: rgba(0,0,0,0.06); color: var(--text); }

.modal-body {
  padding: 28px; overflow-y: auto; flex: 1;
}

.modal-footer {
  padding: 16px 28px;
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  border-top: 1.5px solid var(--border);
  background: var(--panel2);
}

/* Modal Form Sections */
.form-step-section {
  background: #fff; border: 1.5px solid var(--border);
  border-radius: 12px; padding: 20px; margin-bottom: 20px;
}
.form-step-title {
  font-size: 15px; margin-bottom: 16px; color: var(--text);
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}

/* Prize Row */
.prize-item-row {
  display: flex; gap: 12px; align-items: center; margin-bottom: 10px;
}

/* Matchup Creator Box */
.matchup-box {
  background: var(--panel2); border-radius: 10px; padding: 16px;
  border: 1px solid var(--border); margin-bottom: 16px;
}
.matchup-filter-row {
  display: flex; gap: 10px; margin-bottom: 12px;
}

.matchup-card-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px;
}
.matchup-card-item {
  background: #fff; border: 1.5px solid var(--border);
  border-radius: 8px; padding: 12px 14px;
  position: relative; transition: all 0.15s;
}
.matchup-card-item:hover { border-color: var(--primary); }
.matchup-card-names { font-weight: 800; font-size: 14px; margin-bottom: 4px; }
.matchup-card-meta { display: flex; justify-content: space-between; align-items: center; }

/* Group list & empty placeholder */
.group-card-builder {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; margin-bottom: 14px;
}
.assigned-matches-list {
  display: flex; flex-direction: column; gap: 8px; margin-top: 10px; margin-bottom: 10px;
}
.assigned-match-item {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04); transition: border-color 0.15s;
}
.assigned-match-item:hover {
  border-color: rgba(55,157,224,0.4);
}
.empty-placeholder {
  text-align: center; padding: 24px; color: var(--muted);
  font-weight: 700; font-size: 14px; border: 1.5px dashed var(--border);
  border-radius: 8px; background: rgba(0,0,0,0.01);
}

/* ===== ADMIN MATCHUPS LIST IN DETAIL ===== */
.admin-matchups-list {
  display: flex; flex-direction: column; gap: 12px;
}
.admin-matchup-row {
  background: var(--panel2); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; transition: all 0.18s;
}
.admin-matchup-row:hover {
  border-color: rgba(55,157,224,0.4);
  box-shadow: 0 4px 14px rgba(0,0,0,0.04);
}
.admin-matchup-players {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; flex: 1; min-width: 260px;
}
.admin-matchup-p {
  display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px;
}
.admin-matchup-p img {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border);
}
.btn-payment-toggle {
  padding: 7px 14px; font-size: 12.5px; font-weight: 800; border-radius: 8px;
  cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid transparent;
}
.btn-payment-toggle.paid {
  background: #dcfce7; color: #15803d; border-color: #22c55e;
}
.btn-payment-toggle.paid:hover {
  background: #bbf7d0;
}
.btn-payment-toggle.unpaid {
  background: #fef3c7; color: #b45309; border-color: #f59e0b;
}
.btn-payment-toggle.unpaid:hover {
  background: #fde68a;
}

/* Finish Tournament Form Item */
.finish-prize-item {
  background: var(--panel2); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 12px;
}
.finish-prize-rank {
  font-family: 'Paytone One', sans-serif; font-size: 14px; color: var(--text);
  margin-bottom: 8px; display: flex; align-items: center; gap: 8px;
}

/* Bracket builder in Admin */
.stage-builder-box {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; margin-bottom: 16px;
}
.bracket-match-row {
  display: flex; align-items: center; gap: 10px; background: #ffffff;
  padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border);
  margin-bottom: 8px; flex-wrap: wrap; box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.bracket-slot-select {
  flex: 1; min-width: 170px; font-weight: 700; font-size: 13px;
  background: #ffffff; padding: 8px 12px; border: 1.5px solid var(--border);
  border-radius: 6px;
}

.banner-preview-img {
  width: 100%; aspect-ratio: 21/8; object-fit: cover;
  border-radius: 8px; border: 1.5px solid var(--border); display: block;
}

/* Clean Banner Upload Box */
.banner-upload-box {
  position: relative; border-radius: 10px; overflow: hidden; cursor: pointer;
  border: 2px dashed var(--border); transition: all 0.2s; background: var(--panel2); margin-top: 6px;
  min-height: 140px; display: flex; align-items: center; justify-content: center;
}
.banner-upload-box:hover {
  border-color: var(--primary); background: rgba(55,157,224,0.02);
}
.banner-upload-placeholder {
  text-align: center; padding: 28px 20px; color: var(--muted);
}
.upload-icon-circle {
  font-size: 32px; margin-bottom: 6px;
}
.upload-title {
  font-family: 'Paytone One', sans-serif; font-size: 14px; color: var(--text); margin-bottom: 4px;
}
.upload-subtitle {
  font-size: 12px; color: var(--muted); font-weight: 700;
}

.banner-upload-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; opacity: 0; transition: all 0.2s; gap: 4px;
  font-weight: 800; font-size: 13px; text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.banner-upload-box:hover .banner-upload-overlay:not(.hidden) {
  opacity: 1;
}
.upload-icon { font-size: 22px; }

/* Reposition Mode Bar & Box */
.banner-reposition-bar {
  position: absolute; top: 10px; left: 10px; right: 10px;
  background: rgba(26, 26, 26, 0.85); color: #fff;
  border-radius: 8px; padding: 6px 14px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 800; z-index: 10;
  backdrop-filter: blur(6px); box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.15);
}
.banner-upload-box.repositioning {
  cursor: grab !important;
  user-select: none;
  border-color: var(--primary) !important;
  border-style: solid !important;
  box-shadow: 0 0 0 3px rgba(55,157,224,0.35);
}
.banner-upload-box.repositioning:active {
  cursor: grabbing !important;
}
.banner-upload-box.repositioning .banner-upload-overlay {
  display: none !important;
}

/* ===== BANNER GALLERY ===== */
.banner-gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px;
}
.banner-gallery-card {
  border: 2px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer;
  transition: all 0.18s; position: relative; background: var(--panel2);
}
.banner-gallery-card:hover {
  border-color: var(--primary); transform: translateY(-2px);
}
.banner-gallery-card.active {
  border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary);
}
.banner-gallery-card img {
  width: 100%; aspect-ratio: 16/7; object-fit: cover; display: block;
}
.banner-gallery-title {
  padding: 6px 8px; font-size: 11px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
}
.banner-check-badge {
  position: absolute; top: 6px; right: 6px; background: var(--primary); color: #fff;
  border-radius: 50%; width: 20px; height: 20px; font-size: 11px; font-weight: 900;
  display: none; align-items: center; justify-content: center;
}
.banner-gallery-card.active .banner-check-badge {
  display: flex;
}

/* ===== PLAYER SLOTS WITH AVATAR ===== */
.player-slots-container {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-bottom: 14px;
}
.player-slot-box {
  background: #fff; border: 2px dashed var(--border); border-radius: 10px;
  padding: 12px; transition: all 0.18s; cursor: pointer; min-height: 72px;
  display: flex; align-items: center; gap: 12px;
}
.player-slot-box:hover, .player-slot-box.active {
  border-color: var(--primary); background: rgba(55,157,224,0.03); border-style: solid;
}
.player-slot-box.has-player {
  border-style: solid; border-color: rgba(0,0,0,0.12);
}
.slot-avatar-img {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  border: 1.5px solid var(--border); background: #eee;
}
.slot-info { min-width: 0; flex: 1; }
.slot-label-small { font-size: 10px; font-weight: 900; text-transform: uppercase; color: var(--muted); letter-spacing: 0.5px; }
.slot-name { font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-pts { font-size: 11px; font-weight: 700; color: var(--primary); }

.vs-badge-circle {
  width: 32px; height: 32px; border-radius: 50%; background: var(--action); color: #fff;
  font-family: 'Paytone One', sans-serif; font-size: 11px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(245,120,43,0.3);
}

/* Player Picker Dropdown/List */
.player-picker-dropdown {
  background: #fff; border: 1.5px solid var(--border); border-radius: 10px;
  max-height: 220px; overflow-y: auto; margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}
.player-picker-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s;
}
.player-picker-item:last-child { border-bottom: none; }
.player-picker-item:hover { background: var(--panel2); }
.player-picker-item img {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.player-picker-item-name { font-weight: 800; font-size: 13px; flex: 1; }
.player-picker-item-pts { font-weight: 800; font-size: 12px; color: var(--primary); }

/* Custom status selector with full width */
.status-select-lg {
  min-width: 220px; font-weight: 800; padding: 9px 14px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  :root { --sidebar-w: 220px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  /* ===== LAYOUT ===== */
  body { flex-direction: column; }

  /* ===== SIDEBAR — MOBILE DROPDOWN ===== */
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-bottom: 2px solid #2a324b;
    z-index: 200;
    flex-shrink: 0;
  }

  /* Brand bar — luôn hiện, chứa logo + nút hamburger */
  .sidebar-brand {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: none;
    flex-direction: row;
  }
  .sidebar-brand img { height: 30px; }
  .sidebar-brand-text { display: block; }

  /* Nút hamburger trong sidebar — hiện trên mobile */
  #sidebar-menu-toggle { display: flex !important; }

  /* Nav, labels, footer — ẩn mặc định */
  .sidebar-nav,
  .sidebar-section-label,
  .sidebar-footer { display: none; }

  /* Khi sidebar.open → hiện menu xuống */
  .sidebar.open .sidebar-nav {
    display: flex;
    flex-direction: column;
    overflow: visible;
    padding: 8px 16px;
    gap: 6px;
    animation: slideDown 0.22s ease-out;
  }
  .sidebar.open .sidebar-section-label {
    display: block;
    padding: 10px 16px 4px;
    font-size: 10px;
    animation: slideDown 0.22s ease-out;
  }
  .sidebar.open .sidebar-footer {
    display: flex;
    flex-direction: column;
    padding: 10px 16px 16px;
    gap: 8px;
    border-top: 1px solid rgba(255,255,255,0.07);
    animation: slideDown 0.22s ease-out;
  }

  .sidebar-nav a {
    flex-direction: row;
    gap: 12px;
    font-size: 14px;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 0;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    white-space: normal;
  }
  .sidebar-nav a.active { background: var(--primary); border-color: transparent; }
  .sidebar-footer a.home-link,
  .sidebar-footer .btn-logout {
    margin: 0; width: 100%; justify-content: center; padding: 12px;
  }

  /* ===== MAIN CONTENT ===== */
  .main-content { height: auto; padding: 20px 16px; overflow-x: hidden; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
  .page-title { font-size: 22px; }

  /* ===== STATS & CARDS ===== */
  .stats-row { grid-template-columns: 1fr; gap: 12px; }
  .detail-layout { grid-template-columns: 1fr; }
  .tournament-grid { grid-template-columns: 1fr; padding: 16px; }

  .card-head { flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }
  .card-head h2 { font-size: 15px; }
  .add-bar { flex-direction: column; align-items: stretch; padding: 12px 16px; gap: 10px; }
  .add-bar input, .add-bar select, .add-bar .btn { width: 100%; justify-content: center; }

  /* ===== TABLES ===== */
  .tbl-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
  .tbl th, .tbl td { white-space: nowrap; padding: 10px 12px; font-size: 13px; }

  /* ===== MODALS ===== */
  .modal-overlay { padding: 0; }
  .modal-container {
    margin: 0; max-height: 100dvh; height: 100dvh;
    border-radius: 0; width: 100%; max-width: 100%; border: none;
    overflow-y: auto;
  }
  .modal-header { padding: 16px; border-radius: 0; }
  .modal-header h2 { font-size: 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; flex-direction: column-reverse; align-items: stretch; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  /* ===== BRACKET & MATCHUPS ===== */
  .player-slots-container { grid-template-columns: 1fr; gap: 16px; position: relative; }
  .vs-badge-circle { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2; border: 2px solid #fff; }
  .admin-matchup-row { flex-direction: column; align-items: stretch; gap: 12px; padding: 12px; }
  .admin-matchup-players { flex-direction: column; align-items: stretch; gap: 8px; }
  .admin-matchup-p { justify-content: space-between; background: #fff; padding: 10px; border-radius: 8px; border: 1px solid var(--border); }

  /* ===== FORMS ===== */
  .prize-item-row { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px; background: rgba(0,0,0,0.02); border-radius: 8px; border: 1px solid var(--border); }
  .prize-item-row select { width: 100% !important; }
  .matchup-filter-row { flex-direction: column; align-items: stretch; }
  .matchup-filter-row select { width: 100% !important; }
  .form-group > div[style*="display:flex"] { flex-direction: column; align-items: stretch !important; gap: 8px; }
  .form-group > div[style*="display:flex"] > div { width: 100%; }
  .form-group > div[style*="display:flex"] .btn { width: 100%; justify-content: center; }
  .inline-form { flex-direction: column; align-items: stretch !important; }
  .inline-form > div { max-width: 100% !important; flex-direction: column; align-items: stretch !important; }

  .bracket-btn-group { flex-direction: column; align-items: stretch; width: 100%; }
  .bracket-btn-group .btn { width: 100%; justify-content: center; }
  .group-builder-header { flex-direction: column; align-items: flex-start !important; gap: 8px; }
  .group-builder-header input { width: 100% !important; }
  .group-builder-header .btn { width: 100%; margin-left: 0 !important; justify-content: center; }

  /* ===== LOGIN PAGE TOPBAR ===== */
  .topbar-in { position: relative; justify-content: center; padding: 10px 16px; }
  .menu-toggle { display: flex; position: absolute; right: 16px; }
  .topnav {
    display: none; position: absolute; top: 100%; left: 0; width: 100%;
    background: var(--panel); flex-direction: column; padding: 16px 20px; gap: 8px;
    border-bottom: 2px solid var(--text); box-shadow: 0 10px 25px rgba(0,0,0,0.15); z-index: 55;
  }
  .topnav.open { display: flex; animation: slideDown 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
  .login-box { padding: 32px 20px; margin: 16px; }
}

@media (max-width: 480px) {
  .spinning-ball { display: none; }
}





/* Lucide Icons Global Style */
[data-lucide] {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==========================================
   KNOCKOUT BRACKET & CONNECTOR LINES
   ========================================== */
.bracket-tree-container {
    display: flex;
    align-items: stretch;
    gap: 0;
    overflow-x: auto;
    padding: 16px 8px;
    -webkit-overflow-scrolling: touch;
}

.bracket-stage-col {
    display: flex;
    flex-direction: column;
    width: 250px;
    min-width: 230px;
    flex-shrink: 0;
}

.bracket-stage-header {
    font-family: 'Paytone One', sans-serif;
    font-size: 13.5px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 16px;
    color: #0369a1;
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    border: 1.5px solid #7dd3fc;
    padding: 6px 14px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.08);
}

.bracket-stage-header.final-stage {
    color: #d97706;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: #f59e0b;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.12);
}

.bracket-stage-body {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    flex: 1;
    gap: 16px;
}

.bracket-match-node {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    position: relative;
    padding: 4px 0;
}

.bracket-spacer-col {
    width: 40px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}

.bracket-connector-unit {
    display: flex;
    flex-direction: column;
    flex: 1;
    position: relative;
}

.bracket-connector-top {
    flex: 1;
    border-right: 2px solid #94a3b8;
    border-top: 2px solid #94a3b8;
    border-top-right-radius: 8px;
    margin-top: 25%;
}

.bracket-connector-bot {
    flex: 1;
    border-right: 2px solid #94a3b8;
    border-bottom: 2px solid #94a3b8;
    border-bottom-right-radius: 8px;
    margin-bottom: 25%;
}

.bracket-connector-stem {
    position: absolute;
    right: -20px;
    top: 50%;
    width: 20px;
    height: 2px;
    background: #94a3b8;
    transform: translateY(-50%);
}

/* ===================================================
   PLAYER MOBILE CARD — hiển thị thay bảng trên mobile
   =================================================== */

/* Desktop: hiện bảng, ẩn cards */
.admin-table-view { display: block; }
.admin-card-view  { display: none;  }

/* ── Card item ── */
.player-mobile-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.player-mobile-card:last-child { border-bottom: none; }
.player-mobile-card:active { background: #f8fafc; }

/* Rank badge */
.pmc-rank {
    font-size: 13px;
    font-weight: 900;
    color: var(--muted);
    min-width: 28px;
    text-align: center;
    flex-shrink: 0;
}
.pmc-rank.pmc-rank-medal { font-size: 20px; }

/* Avatar */
.pmc-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e2e8f0;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.15s;
}
.pmc-avatar:active { transform: scale(0.95); }

/* Info */
.pmc-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}
.pmc-name {
    font-size: 14px;
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pmc-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    flex-wrap: wrap;
}
.pmc-pts {
    font-size: 12px;
    font-weight: 800;
    color: #d97706;
}

/* Action buttons */
.pmc-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
}
.pmc-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    line-height: 1;
}
.pmc-btn:active { transform: scale(0.92); }
.pmc-btn-edit {
    background: #eff6ff;
    color: var(--primary);
    border: 1px solid #bfdbfe;
}
.pmc-btn-edit:hover { background: #dbeafe; }
.pmc-btn-del {
    background: #fef2f2;
    color: #ef4444;
    border: 1px solid #fecaca;
}
.pmc-btn-del:hover { background: #fee2e2; }

/* ── Filter bar mobile ── */
#filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Stat cards: 3 cột trên desktop, tự co trên mobile ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* ── RESPONSIVE: chuyển sang card view ── */
@media (max-width: 768px) {
    /* Ẩn bảng, hiện card list */
    .admin-table-view { display: none !important; }
    .admin-card-view  { display: block !important; }

    /* Filter bar: search full-width dòng đầu, 2 select dòng dưới */
    #filter-bar {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 0 16px 14px;
    }
    #filter-bar #search-player-admin {
        grid-column: 1 / -1;   /* full width */
        width: 100% !important;
        font-size: 14px !important;
        padding: 9px 12px !important;
    }
    #filter-bar #filter-gender,
    #filter-bar #sort-players {
        width: 100% !important;
        font-size: 13px !important;
        padding: 8px 10px !important;
    }

    /* card-head stack dọc */
    .card-head {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    /* Stat cards: 2 cột trên tablet */
    .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }

    /* Nút "Tạo tuyển thủ" full-width */
    .page-header .btn { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
    /* Stat cards: 1 cột trên điện thoại nhỏ */
    .stats-row { grid-template-columns: 1fr; gap: 8px; }

    .pmc-avatar { width: 40px; height: 40px; }
    .pmc-name { font-size: 13px; }
    .pmc-btn { width: 32px; height: 32px; font-size: 14px; }
    .pmc-rank.pmc-rank-medal { font-size: 18px; }
}

/* ===== BANNER MANAGEMENT RESPONSIVE STYLES ===== */
.banner-tbl-thumb {
  width: 190px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0f172a;
  position: relative;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.banner-tbl-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (max-width: 768px) {
  .banner-tbl-thumb {
    width: 130px;
    height: 48px;
  }
  .banner-inputs-row {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .banner-inputs-row > div {
    min-width: 100% !important;
  }
  .banner-form-actions {
    flex-direction: column-reverse !important;
    gap: 8px !important;
  }
  .banner-form-actions .btn {
    width: 100% !important;
    justify-content: center !important;
  }
  #banner-manage-preview-box {
    min-height: 150px !important;
  }
}

@media (max-width: 480px) {
  .banner-tbl-thumb {
    width: 100px;
    height: 40px;
  }
  #banner-pos-slider {
    height: 24px;
  }
}

/* ===================================================
   ADMIN PAGINATION — giống client
   =================================================== */
#admin-player-pagination {
  padding: 4px 16px 16px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 4px;
}

.pagination-info {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.pagination-info strong {
  color: var(--primary);
}

.pagination-btns {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.pg-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pg-btn:hover:not(.disabled):not(.pg-active) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.pg-btn.pg-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  cursor: default;
}

.pg-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.pg-ellipsis {
  font-size: 14px;
  color: var(--muted);
  padding: 0 4px;
  line-height: 36px;
}

@media (max-width: 500px) {
  .pagination {
    justify-content: center;
  }
  .pg-btn {
    min-width: 32px;
    height: 32px;
    font-size: 13px;
  }
}

/* ===================================================
   BANNER MOBILE CARD
   =================================================== */
.banner-mobile-card {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}
.banner-mobile-card:last-child { border-bottom: none; }

/* Thumbnail dạng wide 16:7 */
.bmc-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 6;
    overflow: hidden;
    background: #e2e8f0;
    flex-shrink: 0;
}
.bmc-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.bmc-order {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 20px;
    font-family: monospace;
}

/* Body */
.bmc-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.bmc-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.3;
}
.bmc-url {
    font-size: 11px;
    color: var(--muted);
    word-break: break-all;
    line-height: 1.4;
    max-height: 32px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bmc-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    gap: 8px;
}
