/* BASIC RESET & SETUP */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:root {
  --field-green: #2d5a1b;
  --field-green-dark: #1e3d12;
  --field-line: rgba(255,255,255,0.25);
  --end-zone-offense: rgba(30,80,200,0.3);
  --end-zone-defense: rgba(200,30,30,0.3);
  --los-color: #f0c040;
  --offense-blue: #1a56db;
  --defense-red: #c0392b;
  --ui-bg: #111827;
  --ui-surface: #1f2937;
  --ui-surface-hover: #374151;
  --ui-border: #374151;
  --ui-text: #f9fafb;
  --ui-text-muted: #9ca3af;
  --accent: #10b981;
  --accent-hover: #059669;
  --selected-glow: #fbbf24;
  --toolbar-bg: #0f172a;
  --sidebar-bg: #111827;

  --header-h: 48px;
  --toolbar-h: 52px;
  --anim-bar-h: 56px;
  --sidebar-w: 260px;
  --formations-w: 200px;
}

body {
    font-family: 'Barlow Condensed', sans-serif;
    background-color: var(--ui-bg);
    color: var(--ui-text);
    display: grid;
    grid-template-rows: var(--header-h) var(--toolbar-h) 1fr var(--anim-bar-h);
    grid-template-columns: var(--sidebar-w) 1fr var(--formations-w);
    height: 100vh;
    overflow: hidden;
}

/* When formations panel is collapsed, remove the right column to give canvas more room */
body.formations-collapsed {
    grid-template-columns: var(--sidebar-w) 1fr 0px;
}
body.formations-collapsed #formations-panel {
    width: 0;
    overflow: hidden;
    min-width: 0;
    border: none;
    padding: 0;
}

/* When sidebar is collapsed, shrink the left column */
body.sidebar-collapsed {
    grid-template-columns: 60px 1fr var(--formations-w);
}
body.sidebar-collapsed #sidebar {
    width: 60px;
    overflow: hidden;
}
body.sidebar-collapsed #sidebar-inner {
    opacity: 0;
    pointer-events: none;
}

/* HEADER */
#header {
    grid-column: 1 / -1;
    grid-row: 1;
    background-color: var(--toolbar-bg);
    border-bottom: 1px solid var(--ui-border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
}

#team-logo-wrap {
    width: 32px;
    height: 32px;
}

#team-logo {
    max-width: 100%;
    max-height: 100%;
}

#team-name {
    font-weight: 700;
    font-size: 1.2rem;
}

#play-name-wrap {
    flex-grow: 1;
    text-align: center;
}

#play-name-input {
    background: none;
    border: none;
    color: var(--ui-text);
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    width: 100%;
    padding: 4px;
    border-radius: 4px;
}

#play-name-input:focus {
    outline: none;
    background-color: var(--ui-surface);
}

#save-indicator {
    color: var(--accent);
    font-weight: 700;
    opacity: 0;
    transition: opacity 0.3s;
}

/* MAIN CONTENT */
#main-content {
    grid-column: 1 / -1;
    grid-row: 3;
    display: flex;
    overflow: hidden;
}

#canvas-wrap {
    flex-grow: 1;
    position: relative;
    background-color: var(--field-green-dark);
    background-image:
        radial-gradient(var(--field-green) 1px, transparent 1px),
        radial-gradient(var(--field-green) 1px, var(--field-green-dark) 1px);
    background-size: 4px 4px;
    background-position: 0 0, 2px 2px;
}

#field-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* TOAST */
#toast {
    position: fixed;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--accent);
    color: white;
    padding: 12px 24px;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 1001;
    font-size: 1rem;
    font-weight: 600;
}

/* CONTEXT MENU */
#context-menu {
    position: fixed;
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: 6px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    z-index: 1000;
    padding: 8px 0;
    min-width: 180px;
}

#context-menu ul {
    list-style: none;
}

#context-menu li {
    padding: 8px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

#context-menu li:hover {
    background-color: var(--ui-surface-hover);
}
#context-menu li.separator {
    height: 1px;
    background-color: var(--ui-border);
    margin: 8px 0;
    padding: 0;
}
#context-menu li.danger {
  color: #f87171;
}

