/* =====================================================================
   Bracket Arena — Base / Shared Styles
   Modern dark esports-inspired design system
   ===================================================================== */

:root {
  --bg-0: #0a0e17;
  --bg-1: #0f1420;
  --bg-2: #141b2b;
  --bg-3: #1a2236;
  --border: #232c42;
  --border-light: #2e3a56;
  --text-0: #f5f7fb;
  --text-1: #c4cbdb;
  --text-2: #8993ab;
  --accent-blue: #4f7cff;
  --accent-purple: #9b5cff;
  --accent-gradient: linear-gradient(135deg, #4f7cff 0%, #9b5cff 100%);
  --accent-green: #2fd67f;
  --accent-red: #ff5470;
  --accent-yellow: #ffb84f;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 4px 18px rgba(0, 0, 0, 0.28);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(79, 124, 255, 0.10), transparent 45%),
    radial-gradient(circle at 85% 20%, rgba(155, 92, 255, 0.10), transparent 45%);
  min-height: 100vh;
}

a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0 0 8px; color: var(--text-1); }

.brand-mark { font-size: 28px; filter: drop-shadow(0 0 12px rgba(79,124,255,.6)); }

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 6px 18px rgba(79, 124, 255, 0.35);
}
.btn-secondary {
  background: var(--bg-3);
  color: var(--text-0);
  border-color: var(--border-light);
}
.btn-ghost {
  background: transparent;
  color: var(--text-1);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-2); color: var(--text-0); }
.btn-danger {
  background: rgba(255, 84, 112, 0.12);
  color: var(--accent-red);
  border-color: rgba(255, 84, 112, 0.3);
}
.btn-danger:hover { background: rgba(255, 84, 112, 0.22); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */
.form-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-1);
  font-weight: 600;
}
.form-input {
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text-0);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.18);
}
.form-input:disabled { opacity: .5; }
.form-hint { font-size: 12px; color: var(--text-2); font-weight: 400; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.form-span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.stack-form.is-disabled { opacity: .6; }
.input-copy-group { display: flex; gap: 8px; }
.input-copy-group .form-input { flex: 1; }

/* ---------------------------------------------------------------------
   Alerts / Badges
   --------------------------------------------------------------------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-error, .alert-danger { background: rgba(255,84,112,.1); color: #ff8aa1; border-color: rgba(255,84,112,.25); }
.alert-success { background: rgba(47,214,127,.1); color: #6fe6a4; border-color: rgba(47,214,127,.25); }
.alert-info { background: rgba(79,124,255,.1); color: #9db4ff; border-color: rgba(79,124,255,.25); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-draft { background: rgba(137,147,171,.15); color: var(--text-2); }
.badge-upcoming { background: rgba(255,184,79,.15); color: var(--accent-yellow); }
.badge-live { background: rgba(47,214,127,.15); color: var(--accent-green); }
.badge-finished { background: rgba(79,124,255,.15); color: var(--accent-blue); }
.badge-status { background: rgba(155,92,255,.18); color: #c9adff; }

/* ---------------------------------------------------------------------
   Modals
   --------------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4,6,12,.7);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-overlay.is-open { display: flex; animation: fadeIn .15s ease; }
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 480px;
  box-shadow: var(--shadow-soft);
  animation: modalPop .18s ease;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; }
.modal-close { background: none; border: none; color: var(--text-2); font-size: 22px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text-0); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ---------------------------------------------------------------------
   Toasts
   --------------------------------------------------------------------- */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 340px;
}
.toast {
  background: var(--bg-3);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--accent-blue);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-0);
  font-size: 13.5px;
  box-shadow: var(--shadow-card);
  animation: slideIn .2s ease;
}
.toast.toast-success { border-left-color: var(--accent-green); }
.toast.toast-error { border-left-color: var(--accent-red); }
.toast.toast-fading { animation: fadeOut .3s ease forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(20px); } }

/* ---------------------------------------------------------------------
   Share buttons / QR
   --------------------------------------------------------------------- */
