
:root {
  --bg: #062016;
  --bg2: #022c22;
  --glass: rgba(255,255,255,0.04);
  --glass-border: rgba(255,255,255,0.1);
  --accent: #10b981;
  --accent2: #34d399;
  --success: #34d399;
  --danger: #ef4444;
  --warning: #fbbf24;
  --info: #3b82f6;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 10px 40px rgba(0,0,0,0.5);
  --glass-modal: rgba(15, 25, 20, 0.95);
  --transition: 0.2s ease;
}

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

body {
  font-family: 'Vazirmatn', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(56,189,248,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(129,140,248,0.08) 0%, transparent 60%);
  direction: rtl;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

/* ===== LAYOUT ===== */
.app-container { 
  display: flex; 
  flex-direction: column; 
  min-height: 100vh; 
  width: 100%; 
  overflow-x: hidden;
}

.content-wrapper { 
  flex: 1; 
  padding: 2rem; 
  max-width: 1400px; 
  margin: 0 auto; 
  width: 100%; 
  box-sizing: border-box; 
}

/* ===== HEADER ===== */
.glass-header {
  background: rgba(10,15,30,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  width: 100%;
}

.glass-header > div, .glass-header > nav {
  /* This ensures the header content stays aligned with the main content */
  max-width: 1400px;
}
.logo { display: flex; align-items: center; gap: 0.75rem; }
.logo-icon { font-size: 2rem; }
.logo-title { display: block; font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.logo-sub { display: block; font-size: 0.72rem; color: var(--text-muted); }
nav ul { list-style: none; display: flex; gap: 0.5rem; }
.nav-link {
  display: block; padding: 0.5rem 1rem; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-size: 0.9rem;
  transition: all var(--transition);
}
.nav-link:hover { background: var(--glass); color: var(--text); }

/* ===== FOOTER ===== */
.glass-footer {
  background: rgba(10,15,30,0.7);
  border-top: 1px solid var(--glass-border);
  text-align: center;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===== GLASS PANEL ===== */
.glass-panel {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem; padding: 0.6rem 1.3rem;
  border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition); text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg,#38bdf8,#818cf8); color: #fff; }
.btn-primary:hover { opacity: 0.9; box-shadow: 0 4px 15px rgba(56,189,248,0.3); }
.btn-success { background: linear-gradient(135deg,#34d399,#059669); color: #fff; }
.btn-success:hover { opacity: 0.9; box-shadow: 0 4px 15px rgba(52,211,153,0.3); }
.btn-danger { background: linear-gradient(135deg,#f87171,#dc2626); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-secondary { background: rgba(255,255,255,0.08); color: var(--text); border: 1px solid var(--glass-border); }
.btn-secondary:hover { background: rgba(255,255,255,0.12); }
.btn-info { background: linear-gradient(135deg,#60a5fa,#3b82f6); color: #fff; }
.btn-info:hover { opacity: 0.9; }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 1.1rem; padding: 0.2rem 0.4rem; border-radius: 6px; transition: background var(--transition); }
.btn-danger-icon:hover { background: rgba(248,113,113,0.15); }

/* ===== FORMS ===== */
.form-control, .form-select {
  width: 100%; padding: 0.65rem 1rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: inherit; font-size: 0.9rem;
  transition: border var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.15);
}
.form-control option {
  background: var(--bg2);
  color: var(--text);
}
.form-control::placeholder { color: var(--text-muted); }
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; margin-bottom: 0.4rem; font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.toggle-label { display: flex; align-items: center; gap: 0.7rem; cursor: pointer; }
.toggle-label input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.toggle-text { font-weight: 600; color: var(--text); }
.toggle-hint { font-size: 0.8rem; color: var(--text-muted); }

/* ===== BADGES ===== */
.badge {
  display: inline-block; padding: 0.2rem 0.65rem; border-radius: 20px;
  font-size: 0.75rem; font-weight: 700;
}
.badge-admin { background: rgba(251,191,36,0.15); color: var(--warning); border: 1px solid rgba(251,191,36,0.3); }
.badge-superadmin { background: rgba(139, 92, 246, 0.15); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-user { background: rgba(56,189,248,0.1); color: var(--accent); border: 1px solid rgba(56,189,248,0.2); }
.badge-active { background: rgba(52,211,153,0.1); color: var(--success); border: 1px solid rgba(52,211,153,0.2); }
.badge-eliminated { background: rgba(248,113,113,0.1); color: var(--danger); border: 1px solid rgba(248,113,113,0.2); }

/* ===== BRACKET BADGES ===== */
.bracket-badge {
  display: inline-block; padding: 0.18rem 0.6rem; border-radius: 20px;
  font-size: 0.78rem; font-weight: 700; white-space: nowrap;
}
.winners-badge { background: rgba(52,211,153,0.15); color: var(--success); border: 1px solid rgba(52,211,153,0.3); }
.losers-badge  { background: rgba(248,113,113,0.12); color: var(--danger);  border: 1px solid rgba(248,113,113,0.25); }
.elim-badge    { background: rgba(148,163,184,0.1);  color: var(--text-muted); border: 1px solid rgba(148,163,184,0.2); }
.cross-badge   { background: rgba(251,191,36,0.12);  color: var(--warning); border: 1px solid rgba(251,191,36,0.3); }

.mmc-bracket-label { margin-bottom: .2rem; }

/* ===== BULK USER CHECKBOXES ===== */
.user-checkbox-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .65rem; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; transition: background var(--transition), border-color var(--transition);
}
.user-checkbox-row:hover { background: rgba(255,255,255,.05); border-color: var(--glass-border); }
.user-checkbox-row input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; }
.user-checkbox-row:has(input:checked) { background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.25); }

/* ===== EXTRA ICON BUTTONS ===== */
.btn-secondary-icon { background: rgba(255,255,255,.07); border: 1px solid var(--glass-border); border-radius: 6px; cursor: pointer; font-size: .85rem; padding: .25rem .55rem; transition: background var(--transition); color: var(--text-muted); }
.btn-secondary-icon:hover { background: rgba(255,255,255,.14); color: var(--text); }

/* ===== STATUS BADGES ===== */
.status-badge {
  display: inline-block; padding: 0.3rem 0.85rem; border-radius: 20px;
  font-size: 0.82rem; font-weight: 700;
}
.status-registration { background: rgba(56,189,248,0.15); color: var(--accent); border: 1px solid rgba(56,189,248,0.3); }
.status-inprogress { background: rgba(251,191,36,0.15); color: var(--warning); border: 1px solid rgba(251,191,36,0.3); }
.status-finished { background: rgba(52,211,153,0.15); color: var(--success); border: 1px solid rgba(52,211,153,0.2); }

/* ===== ALERTS ===== */
.alert-error {
  background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3);
  color: var(--danger); border-radius: var(--radius-sm);
  padding: 0.65rem 1rem; margin-bottom: 1rem; font-size: 0.9rem;
}
.alert-info {
  background: rgba(56,189,248,0.08); border: 1px solid rgba(56,189,248,0.2);
  color: var(--accent); border-radius: var(--radius-sm);
  padding: 0.65rem 1rem; margin-bottom: 1rem; font-size: 0.9rem;
}

/* ===== LOGIN PAGE ===== */
.admin-login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 120px);
}
.login-card {
  padding: 2.5rem; width: 100%; max-width: 420px; text-align: center;
}
.login-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.login-card h2 { font-size: 1.5rem; margin-bottom: 0.3rem; }
.login-sub { color: var(--text-muted); margin-bottom: 2rem; font-size: 0.9rem; }
.login-card form { text-align: right; }
.hint-text { color: var(--text-muted); font-size: 0.78rem; margin-top: 1rem; }

/* ===== ADMIN LAYOUT ===== */
.admin-wrapper { 
  display: grid; 
  grid-template-columns: auto 1fr; 
  gap: 1.5rem; 
  min-height: calc(100vh - 120px); 
}
@media (max-width: 1024px) {
  .admin-wrapper { grid-template-columns: 1fr; }
}
.admin-sidebar {
  padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem;
  align-self: start; position: sticky; top: 90px;
}
.sidebar-avatar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.avatar-icon { font-size: 2.2rem; }
.avatar-name { font-weight: 700; font-size: 0.95rem; }
.avatar-role { font-size: 0.78rem; color: var(--text-muted); }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.8rem 1.2rem; border-radius: 12px;
  color: var(--text-muted); text-decoration: none; font-size: 0.95rem; font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); transform: translateX(-5px); }
.nav-item.active { 
  background: rgba(16, 185, 129, 0.1); 
  color: var(--accent); 
  border: 1px solid rgba(16, 185, 129, 0.2);
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.logout-button:hover { color: var(--danger) !important; background: rgba(239, 68, 68, 0.05) !important; }
.sidebar-logout { margin-top: auto; }
.admin-main { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; width: 100%; }

/* ===== TAB HEADER ===== */
.tab-header { display: flex; justify-content: space-between; align-items: center; }
.tab-header h2 { font-size: 1.4rem; }

/* ===== DATA TABLE ===== */
.table-card { padding: 1.5rem; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: right; padding: 0.75rem 1rem;
  font-size: 0.8rem; font-weight: 700; color: var(--text-muted);
  border-bottom: 1px solid var(--glass-border); white-space: nowrap;
}
.data-table td { padding: 0.8rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.user-cell { display: flex; align-items: center; gap: 0.6rem; white-space: nowrap; }
.user-avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg,var(--accent),var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.text-muted { color: var(--text-muted); font-size: 0.85rem; }
.row-eliminated td { opacity: 0.5; }
.row-gold td { background: rgba(251,191,36,0.06); }
.row-silver td { background: rgba(148,163,184,0.05); }
.row-bronze td { background: rgba(180,120,60,0.05); }
.row-current-user td { border-right: 3px solid var(--accent); background: rgba(16,185,129,0.08); }

/* ===== TOURNAMENTS GRID ===== */
.tournaments-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.tournament-card { padding: 1.5rem; display: flex; flex-direction: column; gap: 1.2rem; transition: transform var(--transition), box-shadow var(--transition); }
.tournament-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tc-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.tc-header-info { min-width: 0; flex: 1; }
.tc-header h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-meta { font-size: 0.8rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.tc-stats { display: flex; gap: 0; border-top: 1px solid var(--glass-border); border-bottom: 1px solid var(--glass-border); padding: 0.75rem 0; }
.tc-stat { flex: 1; text-align: center; }
.tc-stat:not(:last-child) { border-left: 1px solid var(--glass-border); }
.stat-val { display: block; font-size: 1.4rem; font-weight: 800; color: var(--accent); }
.stat-label { display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }
.tc-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: auto; }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  animation: fadeInModal 0.3s ease;
}
@keyframes fadeInModal { from { opacity: 0; } to { opacity: 1; } }

.modal-box { 
  background: var(--glass-modal);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 2.5rem; width: 100%; max-width: 520px; 
  box-shadow: var(--shadow);
  transform: translateY(0);
  animation: slideUpModal 0.3s ease;
}
@keyframes slideUpModal { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-header h3 { font-size: 1.2rem; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; padding: 0.2rem 0.5rem; border-radius: 6px; }
.modal-close:hover { background: var(--glass); color: var(--text); }
.modal-footer { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ===== PAGE HEADER BAR ===== */
.page-header-bar {
  padding: 1.2rem 1.5rem;
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 1.5rem; gap: 1rem;
}
.back-link { color: var(--text-muted); text-decoration: none; font-size: 0.85rem; display: block; margin-bottom: 0.4rem; }
.back-link:hover { color: var(--accent); }
.page-header-bar h2 { font-size: 1.3rem; }
.header-actions { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }

/* ===== TWO COLUMN LAYOUT ===== */
.two-col-layout { 
  display: grid; 
  grid-template-columns: 1fr 380px; 
  gap: 2rem; 
  align-items: start; 
}

@media (max-width: 1200px) {
  .two-col-layout { grid-template-columns: 1fr; }
}

/* ===== STAT CHIPS ===== */
.stat-chip { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 20px; font-size: 0.8rem; font-weight: 700; }
.stat-chip.win { background: rgba(52,211,153,0.15); color: var(--success); }
.stat-chip.lose { background: rgba(248,113,113,0.15); color: var(--danger); }

/* ===== EMPTY STATES ===== */
.empty-state { padding: 4rem 2rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.empty-state h3 { font-size: 1.2rem; color: var(--text-muted); }
.empty-state p { color: var(--text-muted); font-size: 0.9rem; }
.empty-mini { text-align: center; color: var(--text-muted); padding: 2rem; font-size: 0.9rem; }

/* ===== ROUNDS HISTORY ===== */
.rounds-history { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.round-history-card { background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border); border-radius: var(--radius-sm); overflow: hidden; }
.round-title { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; background: rgba(56,189,248,0.08); border-bottom: 1px solid var(--glass-border); }
.round-num { font-weight: 700; color: var(--accent); }
.round-count { font-size: 0.78rem; color: var(--text-muted); }
.matches-list { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.history-match { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem; border-radius: var(--radius-sm); background: rgba(255,255,255,0.02); font-size: 0.85rem; flex-wrap: wrap; }
.hm-player { display: flex; align-items: center; gap: 0.4rem; flex: 1; }
.hm-winner .hm-name { color: var(--success); font-weight: 700; }
.hm-loser .hm-name { color: var(--text-muted); }
.hm-score { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 6px; padding: 0.1rem 0.4rem; font-weight: 700; font-size: 0.9rem; }
.hm-vs { color: var(--text-muted); font-size: 0.75rem; font-weight: 700; flex-shrink: 0; }
.hm-result { width: 100%; font-size: 0.78rem; color: var(--warning); padding-top: 0.25rem; border-top: 1px dashed rgba(255,255,255,0.06); }
.bye-match { opacity: 0.6; }
.bye-tag { font-size: 0.72rem; background: var(--glass); padding: 0.1rem 0.4rem; border-radius: 4px; color: var(--text-muted); }

/* ===== CURRENT MATCHES GRID ===== */
.current-matches-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.2rem; }
.match-manage-card {
  border: 1px solid var(--glass-border); border-radius: var(--radius-sm);
  padding: 1.2rem; display: flex; flex-direction: column; gap: 0.8rem;
  transition: border-color var(--transition);
}
.match-manage-card.pending { border-color: rgba(251,191,36,0.3); background: rgba(251,191,36,0.03); }
.match-manage-card.done { border-color: rgba(52,211,153,0.2); background: rgba(52,211,153,0.02); }
.match-manage-card.bye { border-color: var(--glass-border); opacity: 0.6; }
.mmc-badge { font-size: 0.75rem; font-weight: 700; padding: 0.2rem 0.6rem; border-radius: 20px; align-self: flex-start; }
.pending-badge { background: rgba(251,191,36,0.15); color: var(--warning); }
.done-badge { background: rgba(52,211,153,0.15); color: var(--success); }
.mmc-vs-row { display: flex; align-items: center; gap: 0.75rem; }
.mmc-player { flex: 1; text-align: center; }
.winner-p .mmc-name { color: var(--success); font-weight: 700; }
.loser-p .mmc-name { color: var(--text-muted); }
.mmc-name { font-size: 0.9rem; font-weight: 600; display: block; margin-bottom: 0.3rem; }
.mmc-score-big { font-size: 2rem; font-weight: 900; }
.winner-p .mmc-score-big { color: var(--success); }
.loser-p .mmc-score-big { color: var(--text-muted); }
.mmc-vs-text { color: var(--text-muted); font-weight: 700; font-size: 0.9rem; flex-shrink: 0; }
.mmc-winner-tag { text-align: center; color: var(--warning); font-size: 0.85rem; font-weight: 700; }

/* Score input */
.score-input-row { display: flex; align-items: center; gap: 0.5rem; justify-content: center; }
.score-player-block { flex: 1; text-align: center; min-width: 0; }
.score-player-block .mmc-name { margin-bottom: 0.4rem; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-input {
  width: 70px; text-align: center; font-size: 1.4rem; font-weight: 800;
  background: rgba(255,255,255,0.07); border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm); color: var(--text); padding: 0.4rem;
  font-family: inherit; outline: none;
}
.score-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56,189,248,0.15); }
.vs-divider { color: var(--text-muted); font-weight: 900; font-size: 1.1rem; flex-shrink: 0; }

/* Radio winner */
.winner-select-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; font-size: 0.85rem; }
.winner-select-row label:first-child { color: var(--text-muted); font-weight: 600; }
.radio-label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.radio-label input[type=radio] { accent-color: var(--accent); }

.welcome-card-main {
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.welcome-section-btns {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}
.welcome-section-btns .btn {
  font-size: 1.1rem;
  padding: 0.8rem 2.2rem;
}
.trophy-icon { font-size: 4rem; margin-bottom: 1rem; }
.winner-highlight { color: var(--warning); font-size: 2rem; margin-bottom: 0.5rem; }
.champion-name { font-size: 2.5rem; font-weight: 900; color: var(--success); }
.champion-stats { color: var(--text-muted); margin-top: 0.5rem; }

/* ===== INDEX PAGE (public bracket) ===== */
.status-panel { text-align: center; padding: 2rem; }
.bracket-container { 
    display: flex; 
    gap: 2rem; 
    margin-top: 2rem; 
    overflow-x: auto; 
    padding-bottom: 2rem;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}
.bracket-container::-webkit-scrollbar { height: 6px; }
.bracket-container::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 10px; }
.bracket-column { background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 1.5rem; }
.bracket-column h2 { color: var(--accent); font-size: 1rem; margin-bottom: 1rem; text-align: center; }
.match-card { background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border); border-radius: var(--radius-sm); padding: 1rem; margin-bottom: 1rem; }
.player-row { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0; }
.player-name { font-size: 0.95rem; }
.player-winner { color: var(--success); font-weight: 700; }
.player-loser { color: var(--danger); opacity: 0.7; }
.round-history-card-pub { background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border); border-radius: var(--radius-sm); padding: 1rem; }

