/* components.css — cards, nav, forms, chips, tiles, tables, modal, charts. */

/* ============ sidebar / nav ============ */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: var(--s-5) 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-5) var(--s-5);
  font-weight: 800;
  font-size: var(--fs-lg);
  letter-spacing: -0.01em;
}
.brand .mark {
  width: 26px; height: 26px; flex-shrink: 0;
}
.brand .gg { color: var(--accent); }
.brand .wordmark { letter-spacing: 0.02em; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: var(--s-3) var(--s-3) 0; }
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  color: var(--text-2);
  font-weight: 500;
  font-size: var(--fs-md);
  border-left: 2px solid transparent;
  border-radius: var(--radius);
  transition: background .12s ease, color .12s ease;
}
.nav-link:hover { background: var(--panel); color: var(--text); }
.nav-link.active {
  background: var(--accent-dim);
  color: var(--text);
  border-left-color: var(--accent);
}
.nav-link .ico { width: 16px; height: 16px; flex-shrink: 0; opacity: .9; }
.nav-spacer { flex: 1; }
.sidebar-foot { padding: var(--s-4) var(--s-5) 0; color: var(--faint); font-size: var(--fs-xs); }

/* mobile topbar */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
  }
  .topbar .brand { padding: 0; font-size: var(--fs-md); }
  .drawer {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(0,0,0,.6);
    display: flex;
  }
  .drawer-panel {
    width: 240px; max-width: 80vw; height: 100%;
    background: var(--bg-2); border-right: 1px solid var(--border);
    padding: var(--s-5) 0; overflow: auto;
  }
}

/* ============ cards ============ */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.card-pad { padding: var(--s-5); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: var(--fs-md); font-weight: 600; }
.card-body { padding: var(--s-4) var(--s-5); }
.card.hover { transition: border-color .12s ease, background .12s ease; }
.card.hover:hover { border-color: var(--border-2); }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-4);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
@media (max-width: 980px) { .grid-stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .grid-stats { grid-template-columns: 1fr; } }

/* ============ stat tile ============ */
.tile { padding: var(--s-4) var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); }
.tile-label {
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--muted);
}
.tile-value { font-size: var(--fs-3xl); font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.tile-value.sm { font-size: var(--fs-2xl); }
.tile-sub { font-size: var(--fs-sm); color: var(--muted); }
.tile-accent .tile-value { color: var(--accent); }

/* ============ buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  background: var(--elevated);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-weight: 600; font-size: var(--fs-md);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); border-color: #444; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn .ico { width: 15px; height: 15px; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); border-color: transparent; }

.btn-danger { background: transparent; border-color: var(--border-2); color: var(--loss); }
.btn-danger:hover { background: rgba(232,83,77,.12); border-color: var(--loss); }

.btn-sm { padding: 5px var(--s-3); font-size: var(--fs-sm); }
.btn-lg { padding: var(--s-3) var(--s-5); font-size: var(--fs-md); }

/* ============ forms ============ */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field-label {
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
}
.field-label .opt { color: var(--faint); font-weight: 500; text-transform: none; letter-spacing: 0; }
.field-error { color: var(--loss); font-size: var(--fs-sm); }

.input, .select, .textarea {
  width: 100%;
  background: var(--elevated);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--radius);
  font-size: var(--fs-md);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent-line); box-shadow: var(--ring); }
.textarea { resize: vertical; min-height: 76px; line-height: 1.55; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M3 4.5 6 8l3-3.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 28px;
}
.input.invalid, .select.invalid { border-color: var(--loss); }
.input.sm { padding: 5px var(--s-2); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-4); }

