/* Guild settings: the tab rail and the panels behind it. */

/* Guild settings: a rail of tabs beside the panel on wide screens (a row of tabs
   below 1100px), sections as rows (heading and note left, controls right), and
   one save bar that stays in view. The card does not clip, so the timezone
   panel can open past it; the rail and save bar round their own corners. */
.settings-card.settings-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: none;
  padding: 0;
}

.settings-panel > .editor-tabs {
  margin: 0;
  padding: 10px 26px 0;
  border-bottom: 1px solid var(--border);
}

.settings-rail .ui-icon {
  width: 16px;
  height: 16px;
  flex: none;
}

.settings-rail small {
  display: none;
}

.settings-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.settings-body {
  flex: 1;
  padding: 6px 30px 28px;
  container: settings / inline-size;
}

.settings-body > .form-alert {
  margin-top: 18px;
}

.settings-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 30px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
  background: var(--bg-secondary);
}

.settings-actions .form-note {
  margin: 0 !important;
}

.settings-card.settings-panel > .settings-main > .settings-actions .button {
  margin-top: 0;
}

@media (min-width: 1100px) {
  .settings-card.settings-panel {
    grid-template-columns: 248px minmax(0, 1fr);
  }

  .settings-panel > .settings-rail {
    flex-direction: column;
    align-self: stretch;
    gap: 4px;
    padding: 16px 12px;
    overflow: visible;
    border-bottom: 0;
    border-right: 1px solid var(--border);
    border-radius: 10px 0 0 10px;
    background: var(--bg-secondary);
  }

  .settings-rail button {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 54px;
    margin: 0;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    white-space: normal;
    text-align: left;
  }

  .settings-rail button:hover {
    background: var(--bg-card);
  }

  .settings-rail button[aria-selected="true"] {
    border-color: var(--border-warm);
    background: var(--bg-warm);
  }

  .settings-rail button[aria-selected="true"] .ui-icon {
    color: var(--accent);
  }

  .settings-rail button:focus-visible {
    border-radius: 8px;
  }

  .settings-rail-text {
    display: grid;
    gap: 2px;
    min-width: 0;
  }

  .settings-rail small {
    display: block;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.35;
    color: var(--text-muted);
  }

  .settings-actions {
    border-radius: 0 0 10px 0;
  }
}

/* A section row. Its legend stays floated, so it is a grid item rather than
   the fieldset's caption. */
#settings-form .settings-row,
#settings-form fieldset.form-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 0;
  padding: 24px 0;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  min-width: 0;
}

#settings-form .settings-tab > :first-child {
  border-top: 0;
}

#settings-form .settings-row > h3,
#settings-form .form-section > legend {
  float: left;
  width: auto;
  margin: 0;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.1px;
}

#settings-form .settings-row > .form-note,
#settings-form .form-section > .form-note {
  margin: 6px 0 0 !important;
  max-width: 62ch;
}

#settings-form .section-body {
  min-width: 0;
  margin-top: 16px;
}

#settings-form .section-body > :first-child,
#settings-form .section-body > .form-grid > label,
#settings-form .section-body > .form-grid > .tz-field {
  margin-top: 0;
}

#settings-form .section-body > .form-grid + .form-grid,
#settings-form .section-body > .field-error + .form-grid {
  margin-top: 16px;
}

#settings-form .section-body > .choice-grid,
#settings-form .section-body > .option-grid {
  margin-top: 0;
}

#settings-form .section-body > .option-grid + .choice-grid {
  margin-top: 10px;
}

@container settings (min-width: 700px) {
  #settings-form .settings-row,
  #settings-form fieldset.form-section {
    grid-template-columns: minmax(0, 240px) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    column-gap: 40px;
    align-items: start;
  }

  #settings-form .settings-row > h3,
  #settings-form .form-section > legend {
    grid-column: 1;
    grid-row: 1;
  }

  #settings-form .settings-row > .form-note,
  #settings-form .form-section > .form-note {
    grid-column: 1;
    grid-row: 2;
  }

  #settings-form .section-body {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin-top: 0;
  }

  /* Errors after a shared section line up with its controls. */
  #settings-form .settings-tab > .field-error {
    margin-left: 280px;
  }
}

/* Three selects in a row need room; a narrower panel shows two, then one. */
@container settings (max-width: 800px) {
  #settings-form .section-body > .form-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* A narrow panel stacks its fields, so a timezone or channel name fits. */
@container settings (max-width: 560px) {
  #settings-form .section-body > .form-grid,
  #settings-form .section-body > .form-grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Checkbox tiles share one even grid; option cards one of their own. */
#settings-form .choice-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr));
}

#settings-form .option-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr));
}

#settings-form .option-grid > .archive-choice {
  margin: 0;
}

.settings-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.settings-facts div {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
}

.settings-facts dt {
  font-size: 11px;
  color: var(--text-muted);
}

.settings-facts dd {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 600;
}

#settings-form .discord-sync {
  margin-top: 0;
}

#settings-form .permission-list {
  margin-top: 0;
}

#settings-form .section-body > .permission-list + .form-note {
  margin-top: 12px !important;
}

