/* ==========================================================================
   Habitly — Settings page styles
   Owner: Manal Ezzat Ahmed Gad
   -----------------------------------------------------------------------
   Build this page look here. Pull colors, spacing, radii, and type
   from tokens.css — no hardcoded values (see Rules of Engagement).
   Compose from components.css (.card, .pill, .seal, .tally, .ledger-row,
   .check-ring) before inventing a new pattern.
   ========================================================================== */
.settings-page {
  max-width: 640px;
}

.settings-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4, 16px);
}

.settings-panel {
  background: var(--color-bg-elevated, #1a1a1c);
  border: 1px solid var(--color-border, #2c2c2e);
  border-radius: var(--radius-lg, 16px);
  padding: var(--space-5, 24px);
  box-shadow: var(--shadow-card, 0 4px 16px rgba(0, 0, 0, 0.25));
}

.settings-panel__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4, 16px);
}

.settings-panel__title {
  margin: 0 0 var(--space-1, 4px);
  font-size: var(--fs-lg, 18px);
  font-weight: 600;
}

.settings-panel__row .settings-panel__title {
  margin-bottom: 0;
}

.settings-panel__desc {
  margin: 0 0 var(--space-4, 16px);
  color: var(--color-text-secondary, #a1a1aa);
  font-size: var(--fs-sm, 14px);
  line-height: 1.6;
}

.settings-panel__row .settings-panel__desc {
  margin-bottom: 0;
}

.settings-panel--danger {
  border-color: color-mix(in srgb, var(--color-danger, #ef4444) 35%, var(--color-border, #2c2c2e));
}

/* ===== User Profile ===== */
.profile-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4, 16px);
  padding-bottom: var(--space-5, 24px);
  margin-bottom: var(--space-5, 24px);
  border-bottom: 1px solid var(--color-border, #2c2c2e);
}

.avatar-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3, 12px);
}

.avatar-display {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--color-gold, #e9ce8f) 15%, transparent);
  border: 2px solid var(--color-gold, #e9ce8f);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}

.avatar-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2, 8px);
}

.avatar-options button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--color-border, #2c2c2e);
  background: var(--color-bg, #0f0f10);
  font-size: var(--fs-md, 16px);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.avatar-options button:hover {
  transform: translateY(-2px);
}

.avatar-options button.is-selected {
  border-color: var(--color-gold, #e9ce8f);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-gold, #e9ce8f) 25%, transparent);
}

.profile-field {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2, 8px);
}

.profile-field label {
  font-size: var(--fs-sm, 14px);
  color: var(--color-text-secondary, #a1a1aa);
}

.profile-field input {
  background: var(--color-bg, #0f0f10);
  border: 1px solid var(--color-border, #2c2c2e);
  border-radius: var(--radius-md, 10px);
  padding: var(--space-3, 12px) var(--space-4, 16px);
  color: var(--color-text-primary, #f4f4f5);
  font-family: inherit;
  font-size: var(--fs-md, 16px);
}

.profile-field input:focus {
  outline: 2px solid var(--color-gold, #e9ce8f);
  outline-offset: 1px;
}

.profile-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3, 12px);
}

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3, 12px);
}

.profile-stat {
  background: var(--color-bg, #0f0f10);
  border: 1px solid var(--color-border, #2c2c2e);
  border-radius: var(--radius-md, 10px);
  padding: var(--space-4, 16px);
  display: flex;
  flex-direction: column;
  gap: var(--space-1, 4px);
}

.profile-stat--accent {
  border-color: var(--color-gold, #e9ce8f);
  background: color-mix(in srgb, var(--color-gold, #e9ce8f) 8%, transparent);
}

.profile-stat__value {
  font-size: var(--fs-xl, 24px);
  font-weight: 700;
}

.profile-stat__label {
  font-size: var(--fs-xs, 12px);
  color: var(--color-text-secondary, #a1a1aa);
}

/* ===== Theme switch ===== */
.theme-switch {
  position: relative;
  width: 56px;
  height: 30px;
  padding: 3px;
  border-radius: var(--radius-full, 999px);
  border: 1px solid var(--color-border, #2c2c2e);
  background: var(--color-bg, #0f0f10);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 180ms ease;
}

.theme-switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-text-secondary, #a1a1aa);
  transition: transform 180ms ease, background 180ms ease;
}

.theme-switch[aria-pressed="true"] .theme-switch__thumb {
  transform: translateX(26px);
  background: var(--color-gold, #e9ce8f);
}

.theme-switch__icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--color-text-tertiary, #6b6b70);
  pointer-events: none;
}

.theme-switch__icon--sun { left: 6px; }
.theme-switch__icon--moon { right: 6px; }

/* ===== Buttons ===== */
.settings-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3, 12px);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2, 8px);
  border: none;
  border-radius: var(--radius-md, 10px);
  padding: var(--space-3, 12px) var(--space-4, 16px);
  font-family: inherit;
  font-size: var(--fs-sm, 14px);
  font-weight: 600;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn--primary {
  background: var(--color-gold, #e9ce8f);
  color: var(--color-bg, #0f0f10);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-primary, #f4f4f5);
  border: 1px solid var(--color-border, #2c2c2e);
}

.btn--danger {
  background: color-mix(in srgb, var(--color-danger, #ef4444) 14%, transparent);
  color: var(--color-danger, #ef4444);
  border: 1px solid var(--color-danger, #ef4444);
}

.btn__sub {
  font-size: var(--fs-xs, 12px);
  opacity: 0.7;
  font-weight: 500;
}

.settings-status,
.save-status {
  margin: var(--space-3, 12px) 0 0;
  font-size: var(--fs-sm, 14px);
  color: var(--color-sage, #7fa65b);
  min-height: 1.2em;
}

.settings-status.is-error,
.save-status.is-error {
  color: var(--color-danger, #ef4444);
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4, 16px);
  z-index: 50;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal {
  background: var(--color-bg-elevated, #1a1a1c);
  border: 1px solid var(--color-border, #2c2c2e);
  border-radius: var(--radius-lg, 16px);
  padding: var(--space-5, 24px);
  max-width: 380px;
  width: 100%;
}

.modal h3 {
  margin: 0 0 var(--space-2, 8px);
  font-size: var(--fs-lg, 18px);
}

.modal p {
  margin: 0 0 var(--space-4, 16px);
  color: var(--color-text-secondary, #a1a1aa);
  font-size: var(--fs-sm, 14px);
  line-height: 1.6;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3, 12px);
}

@media (max-width: 780px) {
  .settings-page {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .settings-panel__actions {
    flex-direction: column;
  }
  .settings-panel__actions .btn {
    justify-content: center;
  }
  .settings-panel__row {
    flex-wrap: wrap;
  }
  .profile-stats {
    grid-template-columns: 1fr;
  }
}