/* =============================================================================
   settings.css — Phase 9: Profile & Settings
   Zap Design System
   Covers: settings hub, security, notifications, app settings,
           beneficiaries, and FAQ/support pages.
   ============================================================================= */


/* ─── SETTINGS PAGE LAYOUT ───────────────────────────────────────────────────── */

.settings-page {
  max-width: 560px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) var(--space-2xl);
}

.settings-page-title {
  font-family: var(--font-ui);
  font-size: var(--text-md);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  letter-spacing: -0.2px;
  margin-bottom: var(--space-lg);
}

.settings-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  margin-bottom: var(--space-md);
  transition: color 0.15s;
}

.settings-back-btn:hover {
  color: var(--text-primary);
}

.settings-back-btn img {
  width: 16px;
  height: 16px;
  display: block;
  filter: brightness(0) invert(0.55);
  pointer-events: none;
  transition: filter 0.15s;
}

.settings-back-btn:hover img {
  filter: brightness(0) invert(0.85);
}


/* ─── SETTINGS GROUP ──────────────────────────────────────────────────────────── */

.settings-group {
  margin-bottom: var(--space-lg);
}

.settings-group-label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--font-semi);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0 4px;
  margin-bottom: 8px;
}

.settings-list {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
}


/* ─── SETTINGS ROW ────────────────────────────────────────────────────────────── */

.settings-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
}

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

.settings-row:hover {
  background: var(--bg-hover);
}

.settings-row.danger:hover {
  background: rgba(220, 38, 38, 0.04);
}

/* Non-clickable row (display only) */
.settings-row.static {
  cursor: default;
}

.settings-row.static:hover {
  background: transparent;
}

.settings-row-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-row-icon img {
  width: 17px;
  height: 17px;
  display: block;
  filter: brightness(0) invert(0.6);
  pointer-events: none;
}

.settings-row.danger .settings-row-icon {
  background: rgba(220, 38, 38, 0.06);
  border-color: rgba(220, 38, 38, 0.15);
}

.settings-row.danger .settings-row-icon img {
  filter: brightness(0) saturate(1) invert(0.4) sepia(1) saturate(5) hue-rotate(310deg);
}

.settings-row-body {
  flex: 1;
  min-width: 0;
}

.settings-row-title {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.settings-row.danger .settings-row-title {
  color: var(--danger);
}

.settings-row-sub {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-row-end {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.settings-row-value {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.settings-chevron {
  width: 14px;
  height: 14px;
  display: block;
  filter: brightness(0) invert(0.28);
  pointer-events: none;
}


/* ─── TOGGLE SWITCH ───────────────────────────────────────────────────────────── */

.toggle-switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--success);
  border-color: var(--success);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
  transition: transform 0.2s, background 0.2s;
  pointer-events: none;
}

.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
  background: #ffffff;
}

.toggle-switch input:focus-visible + .toggle-track {
  outline: 2px solid var(--border-active);
  outline-offset: 2px;
}

/* Toggle row variant */
.settings-row.toggle-row {
  cursor: default;
}

.settings-row.toggle-row:hover {
  background: transparent;
}


/* ─── SECURITY PAGE ───────────────────────────────────────────────────────────── */

.security-section {
  margin-bottom: var(--space-lg);
}

/* PIN input group */
.pin-fields {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: var(--space-md) 0;
}

.pin-digit {
  width: 44px;
  height: 52px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

.pin-digit::-webkit-inner-spin-button,
.pin-digit::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.pin-digit:focus {
  border-color: var(--border-active);
}

.pin-digit.filled {
  border-color: var(--text-muted);
}

.pin-digit.error {
  border-color: var(--danger);
}

/* Session card */
.session-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.session-device-icon {
  width: 32px;
  height: 32px;
  display: block;
  filter: brightness(0) invert(0.5);
  flex-shrink: 0;
}

.session-info {
  flex: 1;
  min-width: 0;
}

.session-name {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.session-meta {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.session-current-badge {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--success);
  background: rgba(22, 163, 74, 0.08);
  border: 1px solid rgba(22, 163, 74, 0.2);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.session-revoke-btn {
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--danger);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.session-revoke-btn:hover {
  background: rgba(220, 38, 38, 0.07);
}


/* ─── NOTIFICATION PREFERENCES ───────────────────────────────────────────────── */

.notif-pref-channel {
  margin-bottom: var(--space-lg);
}

.notif-pref-channel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border-bottom: none;
}

.notif-pref-channel-icon {
  width: 16px;
  height: 16px;
  display: block;
  filter: brightness(0) invert(0.55);
}

.notif-pref-channel-name {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-semi);
  color: var(--text-secondary);
  flex: 1;
}

.notif-pref-master-toggle {
  /* reuse toggle-switch */
}

.notif-pref-list {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
}

.notif-pref-list.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.notif-pref-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.notif-pref-label {
  flex: 1;
}

.notif-pref-title {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.notif-pref-sub {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-muted);
}


/* ─── APP SETTINGS ────────────────────────────────────────────────────────────── */

.app-setting-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  min-width: 110px;
  transition: border-color 0.15s;
}

.app-setting-select:focus {
  border-color: var(--border-active);
}

.app-setting-select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.app-setting-select-wrap {
  position: relative;
  flex-shrink: 0;
}

.app-setting-select-wrap::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  pointer-events: none;
}


/* ─── BENEFICIARIES ───────────────────────────────────────────────────────────── */

.beneficiary-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-md);
  overflow-x: auto;
  scrollbar-width: none;
}

.beneficiary-tabs::-webkit-scrollbar {
  display: none;
}

.beneficiary-tab {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.beneficiary-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}

.beneficiary-tab:hover:not(.active) {
  color: var(--text-secondary);
}

