/* ================================================================
   SETTINGS.CSS — Settings page
   Part of the RustyBlade BootCamp stylesheet, split for maintainability.
   ================================================================ */

/* ================================================================
   SECTION 11: SETTINGS PAGE – PREMIUM REDESIGN
   ================================================================ */

.settings-page {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  overflow-x: hidden;
  max-height: calc(100dvh - 66px - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.settings-page .settings-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.settings-empty-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.settings-empty h3 {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text);
  margin-bottom: 4px;
}
.settings-empty p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Page Intro ── */
.page-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}
.page-intro h2 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.84;
  letter-spacing: -0.075em;
  margin: 4px 0 0;
}
.page-intro h2 em {
  color: var(--accent-text);
  font-style: normal;
}
.eyebrow {
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 2px;
}
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--gold);
  font-size: 9px;
  letter-spacing: 0.14em;
  border: 1px solid #5e4a1c;
  padding: 6px 10px;
  flex-shrink: 0;
}
.status-chip span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}
.page-description {
  max-width: 480px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin: 8px 0 0;
}

/* ── Settings sections ── */
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--border);
  margin-top: 6px;
}
.settings-section-header .settings-section-icon {
  width: 16px;
  height: 16px;
  color: var(--accent);
  flex-shrink: 0;
}
.settings-section-header h2 {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0;
}

.settings-section-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s;
  width: 100%;
}
.settings-card:hover {
  border-color: var(--border-strong);
}

/* ── Danger Zone ── */
.danger-zone .settings-card {
  border-color: var(--red-soft);
  background: rgba(198, 40, 40, 0.02);
}
.danger-zone .settings-section-header h2 {
  color: var(--red);
}
.danger-zone .settings-section-header .settings-section-icon {
  color: var(--red) !important;
}

/* ── Profile Card ── */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s;
}
.profile-card:hover {
  border-color: var(--border-strong);
}

.profile-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid var(--border);
}
.profile-info {
  flex: 1;
  min-width: 0;
}
.profile-name {
  display: flex;
  align-items: center;
  gap: 4px;
}
.profile-name span {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}
.profile-edit-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  width: 20px;
}
.profile-edit-btn:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}
.profile-edit-btn .icon-sm {
  width: 12px;
  height: 12px;
}
.profile-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
  flex-wrap: wrap;
}
.profile-meta .profile-email {
  font-size: 0.7rem;
  color: var(--text-secondary);
}
.profile-meta .profile-role {
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-variant);
  padding: 1px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.profile-username {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}
.profile-username span:first-child {
  font-size: 0.65rem;
  color: var(--text-muted);
}
.profile-username #usernameDisplay {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

/* ── Quick Stats ── */
.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.profile-stats .stat-item {
  text-align: center;
}
.profile-stats .stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.profile-stats .stat-value.gold {
  color: var(--gold);
}
.profile-stats .stat-value.accent {
  color: var(--accent-text);
}
.profile-stats .stat-label {
  font-size: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* ── Body Metrics ── */
.body-metrics {
  margin-top: 8px;
}
.metrics-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.metrics-icon {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}
.metrics-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.metrics-trend {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 20px;
  margin-left: auto;
}
.metrics-trend.up {
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid rgba(46, 125, 50, 0.2);
}
.metrics-trend.down {
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid rgba(198, 40, 40, 0.2);
}
.metrics-trend.stable {
  color: var(--text-muted);
  background: var(--surface-variant);
  border: 1px solid var(--border);
}

.metrics-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.weight-input-group {
  display: flex;
  align-items: center;
  background: var(--surface-variant);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s;
}
.weight-input-group:focus-within {
  border-color: var(--accent);
}
.weight-input-group .weight-input {
  width: 70px;
  padding: 4px 8px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font);
}
.weight-input-group .weight-unit {
  padding-right: 8px;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-muted);
}
.weight-latest {
  font-size: 0.7rem;
  color: var(--text-secondary);
}
.weight-latest strong {
  color: var(--text);
  font-weight: 600;
}

.weight-history {
  margin-top: 6px;
  background: var(--surface-variant);
  border-radius: var(--radius-sm);
  padding: 2px 0;
  max-height: 110px;
  overflow-y: auto;
  border: 1px solid var(--border);
}
.weight-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.weight-entry:last-child {
  border-bottom: none;
}
.weight-entry:hover {
  background: var(--surface-raised);
}
.weight-entry .entry-date {
  font-size: 0.7rem;
  color: var(--text-secondary);
}
.weight-entry .entry-weight {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
}
.weight-entry .entry-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.weight-entry .entry-delete:hover {
  color: var(--red);
  background: var(--red-soft);
}
.weight-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.7rem;
}

