/* ============================================================
   Settings Page — agentic-ui-kit layout & components
   Scoped to #settings; uses design tokens from main.css
   ============================================================ */

/* --- Page shell --- */
#settings.settings-page {
  min-height: 100%;
  box-sizing: border-box;
}

#settings .settings-wrap {
  padding: clamp(18px, 3vw, 36px);
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#settings .settings-header {
  margin: 0;
}

#settings .settings-title {
  margin: 0 0 4px;
  font-family: Lato, sans-serif;
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text, var(--textfield-textcolor, #fff));
}

#settings .settings-desc {
  margin: 0;
  font-size: 0.96rem;
  color: var(--text-dim, color-mix(in srgb, var(--textfield-textcolor, #fff) 72%, transparent));
  line-height: 1.55;
}

/* --- Accordion container --- */
#settings .settings-accordion {
  display: block;
  border: 1px solid var(--hairline-2, rgba(255, 255, 255, 0.09));
  border-radius: var(--r-md, 14px);
  overflow: hidden;
  background: var(--surface, var(--color-primary, #222f45));
  box-shadow: var(--shadow-1, 0 4px 16px -8px rgba(0, 0, 0, 0.7));
}

#settings .settings-accordion > st0rm-foldable-section {
  display: block;
  border-bottom: 1px solid var(--hairline-2, rgba(255, 255, 255, 0.09));
}

#settings .settings-accordion > st0rm-foldable-section:last-child {
  border-bottom: 0;
}

/* --- Foldable headlines --- */
#settings st0rm-foldable-section > st0rm-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 15px 20px;
  width: 100%;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text, var(--textfield-textcolor, #fff));
  font-family: Lato, sans-serif;
  font-size: 0.98rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  outline: none;
  filter: none;
  transition: background 0.15s ease;
  box-sizing: border-box;
}

#settings st0rm-foldable-section > st0rm-headline:hover {
  background: var(--hairline-2, rgba(255, 255, 255, 0.06));
  filter: none;
}

#settings st0rm-foldable-section > st0rm-headline.active {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent, var(--color-active)) 14%, transparent), transparent 68%),
    color-mix(in srgb, var(--surface, var(--color-primary)) 46%, transparent);
  filter: none;
}

/* Chevron arrow (UI-kit .arr pattern) */
#settings st0rm-foldable-section > st0rm-headline::after {
  content: "";
  flex: none;
  float: none;
  margin: 0;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--accent, var(--color-active));
  border-bottom: 2px solid var(--accent, var(--color-active));
  border-top: none;
  border-left: none;
  background: none;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

#settings st0rm-foldable-section > st0rm-headline.active::after {
  content: "";
  transform: rotate(225deg);
}

/* --- Accordion content (grid 0fr/1fr — smooth open/close) --- */
#settings st0rm-foldable-section > .content {
  display: grid;
  grid-template-rows: 0fr;
  max-height: none;
  overflow: hidden;
  margin: 0;
  padding: 0 20px;
  box-sizing: border-box;
  transition: grid-template-rows 0.28s ease, padding 0.28s ease;
}

#settings st0rm-foldable-section > .content.is-expanded {
  grid-template-rows: 1fr;
  padding: 20px;
}

#settings st0rm-foldable-section > .content > .content-inner {
  overflow: hidden;
  min-height: 0;
}

/* --- Theme grid --- */
#settings .settings-theme-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  width: 100%;
  padding: 0;
  background: transparent;
  overflow-x: visible;
  overflow-y: visible;
  flex-flow: row wrap;
  align-content: flex-start;
}

#settings .settings-theme-grid > st0rm-menu-tile {
  flex: 0 0 76px;
  width: 76px;
  height: 76px;
  min-width: 76px;
  min-height: 76px;
  max-width: 76px;
  max-height: 76px;
  aspect-ratio: 1;
  font-size: 0.72rem !important;
  border-radius: var(--r-md, 14px);
  border: 1px solid var(--hairline-2, rgba(255, 255, 255, 0.09));
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  overflow: hidden;
  word-break: break-word;
  line-height: 1.2;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

#settings .settings-theme-grid > st0rm-menu-tile:hover {
  border-color: var(--ring-dim, color-mix(in srgb, var(--color-active) 26%, transparent));
  transform: translateY(-1px);
}

#settings .settings-theme-grid > st0rm-menu-tile.selected {
  outline: none;
  border-color: var(--accent, var(--color-active));
  box-shadow: 0 0 0 2px var(--bg, var(--background)), 0 0 0 4px var(--accent, var(--color-active));
}

