/* Admin-only refinements extracted from shared/refinements.css and unified admin UX tokens. */
.admin-body {
  --admin-radius-sm: 4px;
  --admin-radius-md: 6px;
  --admin-radius-lg: 8px;
  --admin-danger: #b42318;
  --admin-danger-bg: #fef2f2;
  --admin-success: #166534;
  --admin-success-bg: #ecfdf3;
  --admin-warning: #854d0e;
  --admin-warning-bg: #fef9c3;
  --admin-focus-ring: #0055c5;
}

.admin-body .button:hover,
.admin-body .button:active,
.login-page .button:hover,
.login-page .button:active {
  transform: none;
}

.admin-body .admin-main :is(section, form, details, div)[id] {
  scroll-margin-top: 96px;
}

/* Mobile admin sidebar scrim and scroll lock */
body.admin-menu-open {
  overflow: hidden;
}

.admin-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 34;
  background: rgba(11, 28, 45, 0.45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease-out, visibility 0s 0.2s;
}

.admin-nav-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.22s ease-out, visibility 0s;
}

/* Lightweight non-blocking admin toast for in-place JSON actions */
.admin-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 120;
  max-width: min(400px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: var(--admin-radius-md, 6px);
  border: 1px solid #bde0cc;
  background: #effaf3;
  color: #166534;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  box-shadow: 0 10px 28px rgba(16, 38, 61, 0.16);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease-out, transform 0.18s ease-out;
}

.admin-toast.is-info {
  border-color: #c9ddf4;
  background: #f0f6fd;
  color: #123c6c;
}

.admin-toast.is-danger {
  border-color: #ebcccc;
  background: #fff0f0;
  color: #a32323;
}

.admin-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Dirty save-state badge & content-order dirty indicators */
.admin-main [data-editor-save-state] {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: #52677d;
  background: #f2f5f9;
}

.admin-main [data-editor-save-state][data-dirty="true"] {
  color: var(--admin-warning, #854d0e);
  background: var(--admin-warning-bg, #fef9c3);
  border: 1px solid #f5d66b;
}

.admin-main [data-editor-save-state][data-dirty="true"]::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d97706;
  flex: none;
}

.content-order-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.order-dirty-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--admin-warning-bg, #fef9c3);
  border: 1px solid #f5d66b;
  color: var(--admin-warning, #854d0e);
  font-size: 13px;
  font-weight: 550;
}

.order-dirty-badge[hidden] {
  display: none;
}

.admin-table tr.is-order-dirty {
  background: #f0f6ff;
}

.admin-table tr.is-order-dirty .content-order-input {
  border-color: var(--blue);
  background: #fff;
}

.admin-main [aria-busy="true"].content-order-form .admin-table {
  opacity: 0.6;
  transition: opacity 0.14s ease-out;
}

/* Reserve editor height before lazy Jodit mount to avoid layout shift */
.admin-main textarea[data-rich-editor] {
  min-height: 360px;
}

.admin-main textarea[data-rich-editor][data-editor-height="240"] {
  min-height: 300px;
}

.admin-main textarea[data-rich-editor][data-editor-height="340"] {
  min-height: 400px;
}

.admin-main textarea[data-rich-editor][data-editor-height="380"] {
  min-height: 440px;
}

/* Drag-and-drop highlight on chunk upload */
.admin-body [data-chunk-upload].is-drag-over {
  outline: 2px dashed var(--blue);
  outline-offset: 6px;
  background: #f2f7fe;
  border-radius: var(--admin-radius-md, 6px);
}

/* Restrained entrance motion for admin dialogs */
@keyframes admin-dialog-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.admin-body dialog[open]:is(
  .admin-confirm-dialog,
  .resource-dialog,
  .resource-edit-dialog,
  .content-picker-dialog,
  .document-dialog,
  [data-page-delete-dialog]
) {
  animation: admin-dialog-enter 160ms ease-out;
}

/* Unified horizontal scroll edge shadows for wide admin tables */
.admin-body .table-scroll {
  background:
    linear-gradient(to right, #fff 30%, rgba(255, 255, 255, 0)) left center,
    linear-gradient(to left, #fff 30%, rgba(255, 255, 255, 0)) right center,
    radial-gradient(farthest-side at 0 50%, rgba(16, 38, 61, 0.14), rgba(16, 38, 61, 0)) left center,
    radial-gradient(farthest-side at 100% 50%, rgba(16, 38, 61, 0.14), rgba(16, 38, 61, 0)) right center;
  background-repeat: no-repeat;
  background-color: #fff;
  background-size: 28px 100%, 28px 100%, 12px 100%, 12px 100%;
  background-attachment: local, local, scroll, scroll;
}

/* Unified chevron styling on inquiry follow-up disclosure */
.admin-body .inquiry-followup > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
  cursor: pointer;
}

.admin-body .inquiry-followup > summary::-webkit-details-marker {
  display: none;
}

.admin-body .inquiry-followup > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 160ms ease-out;
  flex: none;
}

.admin-body .inquiry-followup[open] > summary::after {
  transform: rotate(225deg);
}

/* Presentation settings share the same content catalog as the public website. */
.presentation-index {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0;
}

.presentation-index a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid #dce4ed;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

.presentation-index a:hover {
  color: #12609b;
  border-color: #7aa8c9;
}

.presentation-group {
  scroll-margin-top: 100px;
  margin: 16px 0;
}

.presentation-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
}

.presentation-group > summary::-webkit-details-marker {
  display: none;
}

.presentation-group > summary h2 {
  margin: 0;
  font-size: 20px;
}

