/* ==========================================================================
   SPORTi Court Timetable & Game Score Manager Stylesheet
   Design Theme: Clean Light Slate + High-Contrast Typography + Vibrant Accents
   ========================================================================== */

:root {
  --color-primary: #f72585;       /* SPORTi Pink */
  --color-secondary: #0072ff;     /* SPORTi Royal Blue */
  --color-indigo: #7209b7;        /* SPORTi Purple */
  --color-emerald: #10b981;       /* Live Green */
  --color-amber: #f59e0b;         /* Warmup Amber */
  --color-slate-50: #f8fafc;
  --color-slate-100: #f1f5f9;
  --color-slate-200: #e2e8f0;
  --color-slate-300: #cbd5e1;
  --color-slate-400: #94a3b8;
  --color-slate-500: #64748b;
  --color-slate-600: #475569;
  --color-slate-700: #334155;
  --color-slate-800: #1e293b;
  --color-slate-900: #0f172a;
  
  --bg-page: var(--color-slate-50);
  --bg-card: #ffffff;
  --border-color: rgba(15, 23, 42, 0.08);

  --brand-gradient: linear-gradient(135deg, var(--color-secondary) 0%, var(--color-indigo) 50%, var(--color-primary) 100%);
  --live-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.08);
  
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-brand: 'Outfit', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
}

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

body {
  background-color: var(--bg-page);
  color: var(--color-slate-800);
  font-family: var(--font-ui);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ==========================================================================
   TOP NAVIGATION HEADER
   ========================================================================== */

.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1700px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.brand-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.brand-text {
  font-family: var(--font-brand);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-slate-900);
  letter-spacing: -0.5px;
}

.brand-text span {
  color: var(--color-primary);
}

.header-divider {
  color: var(--color-slate-300);
  font-size: 1.4rem;
  font-weight: 300;
}

.page-title {
  font-family: var(--font-brand);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-slate-800);
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-title i {
  color: var(--color-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Event Selector Box */
.event-selector-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-slate-50);
  border: 1px solid var(--color-slate-200);
  padding: 4px 6px 4px 12px;
  border-radius: var(--radius-pill);
}

.event-code-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.event-icon {
  color: var(--color-indigo);
  font-size: 0.9rem;
}

.event-code-input {
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-slate-900);
  width: 160px;
  outline: none;
}

.event-code-input::placeholder {
  font-family: var(--font-ui);
  font-weight: 400;
  color: var(--color-slate-400);
  font-size: 0.85rem;
}

.event-btn {
  background: var(--brand-gradient);
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.event-btn:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.active-events-select {
  border: 1px solid var(--color-slate-200);
  background: #ffffff;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--color-slate-700);
  outline: none;
  cursor: pointer;
}

/* Nav Shortcuts */
.nav-shortcuts {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shortcut-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: #ffffff;
  border: 1px solid var(--color-slate-200);
  border-radius: var(--radius-md);
  color: var(--color-slate-700);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}

.shortcut-btn:hover {
  border-color: var(--color-secondary);
  color: var(--color-secondary);
  background: rgba(0, 114, 255, 0.03);
}

.shortcut-btn.secondary {
  background: var(--color-slate-100);
  border-color: transparent;
  color: var(--color-slate-700);
}

.shortcut-btn.secondary:hover {
  background: var(--color-slate-200);
}

/* ==========================================================================
   META STATS BAR
   ========================================================================== */

.meta-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 10px 24px;
}