.share-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.share-btn {
  padding: 10px; text-align: center; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 13.5px; color: #fff !important;
}
.share-whatsapp { background: #25D366; }
.share-telegram { background: #229ED9; }
.share-facebook { background: #1877F2; }
.share-twitter { background: #14171A; }
.qr-wrap { text-align: center; }
.qr-wrap img { border-radius: var(--radius-sm); background: #fff; padding: 8px; }

/* ---------------------------------------------------------------------
   Auth screen
   --------------------------------------------------------------------- */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--bg-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-soft);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.auth-brand h1 { font-size: 22px; margin: 0; }
.auth-subtitle { color: var(--text-2); margin-bottom: 20px; font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-footnote { text-align: center; margin-top: 20px; font-size: 12.5px; color: var(--text-2); }

/* ---------------------------------------------------------------------
   Public tournament page
   --------------------------------------------------------------------- */
.public-body { padding-bottom: 40px; }

.public-banner {
  background-size: cover; background-position: center;
  position: relative;
  border-bottom: 1px solid var(--border);
}
.public-banner-overlay {
  background: linear-gradient(180deg, rgba(10,14,23,.55) 0%, rgba(10,14,23,.92) 100%);
  padding: 40px 24px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  flex-wrap: wrap;
}
.public-banner-content { display: flex; align-items: center; gap: 18px; }
.public-tournament-logo {
  width: 72px; height: 72px; border-radius: var(--radius-md);
  object-fit: cover; border: 1px solid var(--border-light);
  background: var(--bg-2);
}
.public-tournament-name { font-size: 30px; margin-bottom: 8px; }
.public-meta-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.meta-chip {
  background: var(--bg-3); border: 1px solid var(--border-light);
  padding: 4px 12px; border-radius: 999px; font-size: 12.5px; color: var(--text-1);
}

.public-main { max-width: 1400px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }

.champion-banner {
  background: linear-gradient(135deg, rgba(255,184,79,.15), rgba(155,92,255,.12));
  border: 1px solid rgba(255,184,79,.4);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  display: flex; align-items: center; gap: 18px;
  animation: glow 2.5s ease-in-out infinite;
}
.champion-trophy { font-size: 46px; }
.champion-label { margin: 0; font-size: 12px; letter-spacing: .12em; color: var(--accent-yellow); font-weight: 700; }
.champion-name { margin: 4px 0 0; font-size: 26px; }
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 rgba(255,184,79,0); }
  50% { box-shadow: 0 0 30px rgba(255,184,79,.25); }
}

.panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.panel-head h2 { font-size: 17px; margin: 0; }

.live-indicator { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--accent-green); font-weight: 600; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-green); animation: pulse 1.4s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(47,214,127,.6); }
  70% { box-shadow: 0 0 0 8px rgba(47,214,127,0); }
  100% { box-shadow: 0 0 0 0 rgba(47,214,127,0); }
}

.public-footer { text-align: center; color: var(--text-2); font-size: 13px; padding: 30px 0 10px; }

.not-found-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; text-align: center; gap: 10px; padding: 20px;
}

/* Skeleton loaders */
.skeleton-bracket { display: flex; gap: 40px; padding: 20px 0; }
.skeleton-col { display: flex; flex-direction: column; gap: 20px; justify-content: center; }
.skeleton-card {
  width: 220px; height: 70px; border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-2) 37%, var(--bg-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty-state p { margin-bottom: 14px; }

.standings-table { width: 100%; border-collapse: collapse; }
.standings-table th, .standings-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.standings-table th { color: var(--text-2); font-weight: 600; text-transform: uppercase; font-size: 11.5px; letter-spacing: .04em; }
.standings-table tr:first-child td { color: var(--accent-yellow); font-weight: 700; }

@media (max-width: 720px) {
  .public-banner-overlay { flex-direction: column; align-items: flex-start; }
  .public-tournament-name { font-size: 24px; }
  .share-buttons { grid-template-columns: 1fr; }
}
