/* ICAM Abacus — global colourful informative admin change forms */

body.change-form.icam-change-form #content-main form > .flex.flex-col {
  gap: 1.25rem;
}

/* ── Overview hero (centre, meet, etc.) ─────────────────────────────────── */
.icam-change-form .icam-overview-shell,
.icam-change-form .mps-overview-shell {
  width: 100%;
  margin: 0 0 0.25rem;
}

.icam-change-form .icam-overview,
.icam-change-form .mps-overview {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.icam-change-form .icam-hero,
.icam-change-form .mps-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(15rem, 0.9fr);
  gap: 1rem;
  padding: 1.15rem 1.2rem;
  border-radius: calc(var(--admin-radius) * 1.15);
  border: 1px solid color-mix(in oklch, var(--admin-primary), white 72%);
  background:
    radial-gradient(
      ellipse 80% 120% at 100% 0%,
      color-mix(in oklch, var(--admin-primary), white 78%) 0%,
      transparent 55%
    ),
    linear-gradient(
      135deg,
      color-mix(in oklch, var(--admin-primary), white 88%) 0%,
      #ffffff 42%,
      color-mix(in oklch, var(--admin-accent-soft), white 35%) 100%
    );
  box-shadow:
    0 1px 0 color-mix(in oklch, white, transparent 25%) inset,
    0 12px 32px -18px color-mix(in oklch, var(--admin-primary), transparent 55%);
  overflow: hidden;
  position: relative;
}

@media (max-width: 900px) {
  .icam-change-form .icam-hero,
  .icam-change-form .mps-hero {
    grid-template-columns: 1fr;
  }
}

.icam-change-form .icam-hero__eyebrow,
.icam-change-form .mps-hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.45rem;
  padding: 0.28rem 0.62rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: color-mix(in oklch, var(--admin-primary), white 82%);
  color: var(--admin-primary);
}

.icam-change-form .icam-hero__title,
.icam-change-form .mps-hero__title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--admin-foreground);
  line-height: 1.2;
}

.icam-change-form .icam-hero__lead,
.icam-change-form .mps-hero__lead {
  margin: 0;
  color: var(--admin-muted-fg);
  font-size: 0.92rem;
  line-height: 1.55;
  max-width: 42rem;
}

.icam-change-form .icam-hero__card,
.icam-change-form .mps-hero__card {
  position: relative;
  z-index: 1;
  padding: 0.95rem 1rem;
  border-radius: calc(var(--admin-radius) * 0.95);
  border: 1px solid color-mix(in oklch, var(--admin-border), white 25%);
  background: color-mix(in oklch, white, transparent 8%);
  backdrop-filter: blur(6px);
}

.icam-change-form .icam-hero__card-title,
.icam-change-form .mps-hero__card-title {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--admin-muted-fg);
}

.icam-change-form .icam-stat-grid,
.icam-change-form .mps-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.65rem;
}

.icam-change-form .icam-stat,
.icam-change-form .mps-stat {
  padding: 0.75rem 0.85rem;
  border-radius: calc(var(--admin-radius) * 0.85);
  border: 1px solid var(--admin-border);
  background: white;
  box-shadow: var(--admin-card-shadow);
}

.icam-change-form .icam-stat__value,
.icam-change-form .mps-stat__value {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--admin-primary);
  line-height: 1.1;
}

.icam-change-form .icam-stat__label,
.icam-change-form .mps-stat__label {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--admin-muted-fg);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.icam-change-form .icam-kv,
.icam-change-form .mps-kv {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}

.icam-change-form .icam-kv dt,
.icam-change-form .mps-kv dt {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--admin-muted-fg);
}

.icam-change-form .icam-kv dd,
.icam-change-form .mps-kv dd {
  margin: 0.1rem 0 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--admin-foreground);
}