.meta-inner {
  max-width: 1700px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.event-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.event-code-badge {
  background: rgba(0, 114, 255, 0.08);
  border: 1px solid rgba(0, 114, 255, 0.18);
  color: var(--color-secondary);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tournament-state-pill {
  background: var(--color-slate-100);
  color: var(--color-slate-700);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.team-clash-pill {
  background: linear-gradient(135deg, rgba(114, 9, 183, 0.12) 0%, rgba(247, 37, 133, 0.12) 100%);
  border: 1px solid rgba(114, 9, 183, 0.25);
  color: var(--color-indigo);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hidden {
  display: none !important;
}

.stats-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stat-pill {
  background: var(--color-slate-50);
  border: 1px solid var(--color-slate-200);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  color: var(--color-slate-600);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-pill strong {
  color: var(--color-slate-900);
  font-weight: 700;
}

.stat-pill.live-pill {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.2);
  color: #047857;
}

.stat-pill.live-pill strong {
  color: #065f46;
}

.stat-pill.completed-pill {
  background: rgba(114, 9, 183, 0.08);
  border-color: rgba(114, 9, 183, 0.2);
  color: var(--color-indigo);
}

/* ==========================================================================
   TOOLBAR SECTION
   ========================================================================== */

.toolbar-section {
  background: var(--color-slate-100);
  border-bottom: 1px solid var(--color-slate-200);
  padding: 12px 24px;
}

.toolbar-inner {
  max-width: 1700px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-slate-400);
  font-size: 0.9rem;
}

.search-input {
  width: 100%;
  padding: 8px 36px 8px 36px;
  background: #ffffff;
  border: 1px solid var(--color-slate-300);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--color-slate-800);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(0, 114, 255, 0.12);
}

.clear-search-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-slate-400);
  cursor: pointer;
  padding: 4px;
}

.clear-search-btn:hover {
  color: var(--color-slate-700);
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-slate-600);
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-select {
  background: #ffffff;
  border: 1px solid var(--color-slate-300);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--color-slate-800);
  outline: none;
  cursor: pointer;
}

.filter-select:focus {
  border-color: var(--color-secondary);
}

.refresh-btn {
  background: #ffffff;
  border: 1px solid var(--color-slate-300);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-slate-700);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.refresh-btn:hover {
  background: var(--color-slate-50);
  color: var(--color-slate-900);
  border-color: var(--color-slate-400);
}

/* ==========================================================================
   TIMETABLE MAIN AREA & COURT COLUMNS
   ========================================================================== */

.timetable-main {
  flex: 1;
  padding: 24px;
  overflow-x: auto;
}

.timetable-state-box {
  display: none !important;
  max-width: 500px;
  margin: 60px auto;
  text-align: center;
  background: #ffffff;
  padding: 40px 30px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

.state-icon {
  font-size: 3rem;
  color: var(--color-secondary);
  margin-bottom: 16px;
}

.state-title {
  font-family: var(--font-brand);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-slate-900);
  margin-bottom: 8px;
}

.state-desc {
  font-size: 0.95rem;
  color: var(--color-slate-500);
  line-height: 1.6;
}

/* Timetable Columns Container */
.timetable-columns-container {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  min-width: min-content;
  padding-bottom: 20px;
}

/* Individual Court Column */
.court-column {
  background: #ffffff;
  border: 1px solid var(--color-slate-200);
  border-radius: var(--radius-lg);
  width: 340px;
  min-width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.court-column-header {
  background: linear-gradient(135deg, #ffffff 0%, var(--color-slate-50) 100%);
  border-bottom: 1px solid var(--color-slate-200);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.court-title-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.court-icon-box {
  width: 34px;
  height: 34px;
  background: rgba(0, 114, 255, 0.08);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-secondary);
  font-size: 1rem;
}

.court-name {
  font-family: var(--font-brand);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-slate-900);
}

.court-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.court-games-count {
  background: var(--color-slate-100);
  color: var(--color-slate-600);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.court-completed-badge {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  gap: 4px;
}

.court-live-indicator {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  gap: 4px;
  text-transform: uppercase;
}

.court-live-indicator .pulse-dot {
  width: 6px;
  height: 6px;
  background-color: var(--color-emerald);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.2); }
  100% { opacity: 1; transform: scale(1); }
}

.court-games-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
}

.court-games-list::-webkit-scrollbar {
  width: 6px;
}