/* Beneficiary card */
.beneficiary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.beneficiary-card:hover {
  border-color: var(--border-active);
}

.beneficiary-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-semi);
  color: var(--text-secondary);
  text-transform: uppercase;
}

.beneficiary-info {
  flex: 1;
  min-width: 0;
}

.beneficiary-label {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.beneficiary-value {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.beneficiary-network-tag {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  flex-shrink: 0;
}

.beneficiary-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.beneficiary-action-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.beneficiary-action-btn:hover {
  background: var(--bg-hover);
}

.beneficiary-action-btn img {
  width: 15px;
  height: 15px;
  display: block;
  filter: brightness(0) invert(0.4);
  pointer-events: none;
  transition: filter 0.15s;
}

.beneficiary-action-btn:hover img {
  filter: brightness(0) invert(0.7);
}

.beneficiary-action-btn.delete:hover {
  background: rgba(220, 38, 38, 0.07);
}

.beneficiary-action-btn.delete:hover img {
  filter: brightness(0) saturate(1) invert(0.4) sepia(1) saturate(5) hue-rotate(310deg);
}

/* Add beneficiary button */
.add-beneficiary-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: none;
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.add-beneficiary-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-active);
  color: var(--text-secondary);
}

.add-beneficiary-btn img {
  width: 16px;
  height: 16px;
  display: block;
  filter: brightness(0) invert(0.35);
  pointer-events: none;
  transition: filter 0.15s;
}

.add-beneficiary-btn:hover img {
  filter: brightness(0) invert(0.55);
}


/* ─── BENEFICIARY EMPTY STATE ─────────────────────────────────────────────────── */

.beneficiary-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  text-align: center;
  gap: 8px;
}

.beneficiary-empty img {
  width: 40px;
  height: 40px;
  display: block;
  opacity: 0.2;
  filter: brightness(0) invert(1);
  margin-bottom: 4px;
}

.beneficiary-empty-title {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
}

.beneficiary-empty-sub {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-muted);
  max-width: 220px;
  line-height: 1.5;
}


/* ─── FAQ + SUPPORT ───────────────────────────────────────────────────────────── */

.support-page {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) var(--space-2xl);
}

.support-search-wrap {
  position: relative;
  margin-bottom: var(--space-lg);
}

.support-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  display: block;
  filter: brightness(0) invert(0.4);
  pointer-events: none;
}

.support-search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 12px 16px 12px 38px;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}

.support-search-input::placeholder {
  color: var(--text-muted);
}

.support-search-input:focus {
  border-color: var(--border-active);
}

/* Contact options */
.support-contacts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: var(--space-lg);
}

.support-contact-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  border: none;
  width: 100%;
  text-align: left;
}

.support-contact-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-active);
}

.support-contact-icon {
  width: 32px;
  height: 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.support-contact-icon img {
  width: 16px;
  height: 16px;
  display: block;
  filter: brightness(0) invert(0.6);
}

.support-contact-title {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.support-contact-sub {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* FAQ category */
.faq-category {
  margin-bottom: var(--space-lg);
}

.faq-category-label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--font-semi);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0 4px;
  margin-bottom: 8px;
}

/* FAQ accordion item */
.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 6px;
}

.faq-question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}

.faq-question:hover {
  background: var(--bg-hover);
}

.faq-chevron {
  width: 16px;
  height: 16px;
  display: block;
  filter: brightness(0) invert(0.35);
  flex-shrink: 0;
  pointer-events: none;
  transition: transform 0.2s, filter 0.15s;
}

.faq-item.open .faq-chevron {
  transform: rotate(90deg);
  filter: brightness(0) invert(0.6);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.faq-item.open .faq-answer {
  max-height: 400px;
}

.faq-answer-inner {
  padding: 0 16px 16px;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.65;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
}

/* Search no-results */
.faq-no-results {
  text-align: center;
  padding: 40px 20px;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Hidden by search filter */
.faq-item.hidden,
.faq-category.hidden {
  display: none;
}


/* ─── FORM ELEMENTS (shared) ─────────────────────────────────────────────────── */

.settings-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}

.settings-input::placeholder {
  color: var(--text-muted);
}

.settings-input:focus {
  border-color: var(--border-active);
}

.settings-input.error {
  border-color: var(--danger);
}

.settings-field-error {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--danger);
  margin-top: 5px;
  display: none;
}

.settings-field-error.visible {
  display: block;
}

.settings-form-group {
  margin-bottom: var(--space-md);
}

.settings-form-label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
}

.settings-submit-btn {
  width: 100%;
  padding: 13px;
  background: var(--text-primary);
  color: var(--bg-base);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-semi);
  cursor: pointer;
  margin-top: var(--space-md);
  transition: opacity 0.15s;
}

.settings-submit-btn:hover {
  opacity: 0.85;
}

.settings-submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.settings-submit-btn.loading {
  opacity: 0.5;
  pointer-events: none;
}


/* ─── MODAL (shared for add/edit beneficiary) ────────────────────────────────── */

.settings-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.settings-modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.settings-modal {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 20px 36px;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-modal-overlay.open .settings-modal {
  transform: translateY(0);
}

.settings-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.settings-modal-title {
  font-family: var(--font-ui);
  font-size: var(--text-md);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.settings-modal-close {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.settings-modal-close:hover {
  background: var(--bg-hover);
}

.settings-modal-close img {
  width: 16px;
  height: 16px;
  display: block;
  filter: brightness(0) invert(0.5);
  pointer-events: none;
}


/* ─── RESPONSIVE ─────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .support-contacts {
    grid-template-columns: 1fr;
  }

  .settings-modal {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .faq-answer,
  .settings-modal,
  .settings-modal-overlay {
    transition: none;
  }
}

/* From Phase 9 notifications page */
.settings-hint-row { padding: 8px 4px; }
