/* Shared Head Office modal system
   Compact controlled actions may use this component. Complete records use workspaces. */

body.ops-tailwind dialog#modal {
  width: min(880px, calc(100vw - 40px)) !important;
  max-width: 880px !important;
  max-height: calc(100dvh - 40px) !important;
  margin: auto !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  background: transparent !important;
  color: var(--enterprise-ink, var(--ops-text)) !important;
}

body.ops-tailwind dialog#modal::backdrop {
  background: rgba(5, 12, 24, .66);
  backdrop-filter: blur(3px);
}

body.ops-tailwind #modal .modal-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  max-height: calc(100dvh - 40px);
  overflow: hidden !important;
  border: 1px solid var(--enterprise-border, var(--ops-border));
  border-radius: 10px;
  background: var(--enterprise-surface, var(--ops-surface));
  box-shadow: 0 24px 80px rgba(16, 24, 40, .32);
}

body.ops-tailwind #modal .modal-shell > header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 20px 22px;
  overflow: hidden;
  border-bottom: 1px solid #2c3b51;
  background: var(--enterprise-navy, #101c2f);
  color: #fff;
}

body.ops-tailwind #modal .modal-shell > header > div {
  flex: 1 1 auto;
  min-width: 0;
  max-width: calc(100% - 58px);
  overflow: hidden;
}

body.ops-tailwind #modal .modal-shell > header .eyebrow,
body.ops-tailwind #modal .modal-shell > header h2,
body.ops-tailwind #modal .modal-shell > header p {
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

body.ops-tailwind #modal .modal-shell > header .eyebrow {
  margin: 0 0 6px;
  color: #9fb7dc;
}

body.ops-tailwind #modal .modal-shell > header h2 {
  margin: 0;
  color: #fff;
  font-size: 21px;
  font-weight: 680;
  line-height: 1.2;
}

body.ops-tailwind #modal .modal-shell > header p:not(.eyebrow) {
  margin: 7px 0 0;
  color: #c1cce0;
  font-size: 12px;
  line-height: 1.5;
}

body.ops-tailwind #modal .modal-shell > header .icon-button {
  flex: 0 0 38px;
  width: 38px;
  min-width: 38px;
  height: 38px;
  border-color: rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color: #fff;
}

body.ops-tailwind #modal .modal-shell > header .icon-button:hover {
  background: rgba(255,255,255,.16);
}

body.ops-tailwind #modal .modal-content {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  max-height: none;
  padding: 22px;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: var(--enterprise-surface, var(--ops-surface));
}

body.ops-tailwind #modal .modal-content > *,
body.ops-tailwind #modal form,
body.ops-tailwind #modal fieldset,
body.ops-tailwind #modal label,
body.ops-tailwind #modal .field,
body.ops-tailwind #modal .form-grid,
body.ops-tailwind #modal .customer-lookup,
body.ops-tailwind #modal .customer-lookup-control,
body.ops-tailwind #modal .summary-list,
body.ops-tailwind #modal .notice {
  min-width: 0;
  max-width: 100%;
}

body.ops-tailwind #modal form {
  width: 100%;
  margin: 0;
}

body.ops-tailwind #modal .form-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

body.ops-tailwind #modal .form-grid .full {
  grid-column: 1 / -1;
}

body.ops-tailwind #modal input,
body.ops-tailwind #modal select,
body.ops-tailwind #modal textarea,
body.ops-tailwind #modal button,
body.ops-tailwind #modal pre {
  min-width: 0;
  max-width: 100%;
}

body.ops-tailwind #modal input,
body.ops-tailwind #modal select,
body.ops-tailwind #modal textarea {
  width: 100%;
}

body.ops-tailwind #modal fieldset {
  width: 100%;
  min-inline-size: 0;
  margin: 16px 0 0;
  padding: 16px;
  border: 1px solid var(--enterprise-border, var(--ops-border));
}

body.ops-tailwind #modal fieldset legend {
  max-width: 100%;
  padding: 0 6px;
  overflow-wrap: anywhere;
  font-weight: 700;
}

body.ops-tailwind #modal .customer-lookup-results {
  left: 0;
  right: 0;
  width: auto;
  max-width: 100%;
}

body.ops-tailwind #modal .form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
  width: 100%;
}

body.ops-tailwind #modal .table-wrap {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}

body.ops-tailwind #modal .key-output {
  width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 820px) {
  body.ops-tailwind dialog#modal {
    width: min(100% - 20px, 680px) !important;
    max-height: calc(100dvh - 20px) !important;
  }
  body.ops-tailwind #modal .modal-shell { max-height: calc(100dvh - 20px); }
  body.ops-tailwind #modal .form-grid { grid-template-columns: 1fr; }
  body.ops-tailwind #modal .form-grid .full { grid-column: auto; }
}

@media (max-width: 560px) {
  body.ops-tailwind dialog#modal { width: calc(100% - 12px) !important; }
  body.ops-tailwind #modal .modal-shell > header { padding: 16px; }
  body.ops-tailwind #modal .modal-content { padding: 16px; }
  body.ops-tailwind #modal .form-actions > .button { flex: 1 1 130px; }
}
