/* ═══════════════════════════════════════════════════════════════════════════
   Chad — Coaching Panel & FAB
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── FAB ─────────────────────────────────────────────────────────────────── */
.chad-fab {
  position: fixed;
  top: 12px;
  right: 24px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 44px;
  border: none;
  border-radius: 22px;
  background: var(--amber);
  color: var(--on-amber);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  transition: transform .15s, box-shadow .15s;
}
.chad-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.5); }
.chad-fab:active { transform: translateY(0); }
.chad-fab.panel-open { display: none; }

.chad-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red, var(--red));
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1;
}

/* ── Panel ────────────────────────────────────────────────────────────────── */
.chad-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  z-index: 800;
  background: var(--bg1, var(--bg0));
  border-left: 1px solid var(--bdr, var(--bg1));
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s ease;
  overflow: hidden;
}
.chad-panel.open { transform: translateX(0); }

.chad-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--bdr, var(--bg1));
  flex-shrink: 0;
}
.chad-panel-title {
  font-size: var(--fs-base);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--amber-ink);
}
/* ── Sections toggle ─────────────────────────────────────────────────────── */
.chad-tabs {
  display: flex;
  border-bottom: 1px solid var(--bdr, var(--bg1));
  flex-shrink: 0;
}
.chad-tab {
  flex: 1;
  padding: 10px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--dim, var(--dim2));
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.chad-tab:hover { color: var(--dim1, var(--dim)); }
.chad-tab.active { color: var(--amber-ink); border-bottom-color: var(--amber-ink); }

.chad-section { display: none; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.chad-section.active { display: flex; }

/* ── Insight feed ────────────────────────────────────────────────────────── */
.chad-feed-actions {
  display: flex;
  justify-content: flex-end;
  padding: 8px 12px 0;
  flex: 0 0 auto;
}
/* Class sets display:flex, so [hidden] needs an explicit override to win. */
.chad-feed-actions[hidden] { display: none; }
.chad-dismiss-all {
  background: none;
  border: none;
  color: var(--dim2, var(--bdr2));
  font-size: var(--fs-xs);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 4px;
}
.chad-dismiss-all:hover { color: var(--dim1, var(--dim)); background: var(--bg2, var(--bg1)); }

.chad-feed {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chad-feed-empty {
  color: var(--dim2, var(--bdr2));
  font-size: var(--fs-xs);
  text-align: center;
  padding: 40px 16px;
}

/* ── Insight card ────────────────────────────────────────────────────────── */
/* Severity is the .tk-eyebrow inside the card, coloured by --kind from
   core/kind.css's data-severity map — the same map the dashboard column reads,
   because both render the SAME feed. The container itself is plain (TKF-310). */
.chad-card {
  background: var(--bg2, var(--bg1));
  border-radius: 8px;
  padding: 12px 14px;
  position: relative;
}

.chad-card-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--fg, var(--txt));
  margin-bottom: 4px;
}
.chad-card-body {
  font-size: var(--fs-xs);
  color: var(--dim1, var(--dim));
  line-height: 1.5;
  /* One item per line — see the note on .dash-chad-body. Same insight bodies
     render here, so the two have to agree. */
  white-space: pre-line;
}
.chad-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.chad-card-time {
  font-size: var(--fs-xs);
  color: var(--dim2, var(--bdr2));
}
.chad-card-dismiss {
  background: none;
  border: none;
  color: var(--dim3, var(--bg3));
  font-size: var(--fs-xs);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.chad-card-dismiss:hover { color: var(--dim1, var(--dim)); background: var(--bg0, var(--bg0)); }

/* ── Post-ride summary card ──────────────────────────────────────────────── */
.chad-summary-grid {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 4px 12px;
  font-size: var(--fs-xs);
  margin-top: 6px;
}
.chad-summary-grid .sg-header {
  font-weight: 600;
  color: var(--dim2, var(--bdr2));
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.chad-summary-grid .sg-label { color: var(--dim1, var(--dim)); }
.chad-summary-grid .sg-planned { color: var(--dim, var(--dim2)); }
.chad-summary-grid .sg-actual { color: var(--fg, var(--txt)); font-weight: 600; }
.chad-summary-grid .sg-delta { font-weight: 600; font-size: var(--fs-xs); }
.chad-summary-grid .sg-delta.over  { color: var(--red, var(--red)); }
.chad-summary-grid .sg-delta.under { color: var(--blue); }
.chad-summary-grid .sg-delta.match { color: var(--green, var(--green)); }

/* ── Workout suggestion cards ────────────────────────────────────────────── */
.chad-suggestion-card .chad-card-body { margin-bottom: 4px; }
.chad-reason { font-style: italic; color: var(--dim, var(--dim2)); margin-bottom: 8px; }

.chad-done-badge {
  display: inline-block;
  font-size: var(--fs-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--green, var(--green));
  border: 1px solid var(--green, var(--green));
  border-radius: 4px;
  padding: 1px 6px;
  vertical-align: middle;
  margin-left: 6px;
}

.chad-budget-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 10px; border-bottom: 1px solid var(--bdr);
}
.chad-budget-label {
  font-size: var(--fs-micro); letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--dim2);
}
.chad-budget-chips { flex: 1; }
.chad-budget-chip { background: var(--bg2); }
.chad-budget-chip.active { background: var(--amber); border-color: var(--amber); color: var(--on-amber); }

