/* Custom Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
  --bg-primary: #080c14;
  --bg-surface: rgba(16, 24, 48, 0.6);
  --bg-surface-hover: rgba(26, 36, 68, 0.8);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-active: rgba(255, 159, 28, 0.5);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  
  --color-gold: #ff9f1c;
  --color-gold-hover: #e08b15;
  --color-cyan: #2ec4b6;
  --color-red: #ff3366;
  --color-green: #4caf50;
  
  --court-wood: #22160d;
  --court-line: rgba(255, 255, 255, 0.9);
  --court-blue: #1d3557;
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 10% 20%, rgba(46, 196, 182, 0.05) 0px, transparent 50%),
    radial-gradient(at 90% 80%, rgba(255, 159, 28, 0.05) 0px, transparent 50%);
}

/* App Shell Layout */
.app-header {
  background: rgba(8, 12, 20, 0.8);
  backdrop-filter: blur(15px);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.club-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.club-title {
  display: flex;
  flex-direction: column;
}

.club-title h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.season-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-gold);
  font-weight: 600;
}

.club-stats {
  display: flex;
  gap: 1rem;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 99px;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: var(--transition-smooth);
}

.stat-pill.warning {
  border-color: var(--color-red);
  background: rgba(255, 51, 102, 0.1);
  color: var(--color-red);
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.stat-label {
  color: var(--text-secondary);
  font-weight: 400;
}

.app-main {
  flex: 1;
  padding: 1rem 1rem 5rem 1rem; /* bottom padding for PWA nav bar */
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.view-section {
  display: none;
  animation: fadeIn 0.4s ease-out forwards;
}

.view-section.active {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

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

/* Nav Bar (Mobile Bottom, Desktop adapts) */
.app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 15, 30, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  padding: 0.75rem 0;
  z-index: 100;
}

.nav-btn, .nav-btn-action {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  flex: 1;
}

.nav-btn svg, .nav-btn-action svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.nav-btn.active, .nav-btn-action.active {
  color: var(--color-gold);
}

/* Layout Utilities */
.grid-cols-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .grid-cols-2 {
    grid-template-columns: 1fr 1fr;
  }
  
  .app-main {
    padding-bottom: 2rem;
  }
  
  .app-nav {
    position: sticky;
    top: 0;
    bottom: auto;
    border-top: none;
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 15, 30, 0.8);
    justify-content: flex-end;
    padding: 0.5rem 2rem;
    gap: 1.5rem;
  }
  
  .nav-btn, .nav-btn-action {
    width: auto;
    flex: none;
    flex-direction: row;
    padding: 0.5rem 1rem;
    border-radius: 8px;
  }
  
  .nav-btn.active, .nav-btn-action.active {
    background: rgba(255, 159, 28, 0.1);
  }
}

/* Glassmorphism Panel */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.25rem;
  backdrop-filter: blur(10px);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.5rem;
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Form & Buttons */
.btn {
  background: var(--color-gold);
  color: #000;
  border: none;
  font-family: var(--font-sans);
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.btn:hover {
  background: var(--color-gold-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
  background: rgba(255, 51, 102, 0.1);
  color: var(--color-red);
  border: 1px solid rgba(255, 51, 102, 0.2);
}

.btn-danger:hover {
  background: rgba(255, 51, 102, 0.2);
}

.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 4px;
}

/* Card Lists */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 450px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

/* Custom Scrollbars */
.card-list::-webkit-scrollbar {
  width: 4px;
}

.card-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}

.card-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* Player Cards */
.player-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: var(--transition-smooth);
  cursor: grab;
}

.player-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
}

.player-card:active {
  cursor: grabbing;
}

.player-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.player-name-wrapper {
  display: flex;
  flex-direction: column;
}

.player-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.player-position {
  font-size: 0.75rem;
  color: var(--color-gold);
  font-weight: 500;
}

.player-contract {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: right;
}

.player-salary {
  font-weight: 600;
  color: var(--text-primary);
}

