/* server/static/style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800;900&display=swap');

:root {
  --bg-color: #e9f2f7;
  --header-bg: #2c3e50;
  --header-text: #ecf0f1;
  --card-bg: #ffffff;
  --text-color: #34495e;
  --muted-text: #7f8c8d;
  --border-color: #e0e5e9;
  --accent-color: #3498db;
  --pts-color: #27ae60;
  --danger-color: #e74c3c;
  --warning-color: #f1c40f;
  --semifinal-color: #9b59b6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  padding: 20px;
  padding-bottom: 60px;
}

header {
  text-align: center;
  margin: 0 auto 30px;
  max-width: 1000px;
  background: var(--header-bg);
  color: var(--header-text);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,.1);
  text-transform: uppercase;
}
h1 {
  font-size: 2.2em;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--header-text);
  text-shadow: 2px 2px 4px rgba(0,0,0,.3);
}

/* ====== PANELS ====== */
.panel {
  display: none;
  max-width: 1000px;
  margin: 0 auto;
}
.panel.active { display: block; }

/* ====== LIVE ====== */
.live-card {
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}
.live-status {
  text-align: center;
  font-size: 1.3em;
  font-weight: bold;
  background: #ff5722;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 20px;
  animation: pulse 2s infinite;
}
.live-status.halftime { background: #ff9800; animation: none; }
.live-status.semifinal { background: #9c27b0; }
.live-status.final { background: #e91e63; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .7; }
}

.score-board {
  display: flex;
  justify-content: space-around;
  align-items: center;
  text-align: center;
  gap: 10px;
}
.team-name {
  font-size: 1.6em;
  font-weight: bold;
  flex: 1;
  word-break: break-word;
}
.score {
  font-size: 4em;
  font-weight: bold;
  color: #ffeb3b;
  padding: 0 10px;
  white-space: nowrap;
}

.events {
  margin-top: 25px;
  background: rgba(0,0,0,.25);
  border-radius: 8px;
  padding: 15px;
  max-height: 300px;
  overflow-y: auto;
}
.events h3 { margin-bottom: 10px; color: #ffeb3b; }
.event-item {
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,.15);
}
.event-item:last-child { border-bottom: none; }
.event-item.goal { color: #4caf50; font-weight: bold; }
.event-item.ht { color: #ff9800; font-style: italic; }

.live-signal-area {
  position: relative;
  min-height: 180px;
  margin-top: 10px;
  user-select: none;
}
.live-signal-zone {
  position: absolute;
  height: 90px;
  width: 50%;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  opacity: 0;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.live-signal-zone.top { top: 0; }
.live-signal-zone.bottom { top: 90px; }
.live-signal-zone.left { left: 0; }
.live-signal-zone.right { right: 0; }
.live-signal-zone:hover,
.live-signal-zone:active,
.live-signal-zone:focus {
  background: transparent;
  opacity: 0;
  outline: none;
  transform: none;
}
.admin-signal-label {
  margin-top: 14px;
  text-align: center;
  font-size: 2.4em;
  font-weight: 900;
  color: #ffeb3b;
  letter-spacing: .08em;
}

.no-match {
  text-align: center;
  padding: 60px 20px;
  opacity: .7;
  font-size: 1.2em;
  background: rgba(255,255,255,.1);
  border-radius: 12px;
}

/* ====== TABLE ====== */
.table-wrap {
  overflow-x: auto;
  background: rgba(255,255,255,.1);
  border-radius: 12px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}
th, td {
  padding: 12px 8px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
th { background: rgba(0,0,0,.3); color: #ffeb3b; }
th.left, td.team-cell { text-align: left; padding-left: 16px; }
tr:hover { background: rgba(255,255,255,.05); }

/* ====== HISTORY ====== */
.day-group { margin-bottom: 18px; }
.day-header {
  background: #ff5722;
  padding: 12px 18px;
  border-radius: 8px 8px 0 0;
  font-size: 1.15em;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.day-header:hover { background: #e64a19; }
.day-matches {
  background: rgba(255,255,255,.08);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}
.match-row {
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 15px;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.1);
  cursor: pointer;
  transition: background .2s;
}
.match-row:hover { background: rgba(255,255,255,.1); }
.match-row:last-child { border-bottom: none; }
.match-team { font-weight: bold; word-break: break-word; }
.match-team.left { text-align: right; }
.match-team.right { text-align: left; }
.match-score {
  font-size: 1.4em;
  font-weight: bold;
  color: #ffeb3b;
  background: rgba(0,0,0,.3);
  padding: 4px 12px;
  border-radius: 6px;
  white-space: nowrap;
}
.match-badge {
  background: #9c27b0;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: .8em;
  white-space: nowrap;
}
.match-badge.final { background: #e91e63; }

.match-details {
  background: rgba(0,0,0,.3);
  padding: 15px 20px;
  display: none;
  border-top: 1px solid rgba(255,255,255,.15);
  font-size: .95em;
}
.match-details.open { display: block; }
.match-details .event { padding: 4px 0; }

.collapsed .day-matches { display: none; }
.chevron { display: inline-block; transition: transform .3s; }
.collapsed .chevron { transform: rotate(-90deg); }

/* ====== BOTTOM BAR ====== */
.bottom-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.bottom-actions button {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  font-weight: bold;
}
.bottom-actions [data-tab].active { background: #ff5722; }

/* ====== FOOTER ====== */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 10px 12px;
  background: rgba(0,0,0,.5);
  font-size: .85em;
}
#conn-status.ok { color: #4caf50; }
#conn-status.fail { color: #f44336; }

/* ====== MOBILE ====== */
@media (max-width: 600px) {
  h1 { font-size: 1.5em; }
  .team-name { font-size: 1.1em; }
  .score { font-size: 2.8em; }
  .bottom-actions button { padding: 8px 14px; font-size: .9em; }
  .match-row { grid-template-columns: 1fr auto 1fr; }
  .match-row .match-badge { grid-column: 1 / -1; text-align: center; margin-top: 5px; }
}

/* ============== TOP BUTTONS ============== */
.top-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.top-btn {
  display: inline-block;
  padding: 8px 16px;
  background: rgba(255,255,255,.15);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: bold;
  transition: background .2s;
}
.top-btn:hover { background: rgba(255,255,255,.28); }
.top-btn.admin { background: #ff5722; }
.top-btn.admin:hover { background: #e64a19; }

/* ============== LOGIN FORMS ============== */
.login-box {
  max-width: 380px;
  margin: 40px auto;
  background: rgba(255,255,255,.1);
  padding: 30px;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}
.login-box label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  color: #ffeb3b;
}
.login-box input[type=password] {
  width: 100%;
  padding: 12px;
  font-size: 1em;
  border: none;
  border-radius: 8px;
  margin-bottom: 14px;
  background: rgba(0,0,0,.3);
  color: #fff;
}
.login-box button {
  width: 100%;
  padding: 12px;
  background: #ff5722;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  font-size: 1em;
  cursor: pointer;
}
.login-box button:hover { background: #e64a19; }
.login-error {
  background: rgba(244,67,54,.25);
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 12px;
  text-align: center;
}
.back-link {
  display: block;
  text-align: center;
  margin-top: 18px;
  color: #ffeb3b;
  text-decoration: none;
}

/* ============== ADMIN PANEL ============== */
.admin-wrap {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.admin-card {
  background: rgba(255,255,255,.1);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.admin-card h2 {
  margin-bottom: 14px;
  color: #ffeb3b;
  font-size: 1.2em;
}

.form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.form-row input[type=text],
.form-row input[type=file],
.form-row select {
  flex: 1;
  min-width: 140px;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: rgba(0,0,0,.3);
  color: #fff;
  font-size: 1em;
}
.form-row select option { background: #1e3c72; }
.vs { font-weight: bold; color: #ffeb3b; padding: 0 5px; }

/* ============== BUTTONS ============== */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  color: #fff;
  background: #607d8b;
  transition: filter .15s, transform .05s;
  font-size: .95em;
}
.btn:hover  { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn.primary { background: #2196f3; }
.btn.goal    { background: #4caf50; font-size: 1.05em; padding: 14px 18px; flex: 1; }
.btn.warn    { background: #ff9800; }
.btn.ok      { background: #4caf50; }
.btn.undo    { background: #9c27b0; }
.btn.danger  { background: #f44336; }
.btn.small   { padding: 5px 10px; font-size: .85em; }

/* ============== MATCH CONTROLS ============== */
.goal-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.extra-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============== MINI SCOREBOARD IN ADMIN ============== */
.mini-board {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(0,0,0,.3);
  border-radius: 10px;
  padding: 16px;
  gap: 10px;
  text-align: center;
}
.mb-team {
  flex: 1;
  font-size: 1.15em;
  font-weight: bold;
  word-break: break-word;
}
.mb-score {
  font-size: 2.2em;
  font-weight: bold;
  color: #ffeb3b;
  white-space: nowrap;
  padding: 0 10px;
}
.mb-status {
  text-align: center;
  margin-top: 10px;
  color: #ff9800;
  font-weight: bold;
}
.mb-events {
  margin-top: 12px;
  max-height: 180px;
  overflow-y: auto;
  background: rgba(0,0,0,.2);
  border-radius: 8px;
  padding: 10px;
  font-size: .92em;
}
.mb-events div {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.mb-events div:last-child { border-bottom: none; }

/* ============== TEAMS LIST ============== */
.teams-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.team-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(0,0,0,.25);
  border-radius: 8px;
}
.t-logo {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  background: rgba(255,255,255,.1);
}
.t-logo.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3em;
  opacity: .6;
}
.t-name { flex: 1; font-weight: bold; }

/* ============== ADMIN HISTORY ============== */
#admin-history {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(0,0,0,.25);
  border-radius: 8px;
  flex-wrap: wrap;
}
.hist-ts {
  font-size: .85em;
  opacity: .75;
  min-width: 130px;
}
.hist-match {
  flex: 1;
  font-weight: 500;
}
.hist-match b { color: #ffeb3b; padding: 0 4px; }

/* ============== TOURNAMENT TABS ============== */
.tour-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 10px 0;
}
.tour-tab {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  color: #fff;
  background: rgba(255,255,255,.15);
  font-size: 1em;
  font-family: inherit;
  transition: background .2s;
}
.tour-tab:hover { background: rgba(255,255,255,.28); }
.tour-tab.active { background: #ff5722; }

/* ============== TOAST ============== */
#toast {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #333;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: bold;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  opacity: 0;
  transition: transform .25s, opacity .25s;
  z-index: 999;
  max-width: 90vw;
  text-align: center;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.ok   { background: #2e7d32; }
#toast.fail { background: #c62828; }

/* ============== MOBILE ============== */
@media (max-width: 600px) {
  .admin-card { padding: 16px; }
  .mb-score { font-size: 1.7em; }
  .mb-team { font-size: 1em; }
  .btn.goal { font-size: 1em; padding: 12px; }
  .hist-ts { min-width: auto; width: 100%; }
}

/* ============== LIGHT TOURNAMENT THEME OVERRIDES ============== */
body {
  background: var(--bg-color);
  color: var(--text-color);
}

header {
  background: var(--header-bg);
  color: var(--header-text);
  box-shadow: 0 4px 15px rgba(0,0,0,.1);
}

.table-wrap,
.live-card,
.admin-card,
.login-box,
.no-match {
  background: var(--card-bg);
  color: var(--text-color);
  box-shadow: 0 4px 20px rgba(0,0,0,.08);
}

th {
  background: var(--header-bg);
  color: #fff;
  text-transform: uppercase;
  font-weight: 700;
}

td, th {
  border-bottom: 1px solid var(--border-color);
}

tr:hover { background: #f7f9fb; }

.score,
.mb-score,
.match-score,
.hist-match b,
.admin-signal-label {
  color: var(--header-bg);
}

.events,
.mb-events,
.day-matches,
.match-details,
.team-item,
.hist-row,
.mini-board {
  background: #f7f9fb;
  color: var(--text-color);
}

.events h3,
.admin-card h2,
.login-box label,
.vs,
.mb-status {
  color: var(--header-bg);
}

.event-item,
.mb-events div,
.match-row {
  border-bottom-color: var(--border-color);
}

.event-item.goal { color: var(--pts-color); }
.event-item.ht { color: #d4a20b; }

.day-header,
.tour-tab.active,
.bottom-actions [data-tab].active,
.top-btn.admin,
.btn.primary {
  background: var(--accent-color);
  color: #fff;
}

.day-header:hover,
.top-btn.admin:hover {
  background: #2b84bd;
}

.match-badge { background: var(--semifinal-color); }
.match-badge.final {
  background: var(--warning-color);
  color: var(--header-bg);
}

.live-status {
  background: var(--header-bg);
  color: var(--header-text);
}
.live-status.halftime {
  background: var(--warning-color);
  color: var(--header-bg);
}
.live-status.semifinal { background: var(--semifinal-color); }
.live-status.final {
  background: var(--warning-color);
  color: var(--header-bg);
}

.top-btn,
.tour-tab {
  background: #ffffff;
  color: var(--header-bg);
  box-shadow: 0 2px 5px rgba(0,0,0,.06);
}
.top-btn:hover,
.tour-tab:hover {
  background: #f7f9fb;
}

footer {
  background: rgba(44,62,80,.94);
  color: var(--header-text);
}

.form-row input[type=text],
.form-row input[type=file],
.form-row select,
.login-box input[type=password] {
  background: #f7f9fb;
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.form-row select option { background: #ffffff; color: var(--text-color); }

.btn.goal { background: var(--pts-color); }
.btn.warn { background: var(--warning-color); color: var(--header-bg); }
.btn.ok { background: var(--pts-color); }
.btn.undo { background: var(--semifinal-color); }
.btn.danger { background: var(--danger-color); }