.chad-wo-option {
  display: block;
  padding: 8px 10px;
  margin-top: 6px;
  background: var(--bg0, var(--bg0));
  border-radius: 6px;
}
.chad-wo-row { display: flex; align-items: center; gap: 8px; }
.chad-wo-primary { border: 1px solid var(--bdr2, var(--bg3)); }
.chad-wo-info { flex: 1; min-width: 0; }
.chad-thumb-wrap {
  margin-top: 6px;
  background: var(--bg1, var(--bg0));
  border: 1px solid var(--bdr, var(--bg1));
  border-radius: 4px;
  overflow: hidden;
}
.chad-thumb { display: block; width: 100%; height: 72px; }
.chad-thumb.empty {
  background: repeating-linear-gradient(45deg, var(--bg0, var(--bg0)), var(--bg0, var(--bg0)) 6px, var(--bg1, var(--bg0)) 6px, var(--bg1, var(--bg0)) 12px);
}
.chad-wo-title {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg, var(--txt));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chad-wo-meta { font-size: var(--fs-xs); color: var(--dim2, var(--bdr2)); margin-top: 2px; }
.chad-wo-stats { margin-top: 4px; gap: 10px; }
.chad-wo-stats .wo-stat-lbl { font-size: var(--fs-xs); letter-spacing: 1.5px; }
.chad-wo-stats .wo-stat-val { font-size: var(--fs-sm); }
.chad-wo-badge-row { margin-top: 3px; }
.chad-wo-badge {
  display: inline-block;
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
}
.chad-wo-badge.easier { background: color-mix(in srgb, var(--green) 13%, transparent); color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 27%, transparent); }
.chad-wo-badge.harder { background: color-mix(in srgb, var(--red) 13%, transparent); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 27%, transparent); }

.chad-load-btn {
  background: var(--amber);
  color: var(--bg0, var(--bg0));
  border: none;
  border-radius: 5px;
  padding: 5px 12px;
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  flex-shrink: 0;
}
.chad-load-btn:hover { filter: brightness(1.1); }

.chad-alt-label {
  font-size: var(--fs-micro);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--dim2, var(--bdr2));
  margin-top: 10px;
  margin-bottom: 2px;
}

/* ── Chat section ────────────────────────────────────────────────────────── */
.chad-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chad-chat-empty {
  color: var(--dim2, var(--bdr2));
  font-size: var(--fs-xs);
  text-align: center;
  padding: 40px 16px;
  line-height: 1.6;
}
.chad-chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: var(--fs-sm);
  line-height: 1.5;
  word-wrap: break-word;
}
.chad-chat-msg.user {
  align-self: flex-end;
  background: var(--amber);
  color: var(--bg0, var(--bg0));
  border-bottom-right-radius: 4px;
}
.chad-chat-msg.assistant {
  align-self: flex-start;
  background: var(--bg2, var(--bg1));
  color: var(--dim1, var(--dim));
  border-bottom-left-radius: 4px;
}
.chad-chat-msg.typing {
  color: var(--dim2, var(--bdr2));
  font-style: italic;
}