/* WAYPOINT BALL ACTION MENU */
#waypoint-ball-menu {
  box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}
#waypoint-ball-menu li {
  transition: background-color 0.1s;
}
#waypoint-ball-menu li:hover {
  background-color: rgba(255,255,255,0.1);
  color: #fff;
}

/* UNIFIED TIMELINE PANEL */
#timeline-panel, #unified-timeline {
  grid-row: 4;
  grid-column: 1 / -1;
  background: #1a1a2e !important;
  color: #e5e7eb !important;
  border-top: 1px solid #334155;
  display: flex !important;
  flex-direction: column;
  min-height: 100px !important;
  height: auto;
  width: 100%;
  visibility: visible !important;
  opacity: 1 !important;
  z-index: 100;
  position: relative;
}

/* Row 1: Playback Controls */
#playback-controls {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 8px 16px;
    background: #1a1a2e;
    border-bottom: 1px solid #334155;
}

#playback-controls button {
    background: none;
    border: 1px solid #4b5563;
    color: #e5e7eb;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#playback-controls button:hover {
    background: #374151;
}

#playback-controls #anim-speed {
    width: 100px;
}

#timeline-time-readout {
    font-size: 13px;
    color: #e5e7eb;
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

/* Row 2: Scrub Bar - must be at least 40px for hit area */
  #scrub-bar-row {
    position: relative;
    min-height: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: #1a1a2e;
    border-bottom: 1px solid #334155;
    box-sizing: border-box;
    width: 100%;
  }
  
  #scrub-track {
    position: relative;
    flex: 1;
    height: 100%;
    background: transparent;
    cursor: pointer;
    margin: 0 10px;
    display: flex;
    align-items: center;
  }
  
  #scrub-progress {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 6px;
    background: #374151;
    border-radius: 3px;
    width: 0%;
    pointer-events: none;
  }
  
  #scrub-playhead {
    position: absolute;
    top: 0;
    left: 0%;
    transform: translateX(-50%);
    width: 3px;
    height: 100%;
    background: #fff;
    cursor: ew-resize;
    z-index: 10;
  }
  
  #playhead-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
    border: 2px solid #1a1a2e;
  }

#scrub-progress {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: #888;
    border-radius: 3px;
    pointer-events: none;
}

#scrub-playhead {
    position: absolute;
    top: 0;
    left: 0%;
    transform: translateX(-50%);
    width: 3px;
    height: 100%;
    background: #fff;
    cursor: ew-resize;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  #playhead-handle {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
    border: 2px solid #1a1a2e;
  }

#scrub-start, #scrub-end {
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
    min-width: 60px;
    text-align: center;
  }

/* Row 3: Ball Events */
  #ball-events-row {
    height: 32px;
    min-height: 28px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: #1a1a2e;
    border-bottom: 1px solid #334155;
    gap: 4px;
    width: 100%;
  }

#ball-events-track {
    flex: 1;
    display: flex;
    gap: 4px;
    align-items: center;
}

.ball-event-pill {
    height: 20px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    padding: 0 8px;
    min-width: 40px;
    cursor: pointer;
}

.ball-event-pill.snap { background: #4A90D9; }
.ball-event-pill.handoff { background: #E6884A; }
.ball-event-pill.pass { background: #27AE60; }
.ball-event-pill.lateral { background: #8E44AD; }

.ball-event-pill:hover {
    opacity: 0.9;
}

/* ANIMATION BAR - kept for compat */
#anim-bar {
    display: none;
}

/* REVISION 6: Waypoint Hover Feedback */
/* REVISION 9: Selected Player Visual Feedback */

/* Waypoint hover state */
#field-canvas:hover .waypoint-point {
  stroke-width: 3px;
  filter: drop-shadow(0 0 4px #5555aa);
}

/* Selected player ring */
.player.selected .player-shape {
  stroke: #FFD700;
  stroke-width: 4px;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.6));
}

/* Selected player label */
.player.selected .player-label {
  font-weight: bold;
  fill: #FFD700;
}

/* Route drawing preview */
.route-preview-line {
  stroke: #5555aa;
  stroke-width: 2;
  stroke-dasharray: 5, 5;
  fill: none;
  opacity: 0.6;
}

/* Waypoint tooltip */
.waypoint-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
}
