/* VolleyIQ Coaches Portal — Professional Theme
   Brand palette derived from app:
   Primary: #0A74FF, Primary Dark: #005DDB, Primary Light: #4FB2FF
   Secondary: #FF7A00, Secondary Dark: #E96A00, Secondary Light: #FFB066
   Background: #F7F9FC, Surface: #FFFFFF
   Success: #22C55E, Warning: #F59E0B, Danger: #EF4444
*/

/* ========== CSS Variables ========== */
:root {
  --brand-primary: #0A74FF;
  --brand-primary-dark: #005DDB;
  --brand-primary-light: #4FB2FF;

  --brand-secondary: #FF7A00;
  --brand-secondary-dark: #E96A00;
  --brand-secondary-light: #FFB066;

  --bg: #F7F9FC;
  --surface: #FFFFFF;

  --text-primary: #0B0C0F;
  --text-secondary: #4B5563;
  --text-muted: #6B7280;

  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;

  --radius-s: 10px;
  --radius-m: 14px;
  --radius-l: 18px;

  --shadow-s: 0 6px 16px rgba(0,0,0,0.06);
  --shadow-m: 0 12px 28px rgba(0,0,0,0.10);
  --shadow-glow: 0 8px 32px rgba(10, 116, 255, 0.25);

  --border: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.12);

  --focus: 0 0 0 3px rgba(10, 116, 255, 0.25);
}

/* ========== Base / Reset ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  color: var(--text-primary);
  background:
    radial-gradient(1200px 600px at -10% -10%, rgba(79, 178, 255, 0.10), transparent 40%),
    radial-gradient(1200px 600px at 110% -10%, rgba(255, 122, 0, 0.10), transparent 40%),
    var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video, canvas {
  max-width: 100%;
  display: block;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
}

/* Utility */
.hidden { display: none !important; }
.muted { color: var(--text-muted); }

/* Generic inline statuses (beyond #login-status) */
.success { color: #14532D; }
.error { color: #7F1D1D; }

/* Subtle scrollbar polish for scrollable panels */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(10,116,255,0.35) rgba(0,0,0,0.06);
}
*::-webkit-scrollbar { height: 10px; width: 10px; }
*::-webkit-scrollbar-track { background: rgba(0,0,0,0.04); border-radius: 999px; }
*::-webkit-scrollbar-thumb {
  background: rgba(10,116,255,0.35);
  border-radius: 999px;
  border: 2px solid rgba(0,0,0,0.04);
}

/* ========== Containers ========== */
.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* Header / Topbar */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.app-title {
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* Header nav links (index) */
.app-header nav {
  display: flex;
  gap: 12px;
  align-items: center;
}
.app-header nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--brand-primary);
  border: 1px solid transparent;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 100ms ease;
  font-weight: 600;
}
.app-header nav a:hover {
  background: rgba(10,116,255,0.06);
  border-color: rgba(10,116,255,0.25);
  text-decoration: none;
}
.app-header nav a:active { transform: translateY(1px); }
.app-header nav a:focus-visible { box-shadow: var(--focus); }

/* Footer links (index) */
.footer-links a {
  color: var(--text-secondary);
  border: 1px solid transparent;
  padding: 6px 8px;
  border-radius: 10px;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
.footer-links a:hover {
  color: var(--brand-primary);
  background: rgba(10,116,255,0.06);
  border-color: rgba(10,116,255,0.18);
  text-decoration: none;
}
.footer-links a:focus-visible { box-shadow: var(--focus); }

/* ========== Auth Section ========== */
#auth-section {
  min-height: 80vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-m);
  border: 1px solid var(--border);
  overflow: hidden;
}

.auth-card-header {
  padding: 24px 24px 12px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
}
.auth-card-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
.auth-card-subtitle {
  margin-top: 6px;
  color: rgba(255,255,255,0.92);
  font-size: 14px;
}
.auth-card-body { padding: 20px 24px 24px; }

/* Inputs */
.input-group { margin-bottom: 14px; }
label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
input[type="email"],
input[type="password"],
input[type="text"],
textarea {
  width: 100%;
  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: #fff;
  color: var(--text-primary);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}
input:focus,
textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: var(--focus);
}
textarea { min-height: 84px; resize: vertical; }

/* Status messages */
#login-status {
  display: none;
  margin-top: 10px;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0,0,0,0.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
#login-status.success {
  background: rgba(34, 197, 94, 0.10);
  border-color: rgba(34, 197, 94, 0.40);
  color: #14532D;
}
#login-status.error {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.40);
  color: #7F1D1D;
}

