/*
 * KPRATIVE Mini App v1.1 — Settings (TASK 8/N).
 * Source: docs/FIGMA_V1_1_CLAUDE_IMPLEMENTATION_GUIDE.md §24, canonical
 * nodes 420:2/421:80/422:144/423:183 (RU/EN × Light/Dark), 425:229/
 * 425:295/425:361 (320/342/360). Settings ControlRow (416:1063, 322×76)
 * and Toggle (417:1063, 44×26) geometry via the --kp-settingsrow- and
 * --kp-toggle- prefixed tokens already extracted into tokens.css during
 * the Task 1 foundation research.
 *
 * Calendar connection action, redirect, and error classes
 * (.kp-cal-connection__action, __redirect, __error) are intentionally
 * reused from calendar.css rather than duplicated here — see the reuse
 * note at the top of that file's connection-banner section.
 */

.kp-settings {
  display: flex;
  flex-direction: column;
  /* TASK 13/N UI HOTFIX (round 2): matches .kp-projects's own major-
     section gap (projects.css) exactly -- the requirement is parity with
     that already-established rhythm, not an arbitrary number. Paired
     with the real border added by the previous round's --kp-settings-
     card-* tokens (below), 8px reads as clearly separated, not touching,
     in both themes -- see projects.css's identical value/precedent. */
  gap: 8px;
  padding-top: 4px;
}

.kp-settings-row {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--kp-settingsrow-h);
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--kp-settings-card-bg);
  border: 1px solid var(--kp-settings-card-border);
}
.kp-settings-row__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kp-settings-row__label { margin: 0; color: var(--kp-text-primary); font-family: "Manrope", Arial, sans-serif; font-weight: 600; font-size: 14px; }
.kp-settings-row__value { margin: 0; color: var(--kp-text-secondary); font-family: "Manrope", Arial, sans-serif; font-size: 12px; }

/* ---- Language segmented control (2 or more real supported_locales,
   never a hardcoded RU/EN pair -- the backend's own supported_locales
   list is the source of truth per its documented comment). ---- */
.kp-settings-lang { display: flex; gap: 8px; flex-wrap: wrap; }
.kp-settings-lang__option {
  border: 1px solid var(--kp-border-subtle);
  border-radius: 12px;
  padding: 8px 14px;
  background: var(--kp-surface);
  color: var(--kp-text-secondary);
  font-family: "Manrope", Arial, sans-serif;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.kp-settings-lang__option.is-selected { background: var(--kp-accent-primary); border-color: var(--kp-accent-primary); color: var(--kp-background); }
.kp-settings-lang__option:focus-visible { outline: 2px solid var(--kp-accent-primary); outline-offset: 2px; }

/* ---- Timezone select -- native <select>, styled minimally; the real
   IANA zone list is a curated set (ported verbatim from the proven
   production SETTINGS_TIMEZONES array -- the backend returns only the
   current value, never a canonical list) with the current value always
   included even if it falls outside the curated set. ---- */
.kp-settings-timezone {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid var(--kp-border-subtle);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--kp-surface);
  color: var(--kp-text-primary);
  font-family: "Manrope", Arial, sans-serif;
  font-size: 14px;
}

/* ---- Toggle (417:1063, 44×26) -- native checkbox visually replaced,
   real state/change events preserved for accessibility + testability. ---- */
.kp-settings-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.kp-settings-toggle__label { flex: 1 1 auto; min-width: 0; margin: 0; color: var(--kp-text-primary); font-family: "Manrope", Arial, sans-serif; font-size: 13px; }
.kp-settings-toggle__input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.kp-settings-toggle__track {
  flex: none;
  position: relative;
  width: var(--kp-toggle-w);
  height: var(--kp-toggle-h);
  border-radius: 999px;
  background: var(--kp-border-subtle);
  transition: background 0.15s ease;
}
.kp-settings-toggle__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(var(--kp-toggle-h) - 4px);
  height: calc(var(--kp-toggle-h) - 4px);
  border-radius: 50%;
  background: var(--kp-surface);
  transition: transform 0.15s ease;
}
.kp-settings-toggle__input:checked + .kp-settings-toggle__track { background: var(--kp-accent-primary); }
.kp-settings-toggle__input:checked + .kp-settings-toggle__track::after {
  transform: translateX(calc(var(--kp-toggle-w) - var(--kp-toggle-h)));
}
.kp-settings-toggle__input:focus-visible + .kp-settings-toggle__track { outline: 2px solid var(--kp-accent-primary); outline-offset: 2px; }

.kp-settings-error { margin: 0; color: var(--kp-recovery); font-family: "Manrope", Arial, sans-serif; font-size: 12px; }
.kp-settings-error__retry {
  border: 1px solid var(--kp-border-subtle);
  border-radius: 12px;
  padding: 8px 16px;
  background: transparent;
  color: var(--kp-text-primary);
  cursor: pointer;
}

.kp-settings-loading { padding: 14px 0; color: var(--kp-text-secondary); }

/* V2-EXPLAINABLE-MEMORY-001: compact memory items inside the Settings card */
.kp-memory-item { display: flex; flex-direction: column; gap: 4px; padding-top: 10px; border-top: 1px solid var(--kp-settings-card-border); }
.kp-memory-item__badge { font-weight: 600; }