.presentation-group > summary > span {
  color: #65778c;
  font-size: 12px;
}

.presentation-group > summary::after {
  content: "+";
  font-size: 23px;
  color: #1c6499;
  flex-shrink: 0;
}

.presentation-group[open] > summary::after {
  content: "−";
}

.presentation-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 24px;
  margin-top: 20px;
}

.presentation-field.copy-field {
  grid-column: 1 / -1;
  padding-top: 18px;
  border-top: 1px solid #e6ecf2;
}

.presentation-field h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px;
}

.presentation-field label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

.presentation-field textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.65;
}

.presentation-image {
  width: 100%;
  max-width: 340px;
  height: 160px;
  object-fit: contain;
  background: #edf2f6;
  border-radius: 6px;
}

.presentation-settings .admin-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.presentation-settings .admin-heading h1 {
  margin: 8px 0;
}

.presentation-settings .admin-heading p {
  color: #63758a;
}

.presentation-settings .page-editor-fields {
  padding: 0;
}

.presentation-settings input,
.presentation-settings select,
.presentation-settings textarea {
  width: 100%;
  min-width: 0;
}

.presentation-group:not([open]) {
  padding-top: 20px;
  padding-bottom: 20px;
}

@media (max-width: 760px) {
  .presentation-fields {
    grid-template-columns: 1fr;
  }

  .presentation-settings .admin-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .presentation-group {
    padding: 20px;
  }

  .presentation-index {
    gap: 6px;
  }

  .presentation-index a {
    font-size: 12px;
    padding: 7px 10px;
  }
}

/* Management refinements extracted from shared/refinements.css */
.admin-body .admin-title > .admin-filter {
  align-self: flex-end;
  margin: 0;
}

.admin-body .traffic-details .table-scroll {
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.admin-body .traffic-details .admin-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.admin-body .traffic-details .admin-table td {
  padding-top: 10px;
  padding-bottom: 10px;
}

.admin-body .inquiry-item .inquiry-heading {
  align-items: flex-start;
  gap: 8px 16px;
}

.admin-body .inquiry-item .inquiry-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.admin-body .inquiry-item .inquiry-heading time {
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.admin-body .inquiry-item .inquiry-meta {
  gap: 6px 18px;
  margin: 12px 0 16px;
  overflow-wrap: anywhere;
}

.admin-body .inquiry-item .inline-form {
  flex-wrap: wrap;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 18px;
}

.admin-body [data-chunk-upload] {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 24px;
}

.admin-body [data-chunk-upload] > label,
.admin-body .media-upload [data-banner-upload] > label {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  min-width: 0;
  margin: 0;
}

.admin-body [data-chunk-upload] > label :is(input, select),
.admin-body .media-upload [data-banner-upload] > label :is(input, select) {
  min-width: 0;
  margin: 0;
}

.admin-body [data-chunk-upload] > :is(.admin-actions, progress, output) {
  grid-column: 1 / -1;
  margin: 0;
}

.admin-body .permission-grid .check-label {
  gap: 12px;
  padding: 12px 14px;
  min-height: 56px;
}

.admin-body .account-password-form {
  max-width: 720px;
}

.admin-body .media-upload [data-banner-upload] {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 16px;
}

.admin-body .media-upload [data-banner-upload] > output {
  grid-column: 1 / -1;
  margin: 0;
}

.admin-body .field-hint,
.admin-body .admin-table time {
  color: var(--muted);
}

.login-panel > p {
  margin-bottom: 28px;
}

.login-panel > .text-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 10px;
}

@media (max-width: 1000px) {
  .admin-body .admin-title > .admin-filter {
    align-self: stretch;
  }
}

@media (max-width: 700px) {
  .admin-body .inquiry-item .inquiry-meta a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  .admin-body .inquiry-item .inline-form :is(select, .button) {
    min-height: 44px;
  }

  .admin-body [data-chunk-upload],
  .admin-body .media-upload [data-banner-upload] {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .admin-body .account-password-form .button {
    width: 100%;
  }
}

.role-list .inquiry-heading {
  align-items: flex-start;
  gap: 12px 20px;
}

.role-list .inquiry-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.role-list .inquiry-heading .text-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  flex-shrink: 0;
}

.role-list .admin-panel > p:empty {
  display: none;
}

.role-list .permission-tags {
  gap: 8px;
}

.admin-body .row-actions {
  flex-wrap: wrap;
  gap: 8px 20px;
}

.admin-body .row-actions :is(.plain-button, .text-link) {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.admin-body .roles-cell .status-badge {
  margin: 4px 6px 4px 0;
}

.admin-body .audit-table td:first-child {
  min-width: 150px;
  font-variant-numeric: tabular-nums;
}

.admin-body .audit-table td:nth-child(3) {
  min-width: 130px;
}

.admin-body .audit-table td:is(:nth-child(4), :nth-child(5)) {
  min-width: 150px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  .admin-nav-backdrop,
  .admin-nav-backdrop.is-open,
  .admin-toast,
  .admin-body .inquiry-followup > summary::after,
  .admin-structure-nav summary::after,
  .site-section-children > summary::before,
  .site-content-advanced > summary::before,
  .content-editor .content-seo > summary::after,
  .content-editor .media-upload > summary::after {
    transition: none;
  }

  .admin-body dialog[open]:is(
    .admin-confirm-dialog,
    .resource-dialog,
    .resource-edit-dialog,
    .content-picker-dialog,
    .document-dialog,
    [data-page-delete-dialog]
  ) {
    animation: none;
  }
}
