/**
 * Modul: Einstellungen (Settings)
 * Zweck: Styles für die Settings-Seite
 * Abhängigkeiten: tokens.css, layout.css
 */

/* --------------------------------------------------------
 * Modul-Akzent
 * -------------------------------------------------------- */
.settings-page { --module-accent: var(--module-settings); }

/* --------------------------------------------------------
   Seiten-Layout - nutzt layout-center (max 720px)
   -------------------------------------------------------- */

.settings-page {
  max-width: var(--content-max-width-narrow);
  margin: 0 auto;
}

/* --------------------------------------------------------
   Banner (Erfolg / Fehler nach OAuth-Callback)
   -------------------------------------------------------- */

.settings-banner {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
}

.settings-banner--success {
  background: var(--color-success-light);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}

.settings-banner--error {
  background: var(--color-danger-light);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

/* --------------------------------------------------------
   Tab-Navigation
   -------------------------------------------------------- */

.settings-tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-6);
  position: sticky;
  top: 0;
  background: var(--color-bg);
  z-index: 10;
  padding-top: var(--space-1);
}

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

.settings-tab-btn {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4);
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  min-height: 44px;
  white-space: nowrap;
  margin-bottom: -1px;
}

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

.settings-tab-btn--active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* --------------------------------------------------------
   Sections
   -------------------------------------------------------- */

.settings-section {
  margin-bottom: var(--space-8);
}

.settings-section__title {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-tertiary);
  margin: 0 0 var(--space-2) var(--space-1);
}

/* --------------------------------------------------------
   Cards
   -------------------------------------------------------- */

.settings-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

@media (min-width: 1024px) {
  .settings-card {
    padding: var(--space-5);
  }
}

.settings-card--hidden {
  display: none;
}

.settings-card__title {
  font-size: var(--text-base);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-3);
  color: var(--color-text-primary);
}

/* --------------------------------------------------------
   Benutzerinfo
   -------------------------------------------------------- */

.settings-user-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.settings-user-info__name {
  font-size: var(--text-md);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.settings-user-info__username {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: 2px;
}

/* --------------------------------------------------------
   Avatar
   -------------------------------------------------------- */

.settings-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-on-accent);
  flex-shrink: 0;
  user-select: none;
  overflow: hidden;
}

.settings-avatar--sm {
  width: 32px;
  height: 32px;
  font-size: var(--text-sm);
}

.settings-avatar--lg {
  width: 72px;
  height: 72px;
  font-size: var(--text-2xl);
}

.settings-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.settings-avatar-editor {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.settings-avatar-editor__controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

@media (max-width: 520px) {
  .settings-avatar-editor {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------
   Formulare
   -------------------------------------------------------- */

.settings-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.settings-form--compact {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.settings-form-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.form-error {
  font-size: var(--text-sm);
  color: var(--color-danger);
  padding: var(--space-2) var(--space-3);
  background: var(--color-danger-light);
  border-radius: var(--radius-sm);
}

.form-hint {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.form-input--color {
  padding: var(--space-1) var(--space-2);
  height: 44px;
  cursor: pointer;
}

/* --------------------------------------------------------
   Sync-Karten
   -------------------------------------------------------- */

.settings-sync-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.settings-sync-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-sync-logo--google {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
}

.settings-sync-logo--apple {
  background: var(--color-text-primary);
  color: var(--color-bg);
}

.settings-sync-info__name {
  font-size: var(--text-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.settings-sync-info__status {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.settings-sync-info__status--connected {
  color: var(--color-success);
}

.settings-sync-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* --------------------------------------------------------
   Familienmitglieder
   -------------------------------------------------------- */

.settings-members {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.settings-member {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

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

.settings-member__name {
  display: block;
  font-size: var(--text-base);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-member__meta {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-top: 1px;
}

.settings-add-btn {
  width: 100%;
}

.settings-token-output {
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
}

/* --------------------------------------------------------
   Theme-Toggle
   -------------------------------------------------------- */

.theme-toggle {
  display: flex;
  gap: var(--space-2);
}

.theme-toggle__btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 44px;
}

.theme-toggle__btn:hover {
  border-color: var(--color-text-secondary);
  color: var(--color-text-primary);
}

.theme-toggle__btn--active {
  background: var(--color-accent-light);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.theme-toggle__btn--active:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* --------------------------------------------------------
   Meal-Type-Toggles
   -------------------------------------------------------- */

.meal-type-toggles {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  min-height: var(--target-lg);
}

.toggle-row:hover {
  background-color: var(--color-surface-2);
}

.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-accent);
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-row span {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

/* --------------------------------------------------------
   Abmelden
   -------------------------------------------------------- */

.settings-logout-btn {
  width: 100%;
}

/* --------------------------------------------------------
   Einkaufskategorien
   -------------------------------------------------------- */

.cat-list {
  list-style: none;
  margin: 0 0 var(--space-3);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.cat-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-1);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.cat-row:hover {
  background: var(--color-surface-2);
}

.cat-row__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--color-text-secondary);
}

.cat-row__name {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-row__name:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

.cat-row__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.cat-add-form {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.cat-add-form .form-input {
  flex: 1;
}