.player-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.15);
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-val {
  font-size: 0.85rem;
  font-weight: 600;
}

.stat-lbl {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.player-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* Court Schematic Styling */
.clipboard-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .clipboard-container {
    flex-direction: row;
  }
  
  .clipboard-container .court-section {
    flex: 1.4;
  }
  
  .clipboard-container .bench-section {
    flex: 1;
  }
}

.court-wrapper {
  background: linear-gradient(135deg, #121c33, #0a0f1d);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.volleyball-court {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1.5; /* Vertical court ratio */
  background: var(--court-blue);
  border: 4px solid var(--court-line);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: grid;
  grid-template-rows: 1fr 2px 1fr; /* Top Half, Net line, Bottom Half */
}

.court-half {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1.2fr 1fr;
  padding: 10px;
}

.court-net-line {
  background: var(--court-line);
  height: 2px;
  width: 100%;
  position: relative;
  z-index: 10;
}

.court-net-line::after {
  content: 'NET';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-gold);
  color: #000;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Court grid zones (Standard 6-player zone positions)
   We simplify it to 6 active court cards:
   Zone 1 (Back Right), Zone 2 (Front Right), Zone 3 (Front Center),
   Zone 4 (Front Left), Zone 5 (Back Left), Zone 6 (Back Center)
*/
.court-positions-grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  padding: 15px;
}

/* Attack Line */
.attack-line {
  position: absolute;
  width: 100%;
  height: 2px;
  border-top: 2px dashed rgba(255, 255, 255, 0.4);
  z-index: 2;
}

.top-attack-line {
  bottom: 33.33%;
}

/* Active Court Player Slot */
.court-slot {
  border: 2px dashed rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
  position: relative;
  transition: var(--transition-smooth);
}

.court-slot.drag-over {
  background: rgba(255, 159, 28, 0.15);
  border-color: var(--color-gold);
}

.court-slot.filled {
  background: rgba(16, 24, 48, 0.85);
  border: 1px solid var(--border-color);
  border-top: 4px solid var(--color-gold);
}

.slot-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  position: absolute;
  top: 6px;
  left: 8px;
}

.court-slot .empty-text {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
  font-weight: 500;
}

/* Court Slot Player Display */
.court-player-name {
  font-weight: 600;
  font-size: 0.8rem;
  text-align: center;
  margin-top: 0.5rem;
  word-break: break-word;
}

.court-player-position {
  font-size: 0.65rem;
  color: var(--color-gold);
  margin-top: 0.1rem;
}

.court-player-stats {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.court-player-stats span {
  margin: 0 2px;
}

.court-slot .remove-court-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 4px;
}

.court-slot .remove-court-btn:hover {
  color: var(--color-red);
  background: rgba(255, 51, 102, 0.1);
}

/* Lineup Alerts */
.validation-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
  width: 100%;
}

.validation-msg {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
}

.validation-msg.error {
  background: rgba(255, 51, 102, 0.1);
  color: var(--color-red);
  border: 1px solid rgba(255, 51, 102, 0.2);
}

.validation-msg.warning {
  background: rgba(255, 159, 28, 0.1);
  color: var(--color-gold);
  border: 1px solid rgba(255, 159, 28, 0.2);
}

.validation-msg.success {
  background: rgba(46, 196, 182, 0.1);
  color: var(--color-cyan);
  border: 1px solid rgba(46, 196, 182, 0.2);
}

/* Modal Renewal Dialog */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 200;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #101830;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.form-group label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
}

.form-group input, .form-group select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  padding: 0.6rem;
  outline: none;
  width: 100%;
  font-size: 0.9rem;
}

.form-group select option, select option {
  background-color: #0c1222 !important;
  color: #f8fafc !important;
}

