/* The raid editor and dialogs: tabs, form sections, checkbox chips, the
   Schedule tab and the shared select, number and date fields. */

/* Editor and dialogs */
.form-alert {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
}

.field-error {
  font-size: 11px;
  color: var(--danger);
  margin-top: 5px;
}

/* A warning paragraph: the warning colors in a small box, spaced from the
   text and lists around it (the dialog form's grid gap spaces it there). */
p.fact-warning {
  margin: 10px 0;
  padding: 9px 12px;
  border: 1px solid var(--warning-border);
  border-radius: 8px;
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 13px;
  line-height: 1.5;
}

.permission-warning {
  font-size: 11px;
  line-height: 1.6;
  color: var(--warning);
  margin-top: 6px;
}

.permission-warning:empty {
  display: none;
}

.field-error:empty {
  display: none;
}

#signup-dialog {
  max-width: 600px;
}

/* Raid editor: header and tabs on top, the panel scrolls, actions stay below. */
#raid-dialog {
  max-width: 720px;
  padding: 0;
  overflow: hidden;
}

#raid-dialog.has-preview {
  max-width: 1240px;
}

.editor-tabbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.editor-tabbar .editor-tabs {
  margin-top: 0;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.preview-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: none;
  margin-bottom: 8px;
  padding: 7px 12px 7px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.preview-toggle::before {
  content: "";
  width: 28px;
  height: 16px;
  border-radius: 999px;
  background: var(--bg-hover)
    radial-gradient(circle at 8px 50%, var(--text-muted) 5px, transparent 5.5px);
  transition: background 0.15s;
}

.preview-toggle[aria-pressed="true"] {
  border-color: var(--accent-border);
  color: var(--text-primary);
}

.preview-toggle[aria-pressed="true"]::before {
  background: var(--accent)
    radial-gradient(
      circle at 20px 50%,
      var(--accent-ink) 5px,
      transparent 5.5px
    );
}

.preview-toggle:hover {
  border-color: var(--border-hover);
}

.preview-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.editor-preview {
  flex: none;
  width: 500px;
  overflow-y: auto;
  padding: 20px 22px 24px;
  border-left: 1px solid var(--border);
  background: var(--bg-secondary);
}

.editor-preview[hidden] {
  display: none;
}

.editor-preview .discord-preview {
  max-width: none;
}

.editor-preview > .form-note {
  margin-top: 12px !important;
}

@media (max-width: 1099px) {
  #raid-dialog.has-preview {
    max-width: 720px;
  }

  /* One at a time: the preview covers the fields until a tab is chosen. */
  #raid-dialog.has-preview .editor-body {
    display: none;
  }

  .editor-preview {
    width: auto;
    flex: 1;
    border-left: 0;
  }
}

#raid-form {
  display: flex;
  flex-direction: column;
  /* One height for every tab, so switching tabs doesn't resize the dialog. */
  height: min(820px, calc(100dvh - 37px));
}

.editor-head {
  padding: 26px 29px 0;
  border-bottom: 1px solid var(--border);
}

.editor-tabs {
  display: flex;
  gap: 4px;
  margin-top: 18px;
  overflow-x: auto;
  scrollbar-width: none;
}

.editor-tabs button {
  position: relative;
  flex: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 14px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.editor-tabs button:hover {
  color: var(--text-primary);
}

.editor-tabs button[aria-selected="true"] {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

.editor-tabs button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
  border-radius: 6px 6px 0 0;
}

.tab-error {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--danger);
  color: var(--bg-primary);
  font-size: 10px;
  font-weight: 700;
}

.tab-error[hidden] {
  display: none;
}

.editor-main {
  display: flex;
  flex: 1;
  min-height: 0;
}

.editor-body {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 29px 26px;
}

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

.editor-actions {
  margin-top: 0;
  padding: 16px 29px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#raid-form label.half-width {
  max-width: calc(50% - 9px);
}

@media (max-width: 640px) {
  #raid-form label.half-width {
    max-width: none;
  }
}

/* Sections inside forms: a heading instead of a boxed fieldset. */
#raid-form fieldset.form-section,
#settings-form fieldset.form-section {
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  padding: 18px 0 0;
  margin: 22px 0 0;
  min-width: 0;
}

#raid-form .form-section legend,
#settings-form .form-section legend {
  float: left;
  width: 100%;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
}

#raid-form .form-section legend + *,
#settings-form .form-section legend + * {
  clear: both;
}

#raid-form .form-section .form-note,
#settings-form .form-section .form-note {
  margin-top: 4px !important;
}

/* A tab that opens with a section needs no rule above it. */
#raid-form .editor-panel > fieldset.form-section:first-child {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

#raid-form .form-note a {
  color: var(--accent);
}

/* Checkbox chips: aligned in a grid, the whole chip is the hit area. */
.choice-grid,
.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.option-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

#raid-form label.choice,
#settings-form label.choice,
.attn-actions label.choice,
.sr-team-rules-fields label.choice,
.as-table-form label.choice,
.bank-form label.choice {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin: 0;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}

