/* ── Settings Component ────────────────────────────────────────────────────── */

/* Overlay */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  display: none;
  z-index: 1100;
  transition: opacity 0.35s ease;
}

.settings-overlay--active {
  opacity: 1;
  pointer-events: auto;
  display: block;
}

.samsung .settings-overlay--active {
  background: rgba(0, 0, 0, 0.55);
}

/* Popup shell — morphs from the header button */
.settings-popup {
  position: fixed;
  z-index: 1200;
  background: var(--background-color-secondary);
  border-radius: 50%;
  box-shadow: var(--shadow);
  overflow: clip;
  flex-direction: column;
  /* display:flex set via JS */

  transition:
    transform     0.42s cubic-bezier(0.32, 0.72, 0, 1),
    border-radius 0.42s cubic-bezier(0.32, 0.72, 0, 1),
    box-shadow    0.42s ease;

  will-change: transform;
}

/* Inner content fades in after the morph completes */
.settings-popup__inner {
  opacity: 0;
  transition: opacity 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 0 1.25rem 1.5rem; /* top padding lives in the sticky title row */
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.settings-popup--open .settings-popup__inner {
  opacity: 1;
  transition-delay: 0.28s;
}

/* Title row: sticky header with gradient blur + color fade */
.settings-popup__title-row {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Extend edge-to-edge, cancelling the inner's horizontal padding */
  margin: 0 -1.25rem;
  padding: 1.25rem 1.25rem 0.875rem;
}

/* The blur+color gradient lives on ::before so mask-image can fade both
   simultaneously — the mask affects backdrop-filter output too. */
.settings-popup__title-row::before {
  content: '';
  position: absolute;
  inset: 0;
  bottom: -2.5rem; /* extend into the gap below the row */
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: var(--background-color-secondary);
  -webkit-mask-image: linear-gradient(to bottom, black 45%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 45%, transparent 100%);
  pointer-events: none;
  z-index: -1;
}

/* Close button — flush with inner padding, vertically aligned to title */
.settings-close-btn {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  margin-right: -0.125rem; /* optical alignment to inner padding edge */
  border-radius: 50%;
  border: none;
  background: color-mix(in srgb, var(--text-color-primary) 10%, transparent);
  color: color-mix(in srgb, var(--text-color-primary) 55%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.settings-close-btn .material-symbols-outlined {
  font-size: 18px !important;
}

.settings-popup--open .settings-close-btn {
  opacity: 1;
  transition-delay: 0.28s;
}

@media (hover: hover) {
  .settings-close-btn:hover {
    background: color-mix(in srgb, var(--text-color-primary) 16%, transparent);
    color: var(--text-color-primary);
  }
}

/* Hide the trigger while the popup is morphing */
.settings-btn--morphing {
  visibility: hidden;
}

/* ── Large title ────────────────────────────────────────────────────────────── */

.settings-popup__title {
  font-size: 1.75rem;      /* 28px — Apple "Tile Heading" scale */
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: -0.01em;
  color: var(--text-color-primary);
  margin: 0;
  padding: 0 0.25rem;      /* slight indent aligns with section group padding */
}

/* ── Section ────────────────────────────────────────────────────────────────── */

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Section header: colored icon badge + uppercase label */
.settings-section__header {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 0.25rem;

  text-align: center;
}

.settings-section__icon-badge {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: color-mix(in srgb, var(--text-color-primary) 48%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-section__icon-badge .material-symbols-outlined {
  font-size: 1rem !important;
}

.settings-section__header-label {
  font-size: 1rem;
  font-weight: bold;
  color: color-mix(in srgb, var(--text-color-primary) 48%, transparent);
}

/* ── Group card ─────────────────────────────────────────────────────────────── */

.settings-group {
  background: color-mix(in srgb, var(--text-color-primary) 6%, transparent);
  border-radius: 11px;
  overflow: hidden;
}

/* ── Row ────────────────────────────────────────────────────────────────────── */

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 44px;        /* Apple minimum touch target */
  padding: 0.6rem 0.875rem;
}

/* Separator between rows in the same group */
.settings-row + .settings-row {
  border-top: 0.5px solid color-mix(in srgb, var(--text-color-primary) 10%, transparent);
}


.settings-row__icon-title-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.settings-row__icon-badge {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--badge-color, var(--text-color-accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-row__icon-badge .material-symbols-outlined {
  font-size: 17px !important;
}

.settings-row__label {
  flex: 1;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: -0.014em;
  color: var(--text-color-primary);
}

/* ── Language segmented control ─────────────────────────────────────────────── */

.settings-lang-toggle {
  display: flex;
  flex-direction: row;
  background: color-mix(in srgb, var(--text-color-primary) 10%, transparent);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
  position: relative;
}

.settings-lang-indicator {
  position: absolute;
  top: 3px;
  left: 0;
  border-radius: 8px;
  background: var(--background-color-secondary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14), 0 1px 2px rgba(0, 0, 0, 0.08);
  pointer-events: none;
  z-index: 0;
  transition:
    transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
    width     0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.settings-lang-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0.4rem 0.625rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: color-mix(in srgb, var(--text-color-primary) 50%, transparent);
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.settings-lang-btn__flag {
  font-size: 1rem;
  line-height: 1;
}

.settings-lang-btn__name {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.settings-lang-btn.active {
  color: var(--text-color-primary);
}

/* Icon inside a segmented control button */
.settings-seg-icon {
  font-size: 1.1rem !important;
  line-height: 1;
}

/* Thin vertical rule that visually separates button groups within a toggle */
.settings-seg-separator {
  flex-shrink: 0;
  width: 1px;
  align-self: stretch;
  margin: 4px 4px;
  background: color-mix(in srgb, var(--text-color-primary) 15%, transparent);
}

@media (hover: hover) {
  .settings-lang-btn:not(.active):hover {
    background: color-mix(in srgb, var(--text-color-primary) 12%, transparent);
    color: var(--text-color-primary);
  }
}

/* ── Label group (label + sublabel stacked) ─────────────────────────────────── */

.settings-row__label-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;

  text-align: left;
}

.settings-row__sublabel {
  font-size: 0.75rem;
  font-weight: 400;
  color: color-mix(in srgb, var(--text-color-primary) 48%, transparent);
  letter-spacing: -0.01em;
}

.settings-row__sublabel:empty {
  display: none;
}

/* ── iOS-style toggle switch ────────────────────────────────────────────────── */

.settings-toggle {
  position: relative;
  width: 61px;
  height: 31px;
  border-radius: 16px;
  /* iOS 26: glass track — translucent fill + visible stroke */
  background: color-mix(in srgb, var(--text-color-primary) 10%, transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--text-color-primary) 18%, transparent);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background 0.25s ease,
    box-shadow  0.25s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.settings-toggle.on {
  background: #34C759;
  box-shadow: none;
}

.settings-toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 36px;
  height: 25px;
  border-radius: 12.5px; /* half of height — proper pill shape */
  /* iOS 26: frosted-glass thumb */
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.20),
    0 0.5px 1px rgba(0, 0, 0, 0.10),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.settings-toggle.on .settings-toggle__thumb {
  transform: translateX(19px); /* 61 - 3 - 36 - 3 = 19 */
}

/* ── Stepper control (−  value  +) ──────────────────────────────────────────── */

.settings-stepper {
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--text-color-primary) 10%, transparent);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.settings-stepper__btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.settings-stepper__btn .material-symbols-outlined {
  font-size: 16px !important;
}

@media (hover: hover) {
  .settings-stepper__btn:not(:disabled):hover {
    background: color-mix(in srgb, var(--text-color-primary) 12%, transparent);
  }
}

.settings-stepper__btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.settings-stepper__value {
  min-width: 2.25rem;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-color-primary);
  font-family: inherit;
}

/* ── Campus select picker ────────────────────────────────────────────────────── */

.settings-row--campus-picker {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.settings-campus-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: color-mix(in srgb, var(--text-color-primary) 10%, transparent);
  border: none;
  border-radius: 8px;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-color-primary);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%23888' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}

.settings-campus-select:disabled {
  opacity: 0.4;
  cursor: default;
}