.form-group input:focus {
  border-color: var(--color-gold);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  left: 1rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

@media (min-width: 480px) {
  .toast-container {
    left: auto;
    width: 320px;
  }
}

.toast {
  background: #141e3a;
  border-left: 4px solid var(--color-gold);
  border-top: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-size: 0.85rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transform: translateX(120%);
  animation: slideInLeft 0.3s forwards, fadeOut 0.3s 2.7s forwards;
}

.toast.success { border-left-color: var(--color-cyan); }
.toast.error { border-left-color: var(--color-red); }

@keyframes slideInLeft {
  to { transform: translateX(0); }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-10px); }
}

/* Utility to support tapping targets on mobile */
.tap-target-selected {
  border-color: var(--color-gold) !important;
  box-shadow: 0 0 10px rgba(255, 159, 28, 0.3);
}

/* Save Management Layout */
.save-management-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.save-management-layout textarea {
  transition: var(--transition-smooth);
}

.save-management-layout textarea:focus {
  border-color: var(--color-gold);
  box-shadow: 0 0 8px rgba(255, 159, 28, 0.25);
}

@media (min-width: 768px) {
  .save-management-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 2rem;
  }
}

/* Scouting Tab Comparison Layout */
.scouting-comparison-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.scouting-selectors {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
}

.scouting-vs-divider {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-gold);
  text-align: center;
  margin: 0.5rem 0;
  font-family: var(--font-sans);
  letter-spacing: 2px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scouting-vs-divider::before, .scouting-vs-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0 1rem;
}

.chart-container-wrapper {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-container {
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1;
}

@media (min-width: 768px) {
  .scouting-comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 2rem;
    align-items: center;
  }
  
  .scouting-selectors {
    gap: 1.5rem;
  }
}

/* Service Worker update notification overrides */
.toast.sw-update-toast {
  animation: slideInLeft 0.3s forwards !important;
  pointer-events: auto !important;
  border-left-color: var(--color-cyan) !important;
  background: #102035 !important;
}

/* Standings Table Styling */
.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  color: var(--text-primary);
  text-align: left;
  min-width: 600px;
}

.standings-table th, .standings-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.standings-table th {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.15);
}

.standings-table tbody tr {
  transition: var(--transition-smooth);
}

.standings-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* User Team Highlight */
.standings-table tr.user-team-row {
  background: rgba(255, 159, 28, 0.08) !important;
  color: var(--color-gold) !important;
  font-weight: 600;
}

.standings-table tr.user-team-row td {
  border-bottom: 1px solid rgba(255, 159, 28, 0.15);
}

/* Playoff Cutoff Indicator */
.standings-table tbody tr.playoff-spot-row {
  border-left: 4px solid var(--color-cyan);
}

.standings-table tbody tr.non-playoff-spot-row {
  border-left: 4px solid transparent;
}

/* Playoff Bracket Tree Layout */
.playoff-bracket-panel {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.bracket-container {
  display: flex;
  gap: 2rem;
  overflow-x: auto;
  padding: 1rem 0;
  scrollbar-width: thin;
}

.bracket-col {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 1.5rem;
  min-width: 200px;
  flex: 1;
}

.bracket-col-header {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--color-gold);
  font-weight: 800;
  text-align: center;
  margin-bottom: 0.5rem;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.25rem;
}

.playoff-match-card {
  background: rgba(16, 24, 48, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.playoff-match-card.user-involved {
  border-color: rgba(46, 196, 182, 0.4);
  box-shadow: 0 0 10px rgba(46, 196, 182, 0.1);
}

.playoff-match-team {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.playoff-match-team.winner {
  color: var(--text-primary);
  font-weight: 600;
}

.playoff-match-team.loser {
  color: var(--text-secondary);
  opacity: 0.6;
}

.playoff-match-score {
  font-weight: 700;
}

.playoff-match-winner-tag {
  font-size: 0.65rem;
  color: var(--color-gold);
  text-transform: uppercase;
  font-weight: 700;
  border-top: 1px dashed rgba(255, 255, 255, 0.05);
  padding-top: 0.25rem;
  text-align: center;
}

.icon-btn-edit {
  opacity: 0.6;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.icon-btn-edit:hover {
  opacity: 1;
  color: var(--color-cyan) !important;
}