#raid-form label.choice:hover,
#settings-form label.choice:hover,
.attn-actions label.choice:hover,
.sr-team-rules-fields label.choice:hover,
.as-table-form label.choice:hover,
.bank-form label.choice:hover {
  border-color: var(--border-hover);
}

#raid-form label.choice:has(input:checked),
#settings-form label.choice:has(input:checked),
.attn-actions label.choice:has(input:checked),
.sr-team-rules-fields label.choice:has(input:checked),
.as-table-form label.choice:has(input:checked),
.bank-form label.choice:has(input:checked) {
  border-color: var(--accent-border);
  background: var(--bg-warm);
}

#settings-form fieldset:disabled label.choice {
  cursor: default;
  opacity: 0.65;
}

#raid-form label.choice > span,
#settings-form label.choice > span,
.attn-actions label.choice > span,
.sr-team-rules-fields label.choice > span,
.as-table-form label.choice > span,
.bank-form label.choice > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Checkboxes and radios everywhere: the theme's 18px box (a circle for
   radios) on inset charcoal. A checked box turns copper with a dark tick; a
   chosen radio gets a copper ring and dot. The form rules below repeat it for
   their ids, which win over the forms' own input styles. */
input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  display: inline-grid;
  place-content: center;
  flex: none;
  width: 18px;
  height: 18px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--border-hover);
  border-radius: 5px;
  background: var(--bg-inset);
  vertical-align: -4px;
  cursor: pointer;
  transition:
    background-color 0.12s,
    border-color 0.12s;
}

input[type="checkbox"]::after {
  content: "";
  width: 9px;
  height: 5px;
  margin-top: -2px;
  border-left: 2px solid var(--accent-ink);
  border-bottom: 2px solid var(--accent-ink);
  transform: rotate(-45deg) scale(0);
  transition: transform 0.12s;
}

input[type="checkbox"]:hover:not(:disabled),
input[type="radio"]:hover:not(:disabled) {
  border-color: var(--accent-border);
}

input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent);
}

input[type="checkbox"]:checked::after {
  transform: rotate(-45deg) scale(1);
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input[type="radio"] {
  border-radius: 50%;
}

input[type="radio"]::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform 0.12s;
}

input[type="radio"]:checked {
  border-color: var(--accent);
  background: var(--bg-inset);
}

input[type="radio"]:checked::after {
  transform: scale(1);
}

#raid-form .choice input:is([type="checkbox"], [type="radio"]),
#settings-form .choice input:is([type="checkbox"], [type="radio"]),
.attn-actions .choice input:is([type="checkbox"], [type="radio"]),
.sr-team-rules-fields .choice input:is([type="checkbox"], [type="radio"]) {
  appearance: none;
  display: grid;
  place-content: center;
  flex: none;
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--border-hover);
  border-radius: 5px;
  background: var(--bg-inset);
  cursor: inherit;
}

#raid-form .choice input:is([type="checkbox"], [type="radio"])::after,
#settings-form .choice input:is([type="checkbox"], [type="radio"])::after,
.attn-actions .choice input:is([type="checkbox"], [type="radio"])::after,
.sr-team-rules-fields
  .choice
  input:is([type="checkbox"], [type="radio"])::after {
  content: "";
  width: 9px;
  height: 5px;
  margin-top: -2px;
  border-left: 2px solid var(--accent-ink);
  border-bottom: 2px solid var(--accent-ink);
  transform: rotate(-45deg) scale(0);
  transition: transform 0.12s;
}

#raid-form .choice input:is([type="checkbox"], [type="radio"]):checked,
#settings-form .choice input:is([type="checkbox"], [type="radio"]):checked,
.attn-actions .choice input:is([type="checkbox"], [type="radio"]):checked,
.sr-team-rules-fields
  .choice
  input:is([type="checkbox"], [type="radio"]):checked {
  border-color: var(--accent);
  background: var(--accent);
}

#raid-form .choice input:is([type="checkbox"], [type="radio"]):checked::after,
#settings-form
  .choice
  input:is([type="checkbox"], [type="radio"]):checked::after,
.attn-actions
  .choice
  input:is([type="checkbox"], [type="radio"]):checked::after,
.sr-team-rules-fields
  .choice
  input:is([type="checkbox"], [type="radio"]):checked::after {
  transform: rotate(-45deg) scale(1);
}

#raid-form .choice input:is([type="checkbox"], [type="radio"]):focus-visible,
#settings-form
  .choice
  input:is([type="checkbox"], [type="radio"]):focus-visible,
.attn-actions .choice input:is([type="checkbox"], [type="radio"]):focus-visible,
.sr-team-rules-fields
  .choice
  input:is([type="checkbox"], [type="radio"]):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

#raid-form .choice input[type="radio"],
#settings-form .choice input[type="radio"],
.attn-actions .choice input[type="radio"],
.sr-team-rules-fields .choice input[type="radio"] {
  border-radius: 50%;
}