#settings-form .section-body > .button {
  margin-top: 12px;
}

/* The bot's server avatar on the Discord tab: a round preview beside its buttons. */
#settings-form .bot-avatar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

#settings-form .bot-avatar {
  width: 64px;
  height: 64px;
  border: 1px solid var(--border);
  border-radius: 50%;
  object-fit: cover;
}

#settings-form .bot-avatar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* The upload label is a button, not a field label: no field spacing. */
#settings-form .bot-avatar-actions > * {
  margin-top: 0;
}

#settings-form label.button.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* The timezone picker: a button like a select, and a panel with a search box
   over a scrolling list. */
.tz-field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.tz-label {
  font-size: 12px;
  font-weight: 500;
}

.tz-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 10px 34px 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  /* The one select chevron, like every dashboard select. */
  background: var(--bg-secondary) var(--select-chevron) no-repeat right 12px
    center;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.tz-button:hover {
  border-color: var(--border-hover);
}

.tz-button:focus-visible,
.tz-button[aria-expanded="true"] {
  border-color: var(--accent-border);
  outline: 2px solid var(--focus-ring);
  outline-offset: -1px;
}

.tz-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tz-offset,
.tz-list small {
  flex: none;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.tz-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  min-width: min(300px, calc(100vw - 32px));
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  box-shadow: 0 14px 36px rgb(0 0 0 / 45%);
}

.tz-panel[hidden] {
  display: none;
}

.settings-card .tz-search {
  min-height: 40px;
}

.tz-list {
  position: relative;
  max-height: 288px;
  margin: 6px 0 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.tz-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.tz-list li:hover,
.tz-list li.is-active {
  background: var(--bg-secondary);
}

.tz-list li[aria-selected="true"] {
  color: var(--accent);
  font-weight: 600;
}

.tz-empty {
  padding: 12px 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.permission-list,
.command-list {
  display: grid;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}

.permission-list li,
.command-list li {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  font-size: 12px;
}

.permission-list strong,
.command-list code {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.permission-list span,
.command-list span {
  color: var(--text-secondary);
  line-height: 1.6;
}

.permission-list .is-ok {
  border-color: var(--success-border);
}

.permission-list .is-ok strong {
  color: var(--success);
}

.permission-list .is-missing {
  border-color: var(--warning-border);
}

.permission-list .is-missing strong {
  color: var(--warning);
}

.command-list code {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.command-rules {
  display: grid;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
}

.command-rule {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
  gap: 8px 16px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
}

.command-rule-name {
  display: grid;
  gap: 4px;
  min-width: 0;
  font-size: 12px;
}

.command-rule-name code {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.command-rule-name span {
  color: var(--text-secondary);
  line-height: 1.5;
}

.command-rule > label {
  display: grid;
  gap: 6px;
  font-size: 12px;
}

.command-rule-roles,
.command-rule .field-error {
  grid-column: 1 / -1;
}

.command-rule-roles[hidden],
.command-rule .field-error:empty {
  display: none;
}

/* The Access tab's /guildbank row: the rule in words, and a link to its control. */
.command-rule-text a {
  color: var(--accent);
}

.command-rule-text a:hover {
  color: var(--accent-hover);
}

@media (max-width: 640px) {
  .settings-panel > .editor-tabs {
    padding: 6px 12px 0;
    overflow-x: auto;
  }

  .settings-body {
    padding: 4px 18px 22px;
  }

  .settings-actions {
    padding: 12px 18px;
  }

  .settings-facts,
  .permission-list li,
  .command-list li,
  .command-rule {
    grid-template-columns: 1fr;
  }
}

/* The Warcraft Logs tab: the connection's status card and its form. */
#settings-form .wcl-status,
#settings-form .wcl-form {
  display: grid;
  gap: 12px;
  max-width: 560px;
}

#settings-form .wcl-status > *,
#settings-form .wcl-form > * {
  margin: 0;
}

#settings-form .wcl-status .button,
#settings-form .wcl-form > .button {
  justify-self: start;
}

#settings-form .wcl-guild {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
  overflow-wrap: anywhere;
}

#settings-form .wcl-warning {
  color: var(--warning);
}

/* Secret saved: the label, the state and the Replace button on one line. */
#settings-form .wcl-secret {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}

#settings-form .wcl-secret-label {
  flex-basis: 100%;
  font-size: 13px;
  font-weight: 500;
}

#settings-form .wcl-secret-saved {
  color: var(--text-muted);
  font-size: 14px;
}

#settings-form .wcl-steps {
  margin: 0;
  padding-left: 20px;
  max-width: 62ch;
  font-size: 14px;
  color: var(--text-muted);
}

#settings-form .wcl-steps li + li {
  margin-top: 6px;
}

/* The redirect URL to paste, on its own line under its step */
#settings-form .wcl-redirect {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

#settings-form .wcl-redirect code {
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
  user-select: all;
}

@media (max-width: 480px) {
  #settings-form .wcl-status .settings-facts {
    grid-template-columns: minmax(0, 1fr);
  }
}