.icam-change-form .icam-status,
.icam-change-form .mps-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.icam-change-form .icam-status--ok,
.icam-change-form .mps-status-chip--ok {
  background: color-mix(in oklch, #16a34a, white 82%);
  color: #166534;
}

.icam-change-form .icam-status--warn,
.icam-change-form .mps-status-chip--warn {
  background: color-mix(in oklch, #d97706, white 82%);
  color: #92400e;
}

.icam-change-form .icam-status--muted,
.icam-change-form .mps-status-chip--muted {
  background: color-mix(in oklch, var(--admin-muted-fg), white 82%);
  color: var(--admin-muted-fg);
}

.icam-change-form .icam-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.icam-change-form .icam-hero__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid color-mix(in oklch, var(--admin-primary), white 65%);
  background: var(--admin-primary);
  color: #fff !important;
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none !important;
  cursor: pointer;
}

.icam-change-form .icam-hero__btn--ghost {
  background: white;
  color: var(--admin-primary) !important;
}

/* ── Section cards: title + description header, fields on a clean surface ──
 * Scoped to top-level form sections so inline and tabbed fieldsets keep Unfold's layout. */
.icam-change-form #content-main form > .flex-col > fieldset.module {
  overflow: hidden;
  padding: 1.35rem 1.5rem 1.5rem;
  border: 1px solid var(--admin-border) !important;
  border-radius: 1rem !important;
  background: var(--admin-surface-raised, #ffffff) !important;
  box-shadow: var(--admin-card-shadow) !important;
}

.icam-change-form #content-main form > .flex-col > fieldset.module h2 {
  height: auto !important;
  margin: 0 0 0.25rem !important;
  padding: 0 !important;
  border: 0 !important;
  background: none !important;
  color: var(--admin-foreground) !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em;
}

.icam-change-form #content-main form > .flex-col > fieldset.module > .leading-relaxed.text-subtle {
  position: relative;
  margin: 0 0 1.15rem !important;
  padding: 0.9rem 1rem 0.9rem 2.6rem;
  border-radius: 0.75rem;
  border: 1px solid color-mix(in oklch, var(--admin-primary), white 75%);
  border-left: 4px solid var(--admin-primary);
  background: linear-gradient(
    90deg,
    color-mix(in oklch, var(--admin-accent-soft), white 50%) 0%,
    color-mix(in oklch, var(--admin-accent-soft), white 72%) 100%
  );
  color: var(--admin-foreground) !important;
  font-size: 0.8125rem !important;
  line-height: 1.5 !important;
}

.icam-change-form #content-main form > .flex-col > fieldset.module > .leading-relaxed.text-subtle::before {
  content: "info";
  font-family: "Material Symbols Outlined";
  position: absolute;
  left: 0.75rem;
  top: 0.85rem;
  font-size: 1.1rem;
  color: var(--admin-primary);
}

.icam-change-form #content-main form > .flex-col > fieldset.module > h2 + .form-rows {
  margin-top: 1rem;
}

.icam-change-form #content-main form > .flex-col > fieldset.module details > summary {
  margin-bottom: 0.75rem;
  cursor: pointer;
}

html.dark .icam-change-form .form-rows,
html.dark .icam-change-form .form-rows .field-line {
  border-color: var(--admin-border) !important;
}

.icam-change-form #content-main form > .flex-col > fieldset.module .form-rows {
  border-color: var(--list-divider) !important;
  border-radius: 0.75rem !important;
  box-shadow: none !important;
}

.icam-change-form .field-line {
  min-height: 4.25rem;
  padding-top: 0.95rem !important;
  padding-bottom: 0.95rem !important;
}

.icam-change-form .field-line label {
  letter-spacing: -0.01em;
}

.icam-change-form .field-line .grow p,
.icam-change-form .field-line .help,
.icam-change-form .field-line .leading-relaxed {
  max-width: 42rem;
  margin-top: 0.4rem;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.icam-change-form #submit-row {
  position: sticky;
  bottom: 0;
  z-index: 30;
}

.icam-change-form #submit-row > div {
  border: 1px solid var(--admin-border);
  border-radius: 1rem;
  box-shadow: 0 10px 28px -18px rgba(10, 32, 54, 0.45);
}