/* ===== TABS & ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade { animation: fadeIn 0.4s ease forwards; }

.tab-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.tabs-container { margin-bottom: 2rem; }
.tabs { display: flex; gap: 0.5rem; background: rgba(0,0,0,0.2); padding: 0.4rem; border-radius: var(--radius-sm); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab-item { padding: 0.5rem 1rem; color: var(--text-muted); text-decoration: none; border-radius: 6px; font-size: 0.85rem; font-weight: 600; transition: all 0.2s; white-space: nowrap; }
.tab-item:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.tab-item.active { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(16,185,129,0.3); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .admin-wrapper { grid-template-columns: 1fr; gap: 0; width: 100%; }
  .admin-sidebar { 
    position: sticky; top: 0; z-index: 99;
    padding: 0.5rem;
    flex-direction: row; align-items: center; justify-content: space-around;
    border-radius: 0; margin-bottom: 1rem;
    backdrop-filter: blur(20px);
    background: rgba(10, 30, 20, 0.8);
    border-bottom: 1px solid var(--glass-border);
    width: 100vw;
    margin-right: calc(-1 * var(--content-padding, 0.5rem)); /* Offset content padding if needed */
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  }
  .sidebar-avatar { display: none; }
  .sidebar-nav { flex-direction: row; gap: 0.25rem; flex: 1; width: 100%; }
  .nav-item { 
    flex: 1;
    padding: 0.6rem 0.4rem; 
    font-size: 0.7rem; 
    flex-direction: column; 
    gap: 4px; 
    text-align: center;
    border-radius: 10px;
    background: transparent;
    border: none;
    transition: background 0.3s;
  }
  .nav-item:hover { transform: none; background: rgba(255,255,255,0.05); }
  .nav-item.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent2);
    box-shadow: none;
    border: none;
  }
  .nav-item span { font-size: 1.2rem; }
  .nav-item-text { display: block; font-weight: 700; opacity: 0.9; }
  .sidebar-logout { margin: 0; display: flex; align-items: center; }
  .logout-button { padding: 0.5rem !important; border-radius: 50% !important; width: 40px !important; height: 40px !important; justify-content: center; }
  .logout-button .nav-item-text { display: none; }
  
  .two-col-layout { grid-template-columns: 1fr; gap: 1rem; }
}

