/* Element Styles */

/* Highlight the exact-match row in the search results index */
.row-best-match {
  background-color: color-mix(in oklch, var(--badge-ready, #16a34a) 10%, white);
  box-shadow: inset 3px 0 0 var(--badge-ready, #16a34a);
}

/* Element Display */
.element-name {
  background-color: var(--light-gray);
  color: var(--medium-gray);
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.element-link {
  display: block;
  padding: 0.25rem;
  color: var(--dark-gray);
  text-decoration: none;
  border-radius: 0.25rem;
}

.element-link:hover {
  background-color: var(--light-gray);
  text-decoration: underline;
}

/* Element Lists */
.elements-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.element-item {
  display: flex;
  align-items: center;
  padding: 0.25rem;
  background-color: white;
  border-radius: 0.25rem;
  border: 1px solid var(--medium-gray);
  border-bottom: 0px none;
}

.element-item:last-of-type {
  border-bottom: 1px solid var(--medium-gray);
}

/* Element Ranks */
.element-rank {
  display: inline-block;
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
  color: white;
  text-shadow: 1px 1px 1px black;
}

/* Rank color classes for badges */
.rank-ready {
  background-color: var(--badge-ready);
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  /* Green */
}

.rank-notice {
  background-color: var(--badge-notice);
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  /* Gold/Yellow */
}

.rank-caution {
  background-color: var(--badge-caution);
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  /* Orange */
}

.rank-warning {
  background-color: var(--badge-warning);
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  /* Red */
}

.rank-danger {
  background-color: var(--badge-danger);
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  /* Dark red */
}

.rank-stop {
  background-color: var(--badge-stop);
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}


/* Segment Elements */
.segment-elements-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.segment-element-item {
  padding: 0.25rem 0;
  border-bottom: 1px dotted var(--light-gray);
}

.segment-element-item:last-child {
  border-bottom: none;
}

.segment-name {
  color: var(--secondary-color);
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

/* Element Details */
.element-reps,
.element-weight {
  color: var(--medium-gray);
  font-size: 0.8rem;
}

.element-last-completed {
  font-size: 0.75rem;
  color: var(--medium-gray);
}

/* Elements with Ranks Display */
.elements-with-ranks {
  position: relative;
  margin-top: 0.5rem;
  border: 1px dotted var(--light-gray);
  background-color: white;
  background-image: repeating-linear-gradient(45deg,
      transparent,
      transparent 2px,
      var(--light-gray) 2px,
      var(--light-gray) 8px);
  padding: 0;
  color: var(--medium-gray);
}

.elements-with-ranks-content {
  padding-bottom: var(--spacing-unit);
  max-height: 40vh;
  overflow-y: auto;
  margin-top: var(--spacing-unit);
}

.elements-with-ranks-title {
  font-size: 1.1rem;
  color: var(--primary-color);
  border-bottom: 1px solid var(--medium-gray);
  padding-bottom: 0.25rem;
  position: sticky;
}

/* Cycle Elements Display (now uses ElementsWithRanks) */
.cycle-elements-display {
  margin-top: 0.5rem;
}

.cycle-elements-title {
  font-size: 1.1rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--medium-gray);
  padding-bottom: 0.25rem;
}

.active-cycles {
  font-size: 0.9rem;
  /* color: var(--medium-gray); */
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

.cycles-list {
  font-weight: 500;
  color: var(--dark-gray);
}

/* No elements/workouts placeholders */
.no-workouts,
.no-elements {
  text-align: center;
  color: var(--medium-gray);
  font-style: italic;
  padding: var(--spacing-unit);
}

/* Jumble list grid */
.jumble-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.jumble-item {
  background-color: var(--primary-color);
  border-radius: 0.25rem;
  transition: all 0.2s ease;
  display: block;
  padding: 0.75rem 0.5rem;
  color: var(--light-gray);
  text-decoration: none;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 0.25rem;
  transition: background-color 0.2s ease;
}

.jumble-item:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  background-color: var(--primary-color);
  color: white;
}

/* Workout History Section */
.workout-history {
  margin-bottom: 1rem;
  border: 1px solid var(--light-gray);
  border-radius: 0.5rem;
  background-color: var(--light-gray);
}

.workout-history-days {
  display: flex;
  gap: 1rem;
  padding: 0.75rem;
  overflow-x: auto;
}

.workout-history-summary {
  cursor: pointer;
  padding: 0.75rem;
  font-weight: 600;
  color: var(--primary-color);
  border-radius: 0.5rem;
  background-color: white;
  user-select: none;
}

.workout-history-summary:hover {
  background-color: var(--light-gray);
}

.workout-history[open] .workout-history-summary {
  border-bottom: 1px solid var(--light-gray);
  border-radius: 0.5rem 0.5rem 0 0;
}

.workout-history-day {
  flex: 0 0 200px;
  background-color: white;
  border: 1px solid var(--light-gray);
  border-radius: 0.25rem;
  padding: 0.75rem;
}

.workout-history-current {
  background-color: var(--badge-info-bg);
  border-left: 4px solid var(--primary-color);
}

.workout-history-date {
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark-gray);
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px dotted var(--medium-gray);
}

.workout-history-elements {
  margin-bottom: 0.75rem;
}

.workout-history-groups {
  margin-bottom: 0.75rem;
}

.section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--secondary-color);
  margin-bottom: 0.5rem;
}

.workout-history-muscle-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.workout-history-muscle-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0.5rem;
  background-color: white;
  border-radius: 0.25rem;
  border: 1px solid var(--light-gray);
  font-size: 0.875rem;
}