/* ========== Buttons ========== */
#login-button,
#logout-button,
#toggle-drawing-button,
#clear-canvas-button,
#add-comment-button,
#save-feedback-button,
#cancel-feedback-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease, color 120ms ease, border-color 120ms ease;
  user-select: none;
  text-align: center;
  font-weight: 600;
}
#login-button:focus-visible,
#logout-button:focus-visible,
#toggle-drawing-button:focus-visible,
#clear-canvas-button:focus-visible,
#add-comment-button:focus-visible,
#save-feedback-button:focus-visible,
#cancel-feedback-button:focus-visible { box-shadow: var(--focus); }
#login-button:active,
#logout-button:active,
#toggle-drawing-button:active,
#clear-canvas-button:active,
#add-comment-button:active,
#save-feedback-button:active,
#cancel-feedback-button:active { transform: translateY(1px); }
#login-button:disabled,
#logout-button:disabled,
#toggle-drawing-button:disabled,
#clear-canvas-button:disabled,
#add-comment-button:disabled,
#save-feedback-button:disabled,
#cancel-feedback-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Primary actions */
#login-button,
#save-feedback-button {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  box-shadow: var(--shadow-s);
}
#login-button:hover,
#save-feedback-button:hover {
  filter: brightness(1.03);
  box-shadow: var(--shadow-glow);
}

/* Secondary actions */
#toggle-drawing-button,
#add-comment-button {
  background: #fff;
  color: var(--brand-primary);
  border-color: rgba(10, 116, 255, 0.35);
}
#toggle-drawing-button:hover,
#add-comment-button:hover { background: rgba(10, 116, 255, 0.06); }

/* Ghost actions */
#logout-button,
#clear-canvas-button,
#cancel-feedback-button {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
#logout-button:hover,
#clear-canvas-button:hover,
#cancel-feedback-button:hover { background: rgba(0,0,0,0.04); }

/* Special states */
#login-button { width: 100%; }
#toggle-drawing-button.active {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}

/* ========== Main App Layout ========== */
#main-app-section { display: block; }

.portal-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 22px;
}

/* Sidebar (Submissions) */
.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-s);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 60vh;
}
.sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(10, 116, 255, 0.08), transparent 65%), #fff;
}
.sidebar-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.sidebar-subtitle {
  margin: 6px 0 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}
#submissions-list {
  padding: 12px;
  overflow: auto;
  height: 100%;
}

/* Submission item tiles */
.submission-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease, background 120ms ease;
  margin-bottom: 10px;
}
.submission-item:hover {
  transform: translateY(-1px);
  border-color: rgba(10, 116, 255, 0.35);
  box-shadow: var(--shadow-s);
  background: linear-gradient(0deg, rgba(10, 116, 255, 0.06), rgba(10, 116, 255, 0.06)), #fff;
}
.submission-item:active { transform: translateY(0); }

/* Loading spinner */
.loading-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(10, 116, 255, 0.15);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
  margin: 12px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Main panel */
.main-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
}

/* Video + Canvas container (unchanged formatting) */
.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-m);
  overflow: hidden;
}
.video-card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.video-container {
  position: relative;
  width: 100%;
  background: #000;
}
#video-player {
  width: 100%;
  height: auto;
  display: block;
  position: relative;
  z-index: 1;
}
#drawing-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  cursor: crosshair;
  transition: box-shadow 140ms ease, outline-color 140ms ease, opacity 140ms ease;
  outline: 2px solid transparent;
  z-index: 2;
}
#drawing-canvas.active {
  outline-color: rgba(10, 116, 255, 0.45);
  box-shadow: inset 0 0 0 2px rgba(10, 116, 255, 0.35);
}
#drawing-canvas:not(.active) {
  cursor: default;
  pointer-events: none; /* allow clicks to pass through to video controls when not drawing */
}

/* Submission info / metadata */
#current-submission-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-s);
  padding: 14px 16px;
}
#current-submission-info h4 {
  margin: 0 0 6px 0;
  font-size: 16px;
}
#current-submission-info p {
  margin: 4px 0;
  color: var(--text-secondary);
  font-size: 14px;
}
#current-submission-info p strong { color: var(--brand-primary); }

/* Tools row */
.tools-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: #fff;
}

/* Comments + Feedback */
.feedback-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-s);
  overflow: hidden;
}
.feedback-card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.feedback-body { padding: 12px 16px 16px; }
.comment-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  margin-bottom: 10px;
}
#comment-text { min-height: 44px; }

/* Feedback list */
#current-feedback-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
#current-feedback-list li {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}
#current-feedback-list li:hover {
  border-color: rgba(10, 116, 255, 0.35);
  background: linear-gradient(0deg, rgba(10, 116, 255, 0.06), rgba(10, 116, 255, 0.06)), #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-s);
}
#current-feedback-list li:active { transform: translateY(0); }
.feedback-item-comment { color: var(--brand-secondary); font-weight: 700; }
.feedback-item-drawing { color: var(--brand-primary); font-weight: 700; }
.feedback-item-seek {
  margin-left: auto;
  color: var(--brand-primary);
  font-size: 12px;
  opacity: 0.85;
}

/* Save / Cancel row */
.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}

/* ========== Accessibility & Focus States ========== */
:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: 8px;
}