/* --- Profile form grid --- */
#settings st0rm-optionsfield {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 20px;
  row-gap: 22px;
  width: 100%;
}

#settings st0rm-optionsfield-option:last-child {
  grid-column: 1 / -1;
}

#settings st0rm-optionsfield-option {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 !important;
  float: none;
}

#settings st0rm-optionsfield-option > label {
  float: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text, var(--textfield-textcolor, #fff));
}

#settings st0rm-optionsfield-option .input,
#settings st0rm-optionsfield-option input,
#settings st0rm-foldable-section input {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  font-family: Lato, sans-serif;
  font-size: 0.95rem;
  color: var(--text, var(--textfield-textcolor, #fff));
  background: var(--bg-2, var(--textfield-background, #172030));
  border: 1px solid var(--hairline, rgba(255, 255, 255, 0.15));
  border-radius: var(--r-md, 14px);
  padding: 12px 14px;
  height: auto;
  outline: none;
  filter: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

#settings st0rm-optionsfield-option .select,
#settings st0rm-optionsfield-option select,
#settings st0rm-foldable-section select {
  width: 100%;
  max-width: none;
  min-width: 0;
  box-sizing: border-box;
  appearance: none;
  cursor: pointer;
  font-family: Lato, sans-serif;
  font-size: 0.95rem;
  color: var(--text, var(--textfield-textcolor, #fff));
  background: var(--bg-2, var(--textfield-background, #172030));
  border: 1px solid var(--hairline, rgba(255, 255, 255, 0.15));
  border-radius: var(--r-md, 14px);
  padding: 12px 38px 12px 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2393a8b3' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  outline: none;
  filter: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#settings st0rm-optionsfield-option input::placeholder {
  color: var(--text-faint, var(--color-placeholder, #7a7a7a));
}

#settings st0rm-optionsfield-option input:hover,
#settings st0rm-optionsfield-option select:hover,
#settings st0rm-foldable-section input:hover,
#settings st0rm-foldable-section select:hover {
  border-color: var(--ring-dim, color-mix(in srgb, var(--color-active) 26%, transparent));
  filter: none;
}

#settings st0rm-optionsfield-option input:focus,
#settings st0rm-optionsfield-option select:focus,
#settings st0rm-foldable-section input:focus,
#settings st0rm-foldable-section select:focus {
  outline: none;
  border-color: var(--accent, var(--color-active));
  box-shadow: 0 0 0 3px var(--focus, color-mix(in srgb, var(--color-active) 35%, transparent));
  filter: none;
}

/* --- Buttons (UI-kit) --- */
#settings .btn {
  appearance: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: Lato, sans-serif;
  font-weight: 500;
  font-size: 0.98rem;
  color: var(--text, var(--textfield-textcolor, #fff));
  background: var(--surface-2, var(--color-primary));
  border-radius: var(--r-pill, 999px);
  padding: 12px 24px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

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

#settings .btn:active {
  transform: translateY(0);
}

#settings .btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus, color-mix(in srgb, var(--color-active) 35%, transparent));
}

#settings .btn--danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger, #fb7185) 40%, transparent);
  color: var(--danger, #fb7185);
}

#settings .btn--danger:hover {
  background: color-mix(in srgb, var(--danger, #fb7185) 14%, transparent);
  color: var(--danger, #fb7185);
}

/* --- Responsive --- */
@media (max-width: 520px) {
  #settings .settings-wrap {
    padding: 14px 14px 24px;
    gap: 14px;
  }

  #settings st0rm-foldable-section > .content {
    padding-left: 16px;
    padding-right: 16px;
  }

  #settings st0rm-foldable-section > .content.is-expanded {
    padding: 20px 16px;
  }

  #settings st0rm-foldable-section > st0rm-headline {
    padding-left: 16px;
    padding-right: 16px;
  }

  #settings st0rm-optionsfield {
    grid-template-columns: 1fr;
    row-gap: 18px;
  }

  #settings st0rm-optionsfield-option:last-child {
    grid-column: auto;
  }

  #settings .settings-theme-grid {
    gap: 12px;
  }

  #settings .settings-theme-grid > st0rm-menu-tile {
    flex: 0 0 68px;
    width: 68px;
    height: 68px;
    min-width: 68px;
    min-height: 68px;
    max-width: 68px;
    max-height: 68px;
    font-size: 0.65rem !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  #settings st0rm-foldable-section > .content {
    transition-duration: 0.001ms;
  }

  #settings st0rm-foldable-section > st0rm-headline::after,
  #settings .settings-theme-grid > st0rm-menu-tile,
  #settings .btn {
    transition-duration: 0.001ms;
  }
}
