/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --border: #e3e5e8;
  --primary: #4f46e5;
  --primary-text: #ffffff;
  --success-bg: #e9f9ee;
  --success-text: #1b7a3d;
  --danger: #dc2626;
  --danger-bg: #fdecec;
  --danger-text: #b42318;
  --radius: 0.75rem;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1e2126;
    --text: #f1f2f4;
    --muted: #9aa1ac;
    --border: #2c3036;
    --primary: #818cf8;
    --primary-text: #14161a;
    --success-bg: #0f2a1a;
    --success-text: #4ade80;
    --danger: #f87171;
    --danger-bg: #3a1414;
    --danger-text: #fca5a5;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

turbo-frame {
  display: block;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
}

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

a:hover {
  text-decoration: underline;
}

.navbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
}

.navbar-brand:hover {
  text-decoration: none;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.navbar-links form {
  margin: 0;
}

main {
  padding: 1.5rem 1rem 3rem;
  max-width: 40rem;
  margin: 0 auto;
}

/* Flash messages */

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}

.flash-notice {
  background: var(--success-bg);
  color: var(--success-text);
}

.flash-alert {
  background: var(--danger-bg);
  color: var(--danger-text);
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 2.75rem;
  padding: 0.5rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:hover {
  text-decoration: none;
  border-color: var(--muted);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.btn-primary:hover {
  opacity: 0.92;
  border-color: var(--primary);
}

.btn-danger {
  color: var(--danger);
  border-color: var(--danger-bg);
}

.btn-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  min-height: auto;
  padding: 0.375rem 0.5rem;
  font-weight: 500;
}

.btn-ghost:hover {
  background: var(--bg);
  border-color: var(--border);
}

.btn-block {
  width: 100%;
}

/* Forms */

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.field {
  margin-bottom: 1rem;
}

.form-errors {
  background: var(--danger-bg);
  color: var(--danger-text);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}

/* Card-style lists, built from divs (not <table>) so a <turbo-frame> — a custom
 * element — can wrap a whole row without browsers foster-parenting it out of a
 * table's content model. */

.list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0;
  margin: 0 0 1.5rem;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.list-row-title {
  font-weight: 600;
  flex: 1;
}

.list-row-subtitle {
  color: var(--muted);
  font-size: 0.875rem;
}

.list-row > a {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  flex: 1;
  min-width: 0;
  color: inherit;
}

.list-row > a:hover {
  text-decoration: none;
}

.list-row > a:hover .list-row-title {
  color: var(--primary);
  text-decoration: underline;
}

.empty-state {
  color: var(--muted);
  padding: 1.5rem 1rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Set-logging table: Set # / Weight / Reps / actions, aligned with CSS grid */

.set-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr 1fr auto;
  align-items: center;
  gap: 0.75rem;
}

.set-row-header {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 1rem;
}

.set-row form {
  display: inline;
}

.set-row-actions {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
}

.set-entry-form {
  display: flex;
  flex-direction: column;
  width: 100%;
  grid-column: 1 / -1;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
  box-shadow: var(--shadow);
}

.set-entry-form .field {
  margin-bottom: 0;
}

/* Hide "add a set" while a set is being edited, so editing and adding can't
 * happen at once. Reactive to Turbo Frame swaps with no JS needed. */
#set_entries:has(.set-entry-form) ~ #new_set_entry {
  display: none;
}

.plate-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.plate-button {
  flex: 1;
  min-width: 3.5rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.25rem;
}

.plate-reset {
  flex-basis: 100%;
}

/* Rep picker: hidden radios + labels styled as buttons, no JS needed */

.rep-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.rep-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rep-button {
  min-height: 2.75rem;
  padding: 0.5rem 0.25rem;
}

.rep-radio:checked + .rep-button {
  background: var(--success-bg);
  border-color: var(--success-text);
  color: var(--success-text);
}

.rep-radio:focus-visible + .rep-button {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Exercise picker */

.picker-button {
  min-width: 8.5rem;
}

.picker-button.added {
  background: var(--success-bg);
  border-color: var(--success-text);
  color: var(--success-text);
}

.actions-bar {
  margin-bottom: 1.5rem;
}

/* Drag-to-reorder */

.hint {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: -0.5rem;
}

.drag-handle {
  cursor: grab;
  touch-action: none;
  color: var(--muted);
  font-size: 1.25rem;
  padding: 0.25rem 0.5rem;
  user-select: none;
}

.list-row.dragging {
  opacity: 0.4;
}

/* Confirm dialog (replaces the browser's native confirm() for data-turbo-confirm) */

.confirm-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 24rem;
  width: calc(100% - 2rem);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 40px rgba(16, 24, 40, 0.35);
}

.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.confirm-dialog p {
  margin: 0 0 1.25rem;
  font-size: 1rem;
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-field input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
}

.checkbox-field label {
  display: inline;
  font-size: 1rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 0;
}

.badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 999px;
  padding: 0.0625rem 0.5rem;
  margin-left: 0.5rem;
}