/* ========== Responsive ========== */
@media (max-width: 1200px) {
  .portal-layout { grid-template-columns: 280px 1fr; }
}
@media (max-width: 980px) {
  .portal-layout { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
  .main-panel { order: 1; }
}
@media (max-width: 640px) {
  .app-shell { padding: 16px; }
  .video-card-header,
  .feedback-card-header,
  .tools-row,
  .actions-row { padding-left: 12px; padding-right: 12px; }
  .comment-row { grid-template-columns: 1fr; }
}

/* ========== Helper mappings (no HTML changes required) ========== */
#main-app-section .portal-layout .sidebar .sidebar-header .sidebar-title {}
#main-app-section .portal-layout .main-panel .video-card .video-container {}
#main-app-section .portal-layout .main-panel .feedback-card .feedback-body {}

/* ========== Coach Portal compatibility layer (maps your existing HTML to theme) ========== */

/* Map generic .card to themed card look */
.card,
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-m);
}

/* Header content area -> app header look */
.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  margin: 0 24px 18px;
  border-bottom: 1px solid var(--border);
}
.header-content p { margin: 0; color: var(--text-secondary); }
#coach-email {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(10,116,255,0.08);
  border: 1px solid rgba(10,116,255,0.18);
  color: var(--brand-primary);
  font-weight: 600;
}

/* Content wrapper -> two-column layout like .portal-layout */
.content-wrapper {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 22px;
  padding: 0 24px 24px;
}
@media (max-width: 980px) {
  .content-wrapper { grid-template-columns: 1fr; }
}

/* Submissions panel -> sidebar look */
.submissions-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-s);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 60vh;
}
.submissions-panel > h2 {
  margin: 0;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(10, 116, 255, 0.08), transparent 65%),
    #fff;
}
.submissions-panel #submissions-list {
  padding: 12px;
  overflow: auto;
  height: 100%;
}

/* Video + feedback column -> grid like .main-panel */
.video-feedback-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* Map #video-player-container to themed .video-container, without altering video/canvas formatting */
#video-player-container {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: var(--radius-l);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-m);
}

/* Feedback tools wrapper */
#feedback-tools {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-s);
  overflow: hidden;
  padding: 12px 16px 16px;
}
#feedback-tools h3 {
  margin: 8px 0 10px;
  font-size: 16px;
  color: var(--text-primary);
}

/* Button group utility */
.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.button-group.full-width {
  width: 100%;
  justify-content: flex-start;
  margin: 8px 0;
}

/* Button classes to complement ID-based styles */
button.primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  border: 1px solid transparent;
  box-shadow: var(--shadow-s);
}
button.primary:hover { filter: brightness(1.03); box-shadow: var(--shadow-glow); }
button.secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
button.secondary:hover { background: rgba(0,0,0,0.04); }

/* Action-specific button helpers */
button.action-drawing {
  background: #fff;
  color: var(--brand-primary);
  border: 1px solid rgba(10,116,255,0.35);
}
button.action-drawing:hover { background: rgba(10,116,255,0.06); }
button.action-clear,
button.action-cancel {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
button.action-clear:hover,
button.action-cancel:hover { background: rgba(0,0,0,0.04); }
button.action-save {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  border: 1px solid transparent;
  box-shadow: var(--shadow-s);
}
button.action-save:hover { filter: brightness(1.03); box-shadow: var(--shadow-glow); }

/* Inputs inside #feedback-tools align with theme spacing */
#feedback-tools .input-group {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
}
@media (max-width: 640px) {
  #feedback-tools .input-group { grid-template-columns: 1fr; }
}

/* Ensure auth-section card spacing for simple markup login page */
#auth-section.card {
  width: 100%;
  max-width: 460px;
  margin: 40px auto;
  padding: 24px;
  text-align: center;
}
#auth-section.card .app-title { margin-bottom: 6px; }
#auth-section.card input { margin: 6px 0; }
#auth-section.card #login-button { margin-top: 8px; width: 100%; }

/* ========== Type badge and filter styles ========== */
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
}
.type-badge.skill {
  color: var(--brand-primary);
  border-color: rgba(10,116,255,0.35);
  background: rgba(10,116,255,0.06);
}
.type-badge.highlight {
  color: var(--brand-secondary);
  border-color: rgba(255,122,0,0.35);
  background: rgba(255,122,0,0.08);
}
.submissions-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.submissions-toolbar label {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}
.submissions-toolbar select {
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-primary);
  outline: none;
}
.submissions-toolbar select:focus-visible { box-shadow: var(--focus); }

/* Badge-style link button (used on index and support) */
.badge-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow-s);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease, background 120ms ease;
  width: fit-content;
}
.badge-link:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-m);
  border-color: rgba(10, 116, 255, 0.35);
  background: linear-gradient(0deg, rgba(10,116,255,0.06), rgba(10,116,255,0.06)), #fff;
  text-decoration: none;
}
.badge-link span {
  font-weight: 600;
  color: var(--brand-primary);
  white-space: nowrap;
}
