/* Shared dialog heading and navigation. Dialogs own their width and body layout. */
:root {
  --boltex-dialog-surface: #fff;
  --boltex-dialog-text: #241f1b;
  --boltex-dialog-border: #d4d6ce;
  --boltex-dialog-title-size: 17px;
  --boltex-dialog-title-weight: 500;
  --boltex-dialog-header-line: #e4e5df;
  --boltex-dialog-icon-size: 20px;
  --boltex-dialog-icon-ink: #6e675f;
  --boltex-dialog-icon-hover: #edf0ec;
}
html[data-theme="dark"] {
  --boltex-dialog-surface: #222;
  --boltex-dialog-text: #eee;
  --boltex-dialog-border: #333;
  --boltex-dialog-header-line: #383838;
  --boltex-dialog-icon-ink: #aaa;
  --boltex-dialog-icon-hover: #333;
}
.boltex-dialog-surface {
  box-sizing: border-box;
  width: min(var(--boltex-dialog-width, 620px), calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--boltex-dialog-border);
  border-radius: 12px;
  background: var(--boltex-dialog-surface);
  color: var(--boltex-dialog-text);
}
.boltex-dialog-header {
  display: flex;
  margin: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 22px;
  min-height: 61px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--boltex-dialog-header-line);
}
.boltex-dialog-heading,
.boltex-dialog-header .boltex-dialog-heading {
  margin: 0;
  min-width: 0;
  font: var(--boltex-dialog-title-weight) var(--boltex-dialog-title-size)/1.25 Inter, system-ui, sans-serif;
  overflow-wrap: anywhere;
}
.boltex-dialog-heading-note {
  color: var(--boltex-dialog-icon-ink);
  font-size: 14px;
  font-weight: 400;
}
.boltex-dialog-body {
  padding: 16px 22px 18px;
}
.boltex-dialog-layout {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 26px);
}
.boltex-dialog-layout > .boltex-dialog-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.boltex-dialog-layout > :is(.boltex-dialog-header,.boltex-dialog-actions) {
  flex: none;
}
.boltex-dialog-navigation {
  display: flex;
  flex: none;
  align-items: center;
  gap: 2px;
  margin-inline-start: auto;
}
.boltex-dialog-body > .boltex-field-error:not(:empty) {
  margin-top: 8px;
}
.boltex-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-top: 1px solid var(--boltex-dialog-header-line);
}
@media (max-width: 620px) {
  .boltex-dialog-body,
  .boltex-dialog-actions { padding-inline: 16px; }
}
.boltex-dialog-title {
  display: flex;
  align-items: center;
  min-height: 61px;
  box-sizing: border-box;
  margin: 0;
  padding: 10px 96px 10px 22px;
  border-bottom: 1px solid var(--boltex-dialog-header-line);
  font: var(--boltex-dialog-title-weight) var(--boltex-dialog-title-size)/1.25 Inter, system-ui, sans-serif;
  overflow-wrap: anywhere;
}
/* Every icon control gets its shape from here. The layer also takes
   precedence over older unlayered theme rules that use !important. */
@layer boltex-dialog-controls {
  button[data-boltex-dialog-icon] {
    display: grid;
    place-items: center !important;
    box-sizing: border-box !important;
    flex: 0 0 40px !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--boltex-dialog-icon-ink) !important;
    font-size: 0 !important;
    cursor: pointer;
  }
  button[data-boltex-dialog-icon][hidden] { display: none !important; }
  button[data-boltex-dialog-icon] > svg,
  button[data-boltex-dialog-icon]::after { display: none !important; }
  button[data-boltex-dialog-icon]::before {
    content: "";
    display: block;
    width: var(--boltex-dialog-icon-size);
    height: var(--boltex-dialog-icon-size);
    background: currentColor;
    mask: var(--boltex-dialog-icon-mask) center / contain no-repeat;
  }
  button[data-boltex-dialog-icon]:hover { background: var(--boltex-dialog-icon-hover) !important; }
  button[data-boltex-dialog-icon]:focus-visible { outline: 2px solid currentColor !important; outline-offset: -2px !important; }

  /* A flat dialog shell places navigation in the top-right slots.
     A header with its own navigation uses the shared flex row instead. */
  :is(dialog > #modal-form, dialog#modal, dialog#sheet) > button[data-boltex-dialog-icon] {
    position: absolute !important;
    z-index: 20;
    top: 10px !important;
    left: auto !important;
    right: var(--boltex-dialog-icon-right, 12px) !important;
    transform: none !important;
  }
  #modal-form:has(> [data-boltex-dialog-icon="back"]:not([hidden])) > #modal-title {
    padding-inline-end: 96px !important;
  }
  header:has(> .boltex-dialog-navigation) { padding-inline-end: 12px !important; }
  .boltex-dialog-navigation > button[data-boltex-dialog-icon],
  .boltex-dialog-header > button[data-boltex-dialog-icon] {
    position: static !important;
    transform: none !important;
  }
}
button[data-boltex-dialog-icon="close"] {
  --boltex-dialog-icon-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6l12 12M18 6 6 18' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
}
button[data-boltex-dialog-icon="edit"] {
  --boltex-dialog-icon-right: 54px;
  --boltex-dialog-icon-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6.62 14.69-.62 3.31 3.31-.62L18 8.69 15.31 6l-8.69 8.69Zm7.54-7.54 2.69 2.69' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
button[data-boltex-dialog-icon="back"] {
  --boltex-dialog-icon-right: 54px;
  --boltex-dialog-icon-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M18 12H6m6-6-6 6 6 6' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* Existing workspace and field dialogs keep their own shell geometry. */
#modal:is(.team-invite-dialog,.task-create-modal:where(:not(.manager-modern-modal))) #modal-title {
  display: flex;
  align-items: center;
  min-height: 61px;
  margin: 0;
  padding: 10px 96px 10px 22px;
  border-bottom: 1px solid var(--boltex-dialog-header-line);
  font: var(--boltex-dialog-title-weight) var(--boltex-dialog-title-size)/1.25 Inter, system-ui, sans-serif;
}

#sheet .boltex-dialog-header:has(.boltex-dialog-heading) { padding-right: 96px; }

.problem-return-form > .boltex-dialog-header { margin:-16px -16px 0; }
/* The image viewer has a dark canvas in either application theme. */
#photo-viewer { --boltex-dialog-icon-ink: #eee; --boltex-dialog-icon-hover: #333; }