/* segmented control (side, result, rating) */
.segment { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--radius); overflow: hidden; }
.segment button {
  background: var(--elevated); border: none; color: var(--text-2);
  padding: var(--s-2) var(--s-3); cursor: pointer; font-weight: 600; font-size: var(--fs-sm);
  border-right: 1px solid var(--border-2);
}
.segment button:last-child { border-right: none; }
.segment button:hover { background: var(--panel-2); color: var(--text); }
.segment button.on { background: var(--accent); color: #fff; }
.segment button.on.win { background: var(--win); }
.segment button.on.loss { background: var(--loss); }
.segment.rating button { min-width: 34px; }

/* ============ tag chips ============ */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--elevated);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  border-radius: 999px;
  font-size: var(--fs-sm); font-weight: 500;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
  user-select: none;
}
.chip:hover { color: var(--text); border-color: #444; }
.chip .dot { width: 7px; height: 7px; border-radius: 999px; flex-shrink: 0; background: currentColor; }
.chip.selected { background: var(--accent-dim); border-color: var(--accent-line); color: var(--text); }
.chip.disabled { opacity: .35; cursor: not-allowed; }
.chip.static { cursor: default; }
.chip.sm { padding: 2px 8px; font-size: var(--fs-xs); }

/* ============ badges ============ */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; padding: 2px 7px;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.badge.W { color: var(--win); background: rgba(69,184,107,.12); border-color: rgba(69,184,107,.3); }
.badge.L { color: var(--loss); background: rgba(232,83,77,.12); border-color: rgba(232,83,77,.3); }
.badge.OT { color: var(--ot); background: rgba(224,169,59,.12); border-color: rgba(224,169,59,.3); }
.pill { display:inline-flex; align-items:center; gap:6px; font-size: var(--fs-xs); color: var(--muted);
  border:1px solid var(--border); border-radius: 999px; padding: 2px 9px; }

/* ============ match rows ============ */
.rows { display: flex; flex-direction: column; }
.match-row {
  display: grid;
  grid-template-columns: 16px 132px 64px 1fr auto;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s ease;
}
.match-row:last-child { border-bottom: none; }
.match-row:hover { background: var(--panel-2); }
.match-row .map { font-weight: 600; }
.match-row .score { font-weight: 700; }
.match-row .meta { color: var(--muted); font-size: var(--fs-sm); }
.row-caret { color: var(--faint); transition: transform .15s ease; display: flex; }
.match-row.open .row-caret { transform: rotate(90deg); }
@media (max-width: 720px) {
  .match-row { grid-template-columns: 14px 1fr auto; }
  .match-row .hide-sm { display: none; }
}

/* round breakdown */
.breakdown { background: var(--bg-2); border-bottom: 1px solid var(--border); padding: var(--s-4) var(--s-5); }
.round-line {
  display: grid; grid-template-columns: 40px 70px 1fr; gap: var(--s-3);
  align-items: start; padding: var(--s-2) 0; border-bottom: 1px dashed var(--border);
}
.round-line:last-child { border-bottom: none; }
.round-n { color: var(--muted); font-family: var(--mono); font-size: var(--fs-sm); }
.round-note { color: var(--text-2); font-size: var(--fs-sm); }

/* round editor */
.round-editor {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border);
}
.round-editor:last-of-type { border-bottom: none; }
.round-badge {
  width: 40px; height: 28px; display: flex; align-items: center; justify-content: center;
  background: var(--elevated); border: 1px solid var(--border-2); border-radius: var(--radius);
  font-family: var(--mono); font-size: var(--fs-sm); color: var(--muted); font-weight: 700;
}

/* ============ empty state ============ */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: var(--s-4); padding: var(--s-10) var(--s-5);
  color: var(--muted);
}
.empty .glyph { color: var(--border-2); }
.empty h3 { font-size: var(--fs-lg); color: var(--text); font-weight: 700; }
.empty p { max-width: 380px; color: var(--muted); }

/* ============ insights ============ */
.insight {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) 0; border-bottom: 1px solid var(--border);
}
.insight:last-child { border-bottom: none; }
.insight .bullet { color: var(--accent); font-weight: 800; line-height: 1.4; }
.insight .strong { color: var(--text); font-weight: 700; }

/* ============ modal ============ */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-5);
}
.modal {
  width: 100%; max-width: 420px;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.modal-head { padding: var(--s-5) var(--s-5) 0; font-size: var(--fs-lg); font-weight: 700; }
.modal-body { padding: var(--s-3) var(--s-5); color: var(--text-2); }
.modal-foot { padding: var(--s-4) var(--s-5); display: flex; justify-content: flex-end; gap: var(--s-3); border-top: 1px solid var(--border); margin-top: var(--s-3); }

/* ============ charts ============ */
.chart-wrap { width: 100%; height: 280px; }
.chart-wrap.tall { height: 320px; }
.recharts-cartesian-axis-tick text { fill: var(--muted); font-size: 11px; }
.recharts-default-tooltip {
  background: var(--panel) !important;
  border: 1px solid var(--border-2) !important;
  border-radius: var(--radius) !important;
}
.recharts-tooltip-label { color: var(--text) !important; }
.recharts-tooltip-item { color: var(--text-2) !important; }

/* ============ banner / toast ============ */
.banner {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); margin-bottom: var(--s-5);
  border: 1px solid; border-radius: var(--radius);
  font-size: var(--fs-md);
}
.banner.warn { color: var(--ot); border-color: rgba(224,169,59,.35); background: rgba(224,169,59,.08); }
.banner.ok   { color: var(--win); border-color: rgba(69,184,107,.35); background: rgba(69,184,107,.08); }

/* ============ misc ============ */
.divider { height: 1px; background: var(--border); margin: var(--s-5) 0; }
.kbd { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); border: 1px solid var(--border-2); border-radius: var(--radius); padding: 1px 5px; }
.spinner {
  width: 22px; height: 22px; border-radius: 999px;
  border: 2px solid var(--border-2); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.link { color: var(--accent); cursor: pointer; }
.link:hover { color: var(--accent-hover); text-decoration: underline; }