.court-games-list::-webkit-scrollbar-thumb {
  background-color: var(--color-slate-300);
  border-radius: 4px;
}

/* ==========================================================================
   GAME CARD STYLES
   ========================================================================== */

.game-card {
  background: #ffffff;
  border: 1px solid var(--color-slate-200);
  border-radius: var(--radius-md);
  padding: 14px;
  transition: all 0.2s ease;
  position: relative;
}

.game-card:hover {
  border-color: var(--color-slate-300);
  box-shadow: var(--shadow-md);
}

.game-card.status-live {
  border-left: 4px solid var(--color-emerald);
  background: linear-gradient(135deg, #ffffff 0%, rgba(16, 185, 129, 0.02) 100%);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.08);
}

.game-card.status-warmup {
  border-left: 4px solid var(--color-amber);
}

.game-card.status-completed,
.game-card.is-completed {
  border-left: 4px solid #10b981;
  background: linear-gradient(135deg, #ffffff 0%, rgba(16, 185, 129, 0.03) 100%);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.06);
}

.completed-marker-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.28);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.completed-marker-bar i {
  font-size: 0.85rem;
  color: #10b981;
}

.game-card.status-pending {
  border-left: 4px solid var(--color-slate-300);
}

.game-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--color-slate-200);
}

.round-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-slate-600);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status-badge.live {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.status-badge.warmup {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.status-badge.pending {
  background: var(--color-slate-100);
  color: var(--color-slate-600);
  border: 1px solid var(--color-slate-200);
}

.status-badge.completed {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Team Rows */
.teams-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.team-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: var(--color-slate-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-slate-100);
  gap: 8px;
}

.team-row.winner {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.2);
}

.team-info-box {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.team-color-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  flex-shrink: 0;
}

.badge-red {
  background: rgba(247, 37, 133, 0.15);
  color: #be185d;
}

.badge-blue {
  background: rgba(0, 114, 255, 0.15);
  color: #1d4ed8;
}

.team-names {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-slate-800);
  word-break: break-word;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: none;
}

.team-names .partner-name {
  color: var(--color-slate-600);
  font-weight: 500;
  text-shadow: none;
}

.winner-icon {
  color: #eab308;
  font-size: 0.8rem;
  margin-left: 2px;
  display: inline-block;
}

/* Score Input Controls */
.score-control-box {
  display: flex;
  align-items: center;
  gap: 4px;
}

.score-step-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--color-slate-300);
  background: #ffffff;
  color: var(--color-slate-700);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s ease;
}

.score-step-btn:hover {
  background: var(--color-slate-200);
}

.score-number-input {
  width: 38px;
  height: 28px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-slate-900);
  background: #ffffff;
  border: 1px solid var(--color-slate-300);
  border-radius: var(--radius-sm);
  outline: none;
}

.score-number-input:focus {
  border-color: var(--color-secondary);
}

/* Card Controls Footer */
.card-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-slate-100);
}

.status-select-input {
  flex: 1;
  padding: 4px 8px;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--color-slate-700);
  background: #ffffff;
  border: 1px solid var(--color-slate-300);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

.save-score-btn {
  background: var(--brand-gradient);
  color: #ffffff;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.15s ease;
}

.save-score-btn:hover {
  opacity: 0.9;
}

.scorer-link-btn {
  background: var(--color-slate-100);
  color: var(--color-slate-700);
  border: none;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.scorer-link-btn:hover {
  background: var(--color-slate-200);
  color: var(--color-slate-900);
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  background: var(--color-slate-900);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideUp 0.2s ease forwards;
}

.toast.toast-success {
  border-left: 4px solid var(--color-emerald);
}

.toast.toast-error {
  border-left: 4px solid var(--color-primary);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 768px) {
  .app-header {
    padding: 10px 14px;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .toolbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    max-width: 100%;
  }

  .timetable-columns-container {
    flex-direction: column;
    width: 100%;
  }

  .court-column {
    width: 100%;
    min-width: 100%;
  }
}