@media (max-width: 1023px) {
  #submit-row > div {
    padding: 0.7rem !important;
  }

  #submit-row .flex.flex-col-reverse {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem !important;
    height: auto !important;
    align-items: stretch;
  }

  #submit-row .flex.flex-col-reverse > .flex.flex-col {
    display: contents;
  }

  #submit-row button,
  #submit-row a,
  #submit-row input[type="submit"] {
    width: 100% !important;
    min-height: 2.5rem;
    padding: 0.45rem 0.7rem !important;
    font-size: 0.8125rem !important;
    line-height: 1.25;
    white-space: normal;
  }
}

@media (max-width: 639px) {
  #submit-row > div {
    padding: 0.4rem !important;
  }

  #submit-row .flex.flex-col-reverse {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 0.35rem !important;
    height: auto !important;
  }

  #submit-row button,
  #submit-row a,
  #submit-row input[type="submit"] {
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 0 !important;
    min-height: 3.2rem;
    margin: 0 !important;
    padding: 0.35rem 0.1rem !important;
    font-size: 0 !important;
    line-height: 1;
    flex-direction: column;
    gap: 0.15rem;
  }

  #submit-row button::before,
  #submit-row a::before,
  #submit-row input[type="submit"]::before {
    font-family: "Material Symbols Outlined";
    font-size: 1.15rem;
    font-weight: 400;
    line-height: 1;
    font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 24;
  }

  #submit-row button::after,
  #submit-row a::after,
  #submit-row input[type="submit"]::after {
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: 0;
    text-align: center;
    white-space: normal;
  }

  #submit-row button[name="_save"]::before,
  #submit-row input[type="submit"].default::before {
    content: "save";
  }

  #submit-row button[name="_save"]::after,
  #submit-row input[type="submit"].default::after {
    content: "Save";
  }

  #submit-row button[name="_continue"]::before {
    content: "edit_note";
  }

  #submit-row button[name="_continue"]::after {
    content: "Continue";
  }

  #submit-row button[name="_addanother"]::before {
    content: "add";
  }

  #submit-row button[name="_addanother"]::after {
    content: "Add";
  }

  #submit-row button[name="_saveasnew"]::before {
    content: "file_copy";
  }

  #submit-row button[name="_saveasnew"]::after {
    content: "Copy";
  }

  #submit-row a:not([href*="/delete/"])::before {
    content: "close";
  }

  #submit-row a:not([href*="/delete/"])::after {
    content: "Close";
  }

  #submit-row a[href*="/delete/"]::before {
    content: "delete";
  }

  #submit-row a[href*="/delete/"]::after {
    content: "Delete";
  }
}

.icam-change-form [x-data*="activeFieldsetTab"] {
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  overflow: hidden;
  background: white;
  box-shadow: var(--admin-card-shadow);
}

.icam-change-form [x-data*="activeFieldsetTab"] nav {
  background: linear-gradient(
    180deg,
    color-mix(in oklch, var(--admin-accent-soft), white 40%) 0%,
    white 100%
  ) !important;
}

.icam-change-form [x-data*="activeFieldsetTab"] nav a.active {
  background: white !important;
  font-weight: 800 !important;
}

.icam-change-form .inline-group {
  border-radius: var(--admin-radius) !important;
  border: 1px solid var(--admin-border) !important;
  overflow: hidden;
  box-shadow: var(--admin-card-shadow) !important;
}

.icam-change-form .inline-group h2,
.icam-change-form .inline-group .inline-heading {
  background: color-mix(in oklch, var(--admin-accent-soft), white 35%) !important;
  font-weight: 800 !important;
}

.icam-change-form .submit-row,
.icam-change-form footer .submit-row {
  border-radius: var(--admin-radius) !important;
  border: 1px solid var(--admin-border) !important;
  box-shadow: var(--admin-card-shadow) !important;
  background: linear-gradient(
    180deg,
    white 0%,
    color-mix(in oklch, var(--admin-accent-soft), white 55%) 100%
  ) !important;
}