/* ── Theme Swatches ── */
.theme-swatches {
  display: flex;
  gap: 6px;
  margin: 4px 0 2px;
  flex-wrap: wrap;
}
.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  background: var(--surface-variant);
}
.swatch:hover {
  transform: scale(1.05);
}
.swatch.selected {
  border-color: var(--text);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.swatch.red { background: #e53935; }
.swatch.gold { background: #c8992e; }
.swatch.blue { background: #4fc3f7; }
.swatch.green { background: #66bb6a; }
.swatch.purple { background: #ba68c8; }
.swatch.brown { background: #8d6e63; }
.swatch.orange { background: #f57c00; }
.swatch.indigo { background: #5c6bc0; }
.swatch.pink { background: #ec407a; }
.swatch.grey { background: #9a9aaa; }
.setting-note {
  color: var(--text-muted);
  font-size: 8px;
  letter-spacing: 0.12em;
  margin-top: 2px;
}

/* ── Settings Row ── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
}
.settings-row-content {
  flex: 1;
  min-width: 0;
}
.settings-row-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}
.settings-row-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.3;
}
.settings-row-control {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.settings-row-control select {
  padding: 4px 8px;
  font-size: 0.7rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-height: 28px;
}
.settings-row-control .btn {
  min-height: 28px;
  padding: 2px 10px;
  font-size: 0.65rem;
}
.settings-row-foot {
  margin-top: 2px;
  font-size: 0.65rem;
  color: var(--text-muted);
}
.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.settings-row-sub {
  padding: 4px 0 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* ── Stacked row for Training ── */
.settings-row-stacked {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 6px 0;
}
.settings-row-stacked .settings-row-content {
  flex: 1;
}
.settings-row-stacked .settings-row-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}
.settings-row-stacked .settings-row-control select {
  flex: 1;
  min-width: 120px;
}
.settings-row-stacked .settings-row-control .template-select-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
}
.settings-row-stacked .settings-row-control .template-select-group select {
  flex: 1;
  min-width: 120px;
}
.settings-row-stacked .settings-row-control .template-status {
  width: 100%;
  margin-top: 2px;
}

.template-select-group {
  display: flex;
  gap: 4px;
  align-items: center;
}
.template-select-group select {
  min-width: 100px;
  padding: 4px 8px;
  font-size: 0.7rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-height: 28px;
}
.template-status {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.template-status.success {
  color: var(--green);
}

/* ── Toggle ── */
.toggle-wrapper {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.toggle-wrapper input {
  display: none;
}
.toggle-track {
  width: 34px;
  height: 18px;
  border-radius: 12px;
  background: var(--border);
  transition: background 0.2s;
  position: relative;
  flex-shrink: 0;
}
.toggle-track .toggle-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
  box-shadow: var(--shadow-sm);
}
.toggle-wrapper input:checked + .toggle-track {
  background: var(--accent);
}
.toggle-wrapper input:checked + .toggle-track .toggle-thumb {
  transform: translateX(16px);
  background: #fff;
}

.status-badge {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.status-badge.success {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-soft);
}
.status-badge.inactive {
  color: var(--text-muted);
  border-color: var(--border);
  background: var(--surface-variant);
}
.status-message {
  font-size: 0.6rem;
  color: var(--text-muted);
}
.status-message.success {
  color: var(--green);
}

.reminder-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.reminder-label {
  font-size: 0.65rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.reminder-controls input[type="time"] {
  padding: 2px 6px;
  font-size: 0.7rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-height: 28px;
}

.danger-note {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  font-style: italic;
}

.settings-footer {
  text-align: center;
  font-size: 0.6rem;
  color: var(--text-muted);
  padding: 8px 0 4px 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.settings-footer a {
  color: var(--text-muted);
}
.settings-footer a:hover {
  color: var(--text);
  text-decoration: underline;
}
.settings-footer .separator {
  color: var(--border);
}
.footer-link-btn {
  background: transparent;
  border: none;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
}
.footer-link-btn:hover {
  color: var(--text);
  text-decoration: underline;
}

/* ── Side by side: Privacy & Data + Help & Support ── */
.settings-side-by-side {
  display: flex;
  gap: 10px;
  width: 100%;
}
.settings-side-by-side > .settings-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.settings-side-by-side > .settings-section .settings-card {
  flex: 1;
  height: 100%;
}

/* ── Training redesign ── */
.training-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s;
  width: 100%;
}
.training-card:hover {
  border-color: var(--border-strong);
}
.training-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
}
.training-row-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
}
.training-row-icon i,
.training-row-icon svg {
  width: 16px !important;
  height: 16px !important;
}
.training-row-content {
  flex: 1;
  min-width: 0;
}
.training-row-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}
.training-row-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.3;
}
.training-current {
  font-size: 0.6rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.training-status-message {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.training-status-message .status-message.success {
  color: var(--green);
}
.training-row-control {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.training-select {
  padding: 4px 8px;
  font-size: 0.7rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-height: 28px;
  min-width: 120px;
}
.training-request-btn {
  min-height: 28px;
  padding: 2px 10px;
  font-size: 0.65rem;
}
.training-request-btn i,
.training-request-btn svg {
  width: 12px !important;
  height: 12px !important;
}
.training-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Obsolete logs (greyed out) ── */
.set-line.obsolete {
  color: var(--text-muted);
  opacity: 0.6;
}
.set-row.obsolete .set-line {
  color: var(--text-muted);
  opacity: 0.6;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  /* FIX (feature request): this used to stack .settings-side-by-side
     into a single column here — the request explicitly wants the
     side-by-side format preserved even on smaller screens, so only the
     gap/padding shrink now, not the layout itself. */
  .settings-side-by-side {
    gap: 6px;
  }
  .settings-page {
    padding: 12px;
    gap: 8px;
  }
  .settings-card {
    padding: 8px 10px;
  }
  .settings-row {
    flex-wrap: wrap;
  }
  .settings-row-control {
    width: 100%;
    justify-content: flex-start;
  }
  .settings-row-stacked .settings-row-control {
    flex-direction: column;
    align-items: stretch;
  }
  .settings-row-stacked .settings-row-control .template-select-group {
    flex-direction: column;
  }
  .settings-row-stacked .settings-row-control .template-select-group select {
    min-width: 0;
  }
  .page-intro {
    flex-direction: column;
    align-items: flex-start;
  }
  .page-intro h2 {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
  }
  .profile-identity {
    flex-wrap: wrap;
  }
  .profile-stats {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2px;
  }
  .theme-swatches {
    gap: 4px;
  }
  .swatch {
    width: 24px;
    height: 24px;
  }
  .metrics-row {
    flex-direction: column;
    align-items: stretch;
  }
  .weight-input-group {
    width: 100%;
  }
  .weight-input-group .weight-input {
    width: 100%;
  }
  .btn .icon-xs,
  .btn .icon-sm,
  .btn i[data-lucide],
  .btn svg {
    width: 10px !important;
    height: 10px !important;
    min-width: 10px;
    min-height: 10px;
  }
  .training-row {
    flex-wrap: wrap;
  }
  .training-row-control {
    width: 100%;
    align-items: stretch;
  }
  .template-select-group {
    flex-wrap: wrap;
    width: 100%;
  }
  .training-select {
    flex: 1;
    min-width: 100px;
  }
  .training-request-btn {
    flex: 0 0 auto;
  }
}

@media (max-width: 400px) {
  .settings-page {
    padding: 8px;
    gap: 6px;
  }
  .settings-card {
    padding: 6px 8px;
  }
  .settings-section-header h2 {
    font-size: 0.65rem;
  }
  .settings-section-header .settings-section-icon {
    width: 14px;
    height: 14px;
  }
  .profile-card {
    padding: 8px 10px;
  }
  .profile-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
  .profile-name span {
    font-size: 0.8rem;
  }
  .profile-stats .stat-value {
    font-size: 0.85rem;
  }
  .profile-stats .stat-label {
    font-size: 0.45rem;
  }
  .settings-row-label {
    font-size: 0.7rem;
  }
  .settings-row-desc {
    font-size: 0.55rem;
  }
  .settings-row-control select {
    font-size: 0.6rem;
    padding: 2px 6px;
  }
  .settings-row-control .btn {
    font-size: 0.55rem;
    padding: 2px 8px;
    min-height: 24px;
  }
  .swatch {
    width: 20px;
    height: 20px;
  }
  .status-chip {
    font-size: 7px;
    padding: 4px 8px;
  }
  .status-chip span {
    width: 4px;
    height: 4px;
  }
}