#raid-form .choice input[type="radio"]::after,
#settings-form .choice input[type="radio"]::after,
.attn-actions .choice input[type="radio"]::after,
.sr-team-rules-fields .choice input[type="radio"]::after {
  width: 8px;
  height: 8px;
  margin: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
}

#raid-form .choice input[type="radio"]:checked,
#settings-form .choice input[type="radio"]:checked,
.attn-actions .choice input[type="radio"]:checked,
.sr-team-rules-fields .choice input[type="radio"]:checked {
  background: var(--bg-inset);
}

#raid-form .choice input[type="radio"]:checked::after,
#settings-form .choice input[type="radio"]:checked::after,
.attn-actions .choice input[type="radio"]:checked::after,
.sr-team-rules-fields .choice input[type="radio"]:checked::after {
  transform: scale(1);
}

#raid-form label.option-card,
.sr-team-rules-fields label.option-card {
  align-items: flex-start;
  padding: 12px 14px;
}

#raid-form .option-card input,
.sr-team-rules-fields .option-card input {
  margin-top: 1px;
}

.option-card strong {
  display: block;
  font-size: 13px;
}

.option-card small {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-muted);
}

/* The editor's Schedule tab: weekday toggles, the lead time, the end and the
   next raids. */
.schedule-fields {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.schedule-fields fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.schedule-fields legend {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.weekday-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#raid-form label.weekday-toggle {
  position: relative;
  display: inline-flex;
  margin: 0;
}

.weekday-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.weekday-toggle span {
  display: inline-block;
  min-width: 52px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.weekday-toggle input:checked + span {
  border-color: var(--accent-border);
  background: var(--bg-warm);
  color: var(--accent);
}

.weekday-toggle input:focus-visible + span {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.schedule-lead {
  display: flex;
  gap: 6px;
}

#raid-form .schedule-lead input {
  flex: 0 0 6em;
  width: 6em;
}

#raid-form .schedule-lead select {
  flex: 1 1 auto;
  min-width: 7.5em;
}

.schedule-lead-note {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.schedule-ends {
  display: grid;
  gap: 8px;
}

#raid-form label.schedule-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
}

#raid-form label.schedule-end input[type="date"],
#raid-form label.schedule-end input[type="number"] {
  width: auto;
  max-width: 11em;
  height: 32px;
  min-height: 0;
  margin: -6px 0;
  padding: 0 10px;
  background: var(--bg-inset);
}

#raid-form label.schedule-end input[type="number"] {
  width: 5em;
  text-align: center;
}

.schedule-preview {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-inset);
}

.schedule-preview h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.schedule-preview ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.schedule-preview li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
}

.schedule-preview li span {
  color: var(--text-muted);
}

.schedule-note {
  display: grid;
  gap: 12px;
  justify-items: start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
}

.schedule-note p {
  margin: 0;
}

/* Selects get one consistent arrow; numbers and dates line up with them. */
#raid-form select,
#settings-form select,
#signup-form select,
.sr-team-rules-fields select {
  appearance: none;
  padding-right: 34px;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

#raid-form input[type="date"],
#raid-form input[type="time"] {
  height: 42px;
}

#raid-form .role-limit-grid label.role-limit {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
}

#raid-form .role-limit input {
  background: var(--bg-inset);
  text-align: center;
}

#raid-form fieldset,
#settings-form fieldset {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px 14px;
  margin-top: 20px;
}

#raid-form legend,
#settings-form legend {
  font-size: 12px;
  font-weight: 600;
  padding: 0 5px;
}

#raid-form fieldset .form-note,
#settings-form fieldset .form-note {
  margin-top: 4px !important;
}

.role-limit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

#raid-form .role-limit-grid label {
  flex-direction: column;
}

.check-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
}

.check-list legend,
.check-list .form-note {
  width: 100%;
}

#raid-form .check-list label,
#settings-form .check-list label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-weight: 400;
}

#raid-form .check-list input,
#settings-form .check-list input {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--accent);
}

#signup-form label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  margin-top: 18px;
}

#signup-form input,
#signup-form select,
#signup-form textarea {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  min-height: 42px;
}

#signup-form textarea {
  resize: vertical;
}

#signup-form input:focus,
#signup-form select:focus,
#signup-form textarea:focus {
  border-color: var(--accent-border);
  outline: 2px solid var(--focus-ring);
  outline-offset: -1px;
}

.dialog-actions-split {
  justify-content: space-between;
  flex-wrap: wrap;
}

#confirm-dialog {
  max-width: 440px;
}

#confirm-dialog h2,
#dates-dialog h2 {
  font-size: 20px;
}

#dates-dialog {
  max-width: 520px;
}

@media (max-width: 1000px) {
  .stat-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .detail-actions {
    width: 100%;
  }
}

@media (max-width: 450px) {
  .role-limit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .class-bars li {
    grid-template-columns: 20px 60px minmax(0, 1fr) 22px;
    gap: 8px;
  }
}