/* Delete / danger actions — soft red fill, white label */
#submit-row a.bg-red-500,
#submit-row a.bg-red-600,
#submit-row a.bg-red-700,
#submit-row a[class*="bg-red-"],
a.bg-red-500,
a.bg-red-600,
a.bg-red-700,
button.bg-red-500,
button.bg-red-600,
button.bg-red-700,
a[href*="/delete/"].bg-red-600,
a[href*="/delete/"][class*="bg-red-"] {
  background: var(--admin-danger, oklch(0.64 0.12 22)) !important;
  background-image: none !important;
  border-color: var(--admin-danger-border, oklch(0.58 0.11 22)) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px -6px color-mix(in oklch, var(--admin-danger, oklch(0.64 0.12 22)), transparent 45%) !important;
}

#submit-row a.bg-red-500:link,
#submit-row a.bg-red-500:visited,
#submit-row a.bg-red-500:hover,
#submit-row a.bg-red-500:focus,
#submit-row a.bg-red-600:link,
#submit-row a.bg-red-600:visited,
#submit-row a.bg-red-600:hover,
#submit-row a.bg-red-600:focus,
#submit-row a.bg-red-700:link,
#submit-row a.bg-red-700:visited,
#submit-row a.bg-red-700:hover,
#submit-row a.bg-red-700:focus,
a[href*="/delete/"][class*="bg-red-"]:link,
a[href*="/delete/"][class*="bg-red-"]:visited,
a[href*="/delete/"][class*="bg-red-"]:hover,
a[href*="/delete/"][class*="bg-red-"]:focus {
  color: #ffffff !important;
}

#submit-row a[class*="bg-red-"]:hover,
a.bg-red-500:hover,
a.bg-red-600:hover,
a.bg-red-700:hover,
button.bg-red-500:hover,
button.bg-red-600:hover,
button.bg-red-700:hover,
a[href*="/delete/"][class*="bg-red-"]:hover {
  background: var(--admin-danger-hover, oklch(0.58 0.12 22)) !important;
  color: #ffffff !important;
}

/* Force white on icons/labels nested inside danger / primary submit controls */
#submit-row a[class*="bg-red-"] :is(span, i, svg, .material-symbols-outlined),
#submit-row a.bg-primary-600 :is(span, i, svg, .material-symbols-outlined),
#submit-row button.bg-primary-600 :is(span, i, svg, .material-symbols-outlined),
#submit-row input[type="submit"].default,
#submit-row input[type="submit"].bg-primary-600,
.icam-change-form .submit-row input[type="submit"],
.icam-change-form .submit-row a[class*="bg-red-"],
.icam-change-form .submit-row a.bg-primary-600 {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

/* ── Edit-page header (reuses .icam-list-header title styles) ──────────── */
.icam-form-header__main {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  min-width: 0;
}

#main .icam-form-header__back {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--admin-border);
  border-radius: 0.625rem;
  background: var(--admin-surface-raised, #ffffff);
  color: var(--admin-foreground) !important;
  text-decoration: none !important;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#main .icam-form-header__back:hover {
  border-color: color-mix(in srgb, var(--admin-primary) 30%, transparent);
  background: color-mix(in srgb, var(--admin-primary) 9%, transparent);
  color: var(--admin-primary) !important;
}

#main .icam-form-header__back:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--admin-primary) 22%, transparent);
}

#main .icam-form-header__title {
  overflow-wrap: anywhere;
}

.icam-form-header__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0;
}

.icam-form-header__meta > span + span::before {
  content: "·";
  margin: 0 0.5rem;
  opacity: 0.6;
}

/* ── Save bar: unsaved-changes indicator (set by admin-change-form.js) ─── */
.icam-unsaved {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--admin-foreground);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

.icam-unsaved[hidden] {
  display: none;
}

.icam-unsaved::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: #d97706;
  box-shadow: 0 0 0 3px color-mix(in srgb, #d97706 22%, transparent);
}