.muscle-name {
  font-weight: 500;
  color: var(--dark-gray);
}

.muscle-recovery {
  font-size: 0.75rem;
  color: var(--medium-gray);
  font-weight: 400;
}

.workout-history-empty {
  text-align: center;
  color: var(--medium-gray);
  font-style: italic;
  padding: 1rem;
}

/* Element Show Page - Compact 3-Column Layout */

/* Aliases Subtitle */
.element-aliases-subtitle {
  font-size: 1rem;
  font-weight: 400;
  color: var(--medium-gray);
  margin: 0.5rem 0 1rem 0;
}

.element-description-text {
  color: var(--medium-gray);
  margin-bottom: 1rem;
}

/* Single-element autocomplete used by the merge-into form on the element
   show page. Wraps a free-text input + hidden id + results popover.
   Existing .autocomplete-results / .autocomplete-result rules live in
   workouts.css and are reused as-is. */
.element-single-autocomplete {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.element-single-autocomplete-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.element-single-autocomplete-row .form-input {
  flex: 1;
  min-width: 0;
}

.element-single-autocomplete-clear {
  display: none;
}

.element-single-autocomplete--has-selection .element-single-autocomplete-clear {
  display: inline-flex;
}

/* ── Muscle activation bars ─────────────────────────────────────── */

.muscle-bar-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--dark-gray);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.muscle-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* ── Legacy detail grid (unused, kept for safety) ─────────────── */
.element-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Muscle Groups - Compact Badge Display */
.muscle-groups-compact {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.muscle-group-type {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.muscle-type-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--medium-gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.muscle-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

/* Similar Elements */
.similar-elements-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.similar-element-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

.similar-element-item:hover {
  background-color: var(--light-gray);
}

.similar-element-name {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.9rem;
}

.similar-element-name:hover {
  text-decoration: underline;
}

/* Power Profile - Compact Stats */
.profile-scope-badge {
  margin-bottom: 0.75rem;
}

.profile-scope-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.profile-type-badge {
  margin-left: 0.25rem;
}

.power-stats-compact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.power-stat {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.power-stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--medium-gray);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.power-stat-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--dark-gray);
}

.power-stat-subtext {
  font-size: 0.75rem;
  color: var(--medium-gray);
}

/* Calculation Example */
.power-calc-example {
  margin-top: 1rem;
  padding: 0.75rem;
  background-color: var(--light-gray);
  border-radius: 0.25rem;
  border: 1px solid var(--light-gray);
}

.calc-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--dark-gray);
  margin: 0 0 0.5rem 0;
}

.calc-result {
  font-size: 0.9rem;
  margin: 0.25rem 0;
  color: var(--dark-gray);
}