@media (max-width: 900px) {
  .two-col-layout { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .content-wrapper { padding: 0.75rem 0.5rem; }
  .glass-header { padding: 0.6rem 0.8rem; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.4rem; }
  .logo { gap: 0.4rem; flex: 1; }
  .logo-icon { font-size: 1.2rem; }
  .logo-title { font-size: 0.85rem; }
  .logo-sub { display: none; }
  nav { order: 3; width: 100%; margin-top: 0.2rem; }
  nav ul { gap: 0.2rem; justify-content: space-between; width: 100%; }
  .nav-link { font-size: 0.72rem; padding: 0.35rem 0.5rem; flex: 1; text-align: center; white-space: nowrap; }
  .nav-link span { display: none; } /* Hide text in small nav if needed, but let's try wrapping first */
  
  .tab-header { flex-direction: column; align-items: stretch; gap: 0.75rem; margin-bottom: 1rem; }
  .tab-header h2 { text-align: center; font-size: 1.1rem; }
  .tab-header .btn { width: 100%; padding: 0.75rem; }

  .page-header-bar { flex-direction: column; align-items: stretch; padding: 1rem; gap: 0.5rem; }
  .header-actions { width: 100%; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
  .header-actions .btn { flex: 1; }

  .tournaments-grid { grid-template-columns: 1fr; gap: 0.85rem; }
  .tournament-card { padding: 1rem; gap: 0.8rem; }
  .tc-header { flex-direction: row; align-items: flex-start; justify-content: space-between; }
  .tc-header .status-badge { font-size: 0.7rem; padding: 0.2rem 0.5rem; }
  .tc-header h3 { font-size: 1rem; white-space: normal; }
  .tc-meta { font-size: 0.7rem; gap: 0.3rem; }
  
  .tc-stats { 
    display: grid; grid-template-columns: repeat(3, 1fr); 
    padding: 0.6rem 0; gap: 0.5rem;
  }
  .tc-stat { border-left: none !important; }
  .stat-val { font-size: 1.2rem; }
  .stat-label { font-size: 0.6rem; }

  .tc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .tc-actions a, .tc-actions button, .tc-actions form { width: 100%; margin: 0; }
  .tc-actions form { grid-column: span 2; }
  .tc-actions .btn { width: 100%; font-size: 0.8rem; padding: 0.6rem; }

  .modal-box { 
    padding: 1.5rem; width: 100%; margin: 0; 
    border-radius: 20px 20px 0 0; 
    position: fixed; bottom: 0; left: 0; right: 0;
    max-width: 100%; 
    max-height: 90vh; overflow-y: auto;
  }
  @keyframes slideUpModal { from { transform: translateY(100%); } to { transform: translateY(0); } }
  
  .tabs-container { 
    margin-bottom: 1.2rem; 
    overflow-x: auto; 
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding: 0.2rem 0;
  }
  .tabs { padding: 0.3rem; gap: 0.3rem; display: inline-flex; min-width: 100%; scroll-snap-type: x mandatory; }
  .tab-item { padding: 0.5rem 0.9rem; font-size: 0.78rem; scroll-snap-align: start; }

  .form-grid-2 { grid-template-columns: 1fr; gap: 0; }

  /* Table optimizations */
  .table-card { 
    padding: 0; 
    margin: 0;
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch; 
    width: 100%;
    max-width: 100%;
    display: block;
    background: rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
  }
  /* .data-table { min-width: 450px; }  */
  .data-table th, .data-table td { padding: 0.6rem 0.5rem; font-size: 0.72rem; }
  
  .hide-mobile { display: none !important; }
  
  .user-cell { white-space: nowrap; }
  .user-avatar-sm { width: 22px; height: 22px; font-size: 0.65rem; }
  
  .admin-sidebar { width: 100%; border-radius: 0; margin-left: -0.5rem; margin-right: -0.5rem; }
  .sidebar-nav { gap: 0.1rem; }
  .nav-item { padding: 0.5rem 0.2rem; }
  .nav-item span { font-size: 1.1rem; }
  .nav-item-text { font-size: 0.58rem; }
  
  .sidebar-logout { margin: 0; }
  .sidebar-logout .btn { padding: 0.3rem 0.5rem; font-size: 0.7rem; }

  .score-input { width: 45px; font-size: 1.1rem; padding: 0.2rem; }
  .winner-select-row { flex-direction: column; align-items: stretch; }
  .radio-label { background: rgba(255,255,255,0.03); padding: 0.6rem; border-radius: 8px; }

  .glass-panel { padding: 1rem !important; }
  .glass-panel h2 { font-size: 1rem !important; }
  
  .welcome-section-icon { font-size: 2.5rem !important; }
  .welcome-section-title { font-size: 1.2rem !important; }
  .welcome-section-text { font-size: 0.85rem !important; line-height: 1.6 !important; }
  .welcome-card-main { padding: 1.5rem !important; }
  .welcome-section-btns { flex-direction: column; width: 100%; gap: 0.75rem; }
  .welcome-section-btns .btn { width: 100% !important; font-size: 1rem; padding: 0.75rem; }
}

@media (max-width: 400px) {
  .nav-item { min-width: auto; font-size: 0.7rem; }
  .tc-stat { padding: 0.4rem 0.15rem; }
  .stat-val { font-size: 0.95rem; }
  .stat-label { font-size: 0.55rem; }
  .tournament-dashboard-grid { grid-template-columns: 1fr 1fr !important; gap: 0.5rem !important; }
  .current-matches-grid { grid-template-columns: 1fr !important; gap: 0.8rem !important; }
  .mmc-vs-row { gap: 0.2rem; }
  .mmc-name { font-size: 0.75rem; }
  .mmc-score-big { font-size: 1.5rem; }
  .btn { font-size: 0.8rem; padding: 0.6rem 0.8rem; }
  
  /* Force tables to be scrollable and not break parent */
  .table-card { overflow-x: auto !important; width: 100%; display: block; }
  .data-table { min-width: 500px; }
  
  .admin-sidebar .nav-item-text { display: none; }
  .admin-sidebar .nav-item { min-width: 40px; }
}

@media (max-width: 350px) {
  .glass-header { flex-direction: column; align-items: center; text-align: center; gap: 0.8rem; }
  .logo { justify-content: center; }
  nav ul { flex-direction: column; width: 100%; gap: 0.4rem; }
  .nav-link { width: 100%; }
}
/* ===== NEW REGENERATION & HISTORY EDIT STYLES ===== */
.alert-warning {
  padding: 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 2rem;
  animation: fadeIn 0.4s ease;
}

.history-submit-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.history-score-input {
  width: 50px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: var(--text);
  text-align: center;
  font-weight: 700;
  padding: 0.2rem;
  outline: none;
}

.history-score-input:focus {
  border-color: var(--accent2);
}

.hm-winner {
  background: rgba(52, 211, 153, 0.08);
  border-radius: 4px;
  padding-left: 0.4rem;
}

.hm-loser {
  opacity: 0.8;
}

.round-history-card .hm-result {
  margin-top: 0.5rem;
  border-top: 1px dashed var(--glass-border);
  padding-top: 0.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ===== LIVE INDICATOR ===== */
.live-dot {
  width: 10px;
  height: 10px;
  background-color: #ef4444;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 10px rgba(251, 191, 36, 0.2); }
  100% { transform: scale(1.02); box-shadow: 0 0 20px rgba(251, 191, 36, 0.4); }
}

.dash-card {
  transition: transform 0.3s ease;
}
.dash-card:hover {
  transform: translateY(-5px);
}