.chad-chat-input-wrap {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--bdr, var(--bg1));
  flex-shrink: 0;
}
.chad-chat-input {
  flex: 1;
  background: var(--bg0, var(--bg0));
  border: 1px solid var(--bdr, var(--bg1));
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--fg, var(--txt));
  font-family: inherit;
  font-size: var(--fs-sm);
  outline: none;
  resize: none;
}
.chad-chat-input:focus { border-color: var(--amber-ink); }
.chad-chat-input::placeholder { color: var(--dim3, var(--bg3)); }
.chad-chat-send {
  background: var(--amber);
  color: var(--bg0, var(--bg0));
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  flex-shrink: 0;
}
.chad-chat-send:hover { filter: brightness(1.1); }
.chad-chat-send:disabled { opacity: .4; cursor: default; }

.chad-chat-clear {
  background: none;
  border: none;
  color: var(--dim3, var(--bg3));
  font-size: var(--fs-xs);
  cursor: pointer;
  padding: 6px 12px;
  text-align: center;
}
.chad-chat-clear:hover { color: var(--dim1, var(--dim)); }
.chad-chat-controls {
  display: flex;
  justify-content: center;
  gap: 4px;
}

/* ── POI "Hide all" toggle (rendered inside .chad-route-action) ──────────── */
.chad-poi-show-all {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  transition: filter .15s;
}
.chad-poi-show-all:hover { filter: brightness(1.15); }

/* ── Route action card ───────────────────────────────────────────────────── */
.chad-route-action {
  align-self: flex-start;
  max-width: 85%;
  background: var(--bg2, var(--bg1));
  border: 1px solid var(--bdr2, var(--bg3));
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chad-route-meta {
  font-size: var(--fs-xs);
  color: var(--dim1, var(--dim));
  line-height: 1.4;
}
.chad-route-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  transition: filter .15s;
}
.chad-route-btn:hover { filter: brightness(1.15); }
.chad-route-applied { color: var(--green); font-weight: 600; }
/* Stops that wouldn't place. Amber, not red — the route is still usable, the
   rider just needs to know it isn't quite the line they asked for. */
.chad-route-warn {
  font-size: var(--fs-xs);
  color: var(--amber-ink);
  line-height: 1.4;
}

/* ── Saved-route results ─────────────────────────────────────────────────── */
/* Matches from the rider's own library. Rows, not cards — the coach's reply
   has already made the recommendation; these are just the way to act on it. */
.chad-route-results {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.chad-route-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  background: var(--bg2, var(--bg1));
  border: 1px solid var(--bd1, var(--bg3));
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.chad-route-row:hover { border-color: var(--blue); background: var(--bg3, var(--bg0)); }
.chad-route-row-title { font-size: var(--fs-sm); font-weight: 600; color: var(--fg1, var(--txt)); }
.chad-route-row-meta  { font-size: var(--fs-xs); color: var(--dim1, var(--dim)); }

/* ── Plan action card ────────────────────────────────────────────────────── */
/* Proposed calendar change awaiting the rider's confirmation. Same shell as
   the route card; the change list is what's specific to it. */
.chad-plan-action {
  align-self: flex-start;
  max-width: 85%;
  background: var(--bg2, var(--bg1));
  border: 1px solid var(--bdr2, var(--bg3));
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chad-plan-head {
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--dim1, var(--dim));
}
.chad-plan-summary {
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--fg1, var(--txt));
}
.chad-plan-changes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-left: 2px solid var(--bdr2, var(--bg3));
  padding-left: 10px;
}
.chad-plan-changes li {
  font-size: var(--fs-xs);
  color: var(--dim1, var(--dim));
  line-height: 1.4;
}
.chad-plan-more { font-style: italic; opacity: .8; }
.chad-plan-btns { display: flex; gap: 8px; }
.chad-plan-apply {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  transition: filter .15s;
}
.chad-plan-apply:hover:not(:disabled) { filter: brightness(1.15); }
.chad-plan-apply:disabled { opacity: .6; cursor: default; }
.chad-plan-cancel {
  background: transparent;
  color: var(--dim1, var(--dim));
  border: 1px solid var(--bdr2, var(--bg3));
  border-radius: 6px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
}
.chad-plan-cancel:hover:not(:disabled) { color: var(--fg1, var(--txt)); }
.chad-plan-error {
  font-size: var(--fs-xs);
  line-height: 1.4;
  color: var(--red);
}
.chad-plan-applied   { color: var(--green); font-weight: 700; text-transform: none; letter-spacing: 0; }
.chad-plan-dismissed { opacity: .6; text-transform: none; letter-spacing: 0; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .chad-panel { width: 100vw; }
  .chad-fab { top: 8px; right: 16px; height: 40px; padding: 0 12px; font-size: var(--fs-xs); }
}