.calc-note {
  font-size: 0.75rem;
  color: var(--medium-gray);
  margin: 0.25rem 0 0 0;
  font-style: italic;
}

/* Power Profile Notes */
.power-notes {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--light-gray);
}

.notes-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--medium-gray);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0 0 0.25rem 0;
}

.notes-text {
  font-size: 0.85rem;
  color: var(--dark-gray);
  line-height: 1.5;
  margin: 0;
}

/* Empty States */
.empty-text {
  text-align: center;
  color: var(--medium-gray);
  font-style: italic;
  padding: 1rem;
}

/* Muscle Activation Edit Form */
.muscle-activation-help-text {
  color: var(--medium-gray);
  font-size: 0.8125rem;
  margin-bottom: 0.5rem;
}

.ma-columns {
  columns: 2 20rem;
  column-gap: 1rem;
}

.ma-columns > .card {
  break-inside: avoid;
}

.ma-grid {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.ma-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid color-mix(in oklch, var(--medium-gray) 30%, transparent);
}

.ma-row:last-child {
  border-bottom: none;
}

.ma-name {
  flex: 0 0 8rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--dark-gray);
}

.ma-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.ma-presets {
  display: flex;
  gap: 0.125rem;
}

.ma-preset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid var(--medium-gray);
  border-radius: 0.25rem;
  background: var(--surface-white);
  color: var(--dark-gray);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.1s ease;
}

.ma-preset:hover {
  background: var(--primary-color);
  color: var(--surface-white);
  border-color: var(--primary-color);
}

.ma-preset[aria-pressed="true"] {
  background: var(--primary-color);
  color: var(--surface-white);
  border-color: var(--primary-color);
}

.ma-preset-clear {
  color: var(--medium-gray);
  font-size: 0.875rem;
}

.ma-preset-clear:hover {
  background: var(--badge-warning);
  border-color: var(--badge-warning);
  color: var(--surface-white);
}

.ma-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.ma-input {
  width: 3.5rem !important;
  height: 1.75rem;
  padding: 0.125rem 0.375rem;
  font-size: 0.8125rem;
  text-align: right;
}

.ma-suffix {
  font-size: 0.75rem;
  color: var(--medium-gray);
  font-weight: 500;
}

/* ── Element Profiles card ───────────────────────────────────────── */

/* button_to wraps the Delete action in its own <form>; keep it inline with
   the badges beside it instead of dropping to its own line. */
.profile-delete-form {
  display: inline;
}

