/* RugbyHub Analiză: layout și baza. Fără fonturi sau resurse externe. */
:root {
  --bg: #12171c;
  --panel: #1a2127;
  --panel-2: #222b33;
  --line: #34414c;
  --text: #e8edf2;
  --muted: #a8b6c3;
  --primary: #2563eb;
  --primary-hi: #3b82f6;
  --danger: #b91c1c;
  --ok: #4ade80;
  --warn: #fbbf24;
  --focus: #facc15;
  --radius: 6px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 14px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.35;
  height: 100%;
  display: flex;
  flex-direction: column;
}
html { height: 100%; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { margin: 0 0 0.6em; }
kbd {
  font: 600 0.78rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: inherit;
}

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--focus); color: #000; padding: 6px 10px; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }

/* ---- bară sus ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-height: 46px;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.badge { font-size: 0.7rem; font-weight: 600; padding: 1px 6px; border-radius: 99px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); margin-left: 4px; }
.match-summary { flex: 1 1 200px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-summary strong { color: var(--text); }
.topbar-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.save-status { font-size: 0.8rem; color: var(--muted); min-width: 118px; text-align: right; }
.save-status[data-state="saving"] { color: var(--warn); }
.save-status[data-state="saved"] { color: var(--ok); }
.save-status[data-state="error"] { color: #fca5a5; font-weight: 600; }

.notice { margin: 0; padding: 7px 12px; background: #3b2f08; color: #fde68a; border-bottom: 1px solid #6b5410; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice[hidden] { display: none; }
.notice .btn { background: #fde68a; color: #1c1500; border-color: #fde68a; }
.notice.is-error { background: #3b1010; color: #fecaca; border-bottom-color: #7f1d1d; }
.origin-warning { font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #3b2f08; color: #fde68a; border: 1px solid #6b5410; margin-left: 6px; }
.origin-warning[hidden] { display: none; }

/* ---- grilă: video + code window sus, timeline + instanțe jos ---- */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 600px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
  flex: 1 1 0;
  min-height: 640px; /* sub această înălțime pagina se derulează în loc să strivească panourile */
}
.stage-col { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; min-height: 0; }

/* ---- player ---- */
.stage {
  position: relative;
  background: #000;
  height: clamp(220px, 44vh, 540px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}
.stage video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.stage:fullscreen { height: 100%; border: 0; border-radius: 0; }
.stage-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--muted); }
.stage-empty[hidden] { display: none; }
.stage-flash {
  position: absolute; left: 12px; bottom: 12px; max-width: 80%;
  padding: 6px 12px; border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.72); color: #fff; font-weight: 600; font-size: 1.05rem;
  opacity: 0; pointer-events: none;
  border-left: 6px solid var(--flash, var(--primary));
}
.stage-flash.show { opacity: 1; }
@media (prefers-reduced-motion: no-preference) { .stage-flash { transition: opacity 0.25s; } }
.stage-tc {
  position: absolute; right: 10px; top: 10px; padding: 2px 8px; border-radius: 4px;
  background: rgba(0, 0, 0, 0.6); color: #fff; font: 600 1rem ui-monospace, Menlo, Consolas, monospace;
}
.stage:not(:fullscreen) .stage-tc { display: none; }

.transport { display: flex; flex-direction: column; gap: 6px; padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.transport-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.timecode { font: 600 1.25rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.02em; min-width: 8.3ch; }
.timecode-total { color: var(--muted); font: 0.95rem ui-monospace, Menlo, Consolas, monospace; }
.scrub { flex: 1; min-width: 160px; accent-color: var(--primary-hi); height: 22px; }
.rate-label { color: var(--muted); font-size: 0.85rem; display: flex; align-items: center; gap: 4px; }
.spacer { flex: 1; }

/* ---- code window ---- */
.cw-panel { position: relative; overflow: hidden; min-height: 300px; }
/* Conținutul stă absolut: nu mărește rândul 1 al grilei; dacă nu încape, se derulează în panou. */
.cw-scroll { position: absolute; inset: 0; overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.cw-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cw-head h2 { margin-right: auto; }
.cw-head select { max-width: 150px; }
.cw-group { margin: 0; padding: 0; border: 0; min-width: 0; }
.cw-group legend { padding: 0; line-height: 1.1; font-size: 0.72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.cw-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; margin-top: 1px; }
.cw-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  min-height: 28px; padding: 2px 6px; border: 2px solid transparent; border-radius: var(--radius);
  background: var(--c, #475569); color: var(--fg, #fff);
  font: 600 0.78rem/1.15 inherit; text-align: left; cursor: pointer;
}
.cw-btn:hover { filter: brightness(1.12); }
.cw-btn:active { filter: brightness(0.9); }
.cw-btn[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 0 2px var(--focus); }
.cw-btn .cw-label { overflow-wrap: break-word; min-width: 0; }
.cw-btn kbd { font-size: 0.68rem; padding: 1px 4px; flex: none; }
/* start/stop: contur punctat (instant: contur plin) */
.cw-btn.mode-startstop { border: 2px dashed rgba(255, 255, 255, 0.6); }
.cw-desc { border-top: 1px solid var(--line); padding-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 5px 14px; }
.cw-desc > .cw-active, .cw-desc > .entry-hint, .cw-desc > .chips-wide { flex: 1 0 100%; }
.cw-active { font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }
.cw-active strong { color: var(--text); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.chips-label { font-size: 0.78rem; color: var(--muted); }
.chip {
  min-height: 26px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-size: 0.82rem; cursor: pointer;
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary-hi); color: #fff; font-weight: 600; }
.chip kbd { margin-left: 4px; background: rgba(255, 255, 255, 0.12); }
.player-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3px; flex: 1; }
.player-grid .chip { padding: 0; border-radius: 4px; min-width: 0; text-align: center; }
.entry-hint { color: var(--focus); font-weight: 600; }

@media (max-height: 820px) {
  .cw-btn { min-height: 26px; padding: 2px 6px; }
  .cw-scroll { gap: 4px; padding: 6px; }
}
@media (max-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
  .cw-panel { min-height: 0; }
  .cw-scroll { position: static; }
}

[hidden] { display: none !important; }

/* ---- modul live ---- */
.live-panel { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 520px; }
.live-clock { font: 700 3.4rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #fff; }
.live-undo { min-height: 56px; min-width: 220px; font-size: 1.15rem; font-weight: 700; background: #7c2d12; border-color: #fb923c; color: #fff; }
.btn-row.center { justify-content: center; }