/* Responsive Design */
@media (max-width: 768px) {
  .element-detail-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .power-stats-compact {
    grid-template-columns: 1fr;
  }

  .jumble-list {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.25rem;
  }

  .jumble-item {
    display: block;
    padding: 0.5rem 0.25rem;
    font-size: 0.8rem;
  }

  .workout-history-summary {
    padding: 0.5rem;
    font-size: 0.9rem;
  }

  .workout-history-day {
    flex: 0 0 150px;
    padding: 0.5rem;
  }

  .workout-history-days {
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .workout-history-date {
    font-size: 0.9rem;
  }

  .section-title {
    font-size: 0.8rem;
  }

  .workout-history-muscle-item {
    font-size: 0.8rem;
    padding: 0.25rem;
  }

  .muscle-recovery {
    font-size: 0.7rem;
  }

  .ma-row {
    flex-wrap: wrap;
  }

  .ma-name {
    flex: 0 0 100%;
  }
}

/* ── Progression graph (inline SVG) ─────────────────────────────── */

.pg-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.pg-node {
  fill: var(--surface-muted);
  stroke: var(--medium-gray-light);
  stroke-width: 1.5;
  transition: fill 0.15s;
}

.pg-node-current {
  fill: var(--primary-color);
  stroke: var(--primary-color-dark);
  stroke-width: 2;
}

/* Prereq/Next nodes are colored by their element's usage_type below.
   These selectors keep a baseline fill for nodes without a usage_type class. */
.pg-node-prereq,
.pg-node-next {
  fill: var(--surface-muted);
  stroke: var(--medium-gray-light);
}

/* Usage_type fills — drive everything from the chip-* tokens so the graph
   stays in lockstep with drawer chips. Stroke is derived by darkening the
   bg via color-mix, keeping the chip vars the single source of truth. */
.pg-node--workout {
  fill: var(--surface-muted);
  stroke: var(--medium-gray-light);
}

.pg-node--workout-partner {
  fill: var(--chip-partner-bg);
  stroke: color-mix(in oklch, var(--chip-partner-bg) 70%, black);
}

.pg-node--activation {
  fill: var(--chip-activation-bg);
  stroke: color-mix(in oklch, var(--chip-activation-bg) 70%, black);
}

.pg-node--stretching {
  fill: var(--chip-stretching-bg);
  stroke: color-mix(in oklch, var(--chip-stretching-bg) 70%, black);
}

.pg-node--workout:hover {
  fill: var(--surface-hover);
}

.pg-node--workout-partner:hover {
  fill: var(--chip-partner-bg-hover);
}

.pg-node--activation:hover {
  fill: var(--chip-activation-bg-hover);
}

.pg-node--stretching:hover {
  fill: var(--chip-stretching-bg-hover);
}

.pg-label {
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  fill: var(--dark-gray);
  pointer-events: none;
}

.pg-node-current ~ .pg-label,
.pg-node-current + text {
  fill: #fff;
}

/* current node label needs white text — applied via adjacent sibling isn't reliable,
   use a wrapper approach: current node group */
a .pg-node-prereq + text,
a .pg-node-next + text {
  fill: var(--dark-gray);
}

.pg-edge {
  fill: none;
  stroke: var(--border-emphasis);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.pg-arrowhead {
  fill: var(--border-emphasis);
}

/* Proposed-but-not-yet-applied progression edges (staged import review):
   dashed node border and dashed edge instead of the solid live style. */
.pg-node--proposed {
  stroke-dasharray: 4 3;
  stroke-width: 2;
}

.pg-edge--proposed {
  stroke-dasharray: 4 3;
}

/* ── Progression edge direction toggle ──────────────────────────── */
.direction-toggle {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.direction-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.15s, background 0.15s;
}

.direction-option:has(input:checked) {
  border-color: var(--primary-color);
  background: rgba(59, 130, 246, 0.05);
}

.direction-option input[type="radio"] {
  flex-shrink: 0;
}

/* Element alias / typeahead modal */

.element-alias-modal-prompt {
  margin-bottom: 1rem;
}

.element-alias-modal-prompt p {
  color: var(--dark-gray);
}

.element-alias-modal-prompt strong {
  font-weight: 600;
}

.element-alias-modal-error {
  margin-bottom: 1rem;
}

.element-alias-modal-help {
  font-size: 0.875rem;
  color: var(--medium-gray);
}

.element-typeahead-wrapper {
  position: relative;
}

.element-typeahead-input {
  width: 100%;
}

.element-creation-modal-error {
  margin-bottom: 1rem;
}

.quick-edit-modal-field {
  margin-bottom: 0.75rem;
}

.quick-edit-modal-archetype-heading {
  margin-top: 0.75rem;
}

/* Merge-conflict resolution modal */
.merge-conflict-row {
  padding: 0.5rem 0;
  border-bottom: 1px solid oklch(92% 0 0);
}

.merge-conflict-row:last-of-type {
  border-bottom: none;
}

.merge-conflict-label {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--medium-gray-dark);
  margin: 0 0 0.375rem;
}

.merge-conflict-option {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0;
  cursor: pointer;
}

.merge-conflict-note {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
}

/* ── Progression graph rating chips ─────────────────────────────────────
   Small skill-demand chips pinned to node corners (see ProgressionGraph
   annotations). The --change variant marks the value under review. */
.pg-chip {
  fill: var(--surface-muted);
  stroke: var(--medium-gray-light);
  stroke-width: 1;
}

.pg-chip--change {
  fill: var(--primary-color);
  stroke: var(--primary-color-dark);
}

.pg-chip-label {
  font-size: 10px;
  font-weight: 600;
  fill: var(--dark-gray);
}

.pg-chip-label--change {
  fill: #fff;
}

