/* Bookings uses the shared CRM palette in both themes. */
body.bookings-page {
  --booking-panel: var(--ui-panel, #242629);
  --booking-soft: var(--ui-soft, #2d3134);
  --booking-text: var(--ui-text, #f7f5f0);
  --booking-muted: var(--ui-muted, #b7bab9);
  --booking-line: var(--ui-line, #41474a);
  --booking-input-line: var(--ui-input-line, #849096);
  --booking-petrol: var(--ui-petrol, #176c70);
  --booking-gold: var(--ui-gold, #c9a44c);
  --booking-anthracite: var(--ui-anthracite, #242629);
  --booking-focus: var(--ui-focus, #e3c876);
  --booking-review-text: #f5d68f;
  --booking-review-bg: #59411f;
  --booking-unmatched-text: #ffded7;
  --booking-unmatched-bg: #61372e;
  --booking-matched-text: #c9ece4;
  --booking-matched-bg: #254947;
}

html.theme-light body.bookings-page {
  --booking-panel: var(--ui-panel, #fff);
  --booking-soft: var(--ui-soft, #f8f6f1);
  --booking-text: var(--ui-text, #242629);
  --booking-muted: var(--ui-muted, #657076);
  --booking-line: var(--ui-line, #e4e3df);
  --booking-input-line: var(--ui-input-line, #829096);
  --booking-focus: var(--ui-focus, #176c70);
  --booking-review-text: #684712;
  --booking-review-bg: #f8ebce;
  --booking-unmatched-text: #802f26;
  --booking-unmatched-bg: #fce6df;
  --booking-matched-text: #164f49;
  --booking-matched-bg: #dceeea;
}

.bookings-page .bookings-workspace,
.bookings-page .booking-drawer {
  box-sizing: border-box;
  color: var(--booking-text);
}

.bookings-page .bookings-workspace *,
.bookings-page .booking-drawer * {
  box-sizing: border-box;
}

.bookings-page .bookings-workspace [hidden] { display: none !important; }

.bookings-page .bookings-workspace {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 12px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.bookings-page .bookings-heading,
.bookings-page .bookings-heading-actions,
.bookings-page .bookings-results-heading,
.bookings-page .bookings-views,
.bookings-page .bookings-status-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.bookings-page .bookings-heading,
.bookings-page .bookings-results-heading {
  justify-content: space-between;
}

body.bookings-page .bookings-workspace > .bookings-heading {
  margin: 0;
  padding: 0;
  border: 0;
}

body.bookings-page .bookings-heading > .bookings-heading-actions {
  width: auto;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.bookings-page .bookings-heading h1 {
  margin: 0;
  font-size: clamp(1.3rem, 2.5vw, 1.85rem);
  line-height: 1.15;
}

.bookings-page .bookings-panel {
  min-width: 0;
  border: 1px solid var(--booking-line);
  border-radius: 12px;
  background: var(--booking-panel);
}

.bookings-page .bookings-panel[aria-label="Boekingen filteren"] { padding: 12px; }
.bookings-page .bookings-status-filters { margin-top: 8px; }

.bookings-page :is(.bookings-workspace, .booking-drawer) :is(button, .bookings-button, summary, select, input) {
  min-height: 38px;
  min-width: 0;
  font: inherit;
}

.bookings-page :is(.bookings-workspace, .booking-drawer) :is(button, .bookings-button, summary) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 11px;
  border: 1px solid var(--booking-input-line);
  border-radius: 6px;
  background: var(--booking-panel);
  color: var(--booking-text);
  text-decoration: none;
  white-space: normal;
  cursor: pointer;
}

.bookings-page :is(.bookings-workspace, .booking-drawer) :is(button, .bookings-button, summary):hover:not(:disabled) {
  background: var(--booking-soft);
}

.bookings-page :is(.bookings-workspace, .booking-drawer) button:disabled { opacity: .55; cursor: default; }
.bookings-page :is(.bookings-workspace, .booking-drawer) :focus-visible { outline: 3px solid var(--booking-focus); outline-offset: 2px; }

.bookings-page :is(.bookings-view-button, .bookings-status-button) span {
  font-variant-numeric: tabular-nums;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--booking-soft);
}

.bookings-page .bookings-view-button { font-weight: 650; }

.bookings-page .bookings-view-button[aria-pressed="true"] {
  border-color: var(--booking-petrol);
  background: var(--booking-petrol);
  color: #fff;
}

.bookings-page .bookings-view-button[aria-pressed="true"] span { background: #102e30; }
.bookings-page .bookings-status-button[aria-pressed="true"] { box-shadow: inset 0 -3px var(--booking-gold); }

.bookings-page .bookings-controls {
  display: grid;
  grid-template-columns: minmax(130px, .5fr) minmax(0, 1.5fr) auto;
  gap: 8px 12px;
  align-items: end;
  margin-top: 14px;
}

.bookings-page :is(.bookings-controls label, .bookings-search, .bookings-extra-fields label) {
  min-width: 0;
}

.bookings-page :is(.bookings-period, .bookings-extra-fields label, .bookings-search) {
  display: grid;
  gap: 4px;
}

.bookings-page .bookings-controls label {
  font-size: .875rem;
  font-weight: 600;
}

.bookings-page .bookings-controls :is(input, select) {
  width: 100%;
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--booking-input-line);
  border-radius: 6px;
  background: var(--booking-panel);
  color: var(--booking-text);
  color-scheme: inherit;
}

.bookings-page .bookings-search-input { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.bookings-page .bookings-extra { grid-column: 1 / -1; min-width: 0; }
.bookings-page :is(.bookings-extra, .bookings-summary) > summary::before { content: "▸"; color: var(--booking-muted); }
.bookings-page :is(.bookings-extra, .bookings-summary)[open] > summary::before { content: "▾"; }
.bookings-page :is(.bookings-extra, .bookings-summary) > summary::-webkit-details-marker { display: none; }

.bookings-page .bookings-extra-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 142px), 1fr));
  padding-top: 9px;
  gap: 9px;
}

.bookings-page .bookings-results-heading { padding: 12px; }
.bookings-page .bookings-results-heading h2 { margin: 0; font-size: 1.12rem; }
.bookings-page .bookings-results-meta { color: var(--booking-muted); margin: 0; font-size: .875rem; }
.bookings-page .bookings-notice { margin: 0 12px 12px; padding: 9px; border-left: 3px solid var(--booking-gold); background: var(--booking-soft); }

.bookings-page .bookings-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: .925rem;
}

.bookings-page .bookings-table :is(th, td) {
  min-width: 0;
  border-top: 1px solid var(--booking-line);
  padding: 8px 12px;
  text-align: start;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.bookings-page .bookings-table th {
  background: var(--booking-soft);
  color: var(--booking-muted);
  font-size: .8rem;
}

.bookings-page .bookings-table th:nth-child(2) { width: 24%; }
.bookings-page .bookings-table th:nth-child(3) { width: 16%; }
.bookings-page .bookings-table th:nth-child(4) { width: 100px; }
.bookings-page .bookings-table .bookings-amount { text-align: end; font-variant-numeric: tabular-nums; font-weight: 650; }
.bookings-page .bookings-table .bookings-row-action { text-align: end; }
.bookings-page .bookings-table tr[data-booking-id] { cursor: pointer; }
.bookings-page .bookings-table tr[data-booking-id]:hover { background: var(--booking-soft); }
.bookings-page .bookings-table tr.flash-focus { background: var(--booking-soft); box-shadow: inset 3px 0 var(--booking-gold); }
.bookings-page .bookings-table .bookings-empty { padding: 22px 12px; color: var(--booking-muted); text-align: center; }
.bookings-page .bookings-row-title { display: block; font-weight: 650; line-height: 1.35; }
.bookings-page .bookings-row-meta { display: block; margin-top: 3px; color: var(--booking-muted); font-size: .82rem; }
.bookings-page .bookings-row-status, .bookings-page .booking-detail-flags { display: flex; flex-wrap: wrap; gap: 5px; }

.bookings-page :is(.status-pill, .vat-rate-pill) {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--booking-soft);
  color: var(--booking-text);
  overflow-wrap: anywhere;
  font-size: .8rem;
  line-height: 1.25;
}

.bookings-page :is(.status-pill.matched, .status-pill.checked) { background: var(--booking-matched-bg); color: var(--booking-matched-text); }
.bookings-page .status-pill.review { background: var(--booking-review-bg); color: var(--booking-review-text); }
.bookings-page .status-pill.unmatched { background: var(--booking-unmatched-bg); color: var(--booking-unmatched-text); }

.bookings-page .bookings-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-top: 1px solid var(--booking-line);
  color: var(--booking-muted);
  font-size: .875rem;
}
.bookings-page .bookings-summary { padding: 8px 12px; }
.bookings-page .bookings-summary dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 146px), 1fr));
  gap: 10px;
  margin: 12px 0 4px;
}
.bookings-page .bookings-summary dt { color: var(--booking-muted); font-size: .875rem; }
.bookings-page .bookings-summary dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; }

body.bookings-page > #bookingDrawer {
  position: fixed;
  inset: 16px 16px 16px auto;
  width: min(560px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--booking-gold);
  border-radius: 12px;
  background: var(--booking-panel);
}

.bookings-page .booking-drawer[open] { display: flex; flex-direction: column; }
.bookings-page .booking-drawer::backdrop { background: #101315a3; }
html:has(body.bookings-page #bookingDrawer[open]) { overflow: hidden; }

body.bookings-page .booking-drawer > .booking-drawer-header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--booking-petrol);
  color: #fff;
}

.bookings-page .booking-drawer-header h2 { color: inherit; margin: 0; font-size: 1.05rem; }
.bookings-page #bookingDrawerContent { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 14px; }
.bookings-page .booking-detail-title { margin: 0 0 4px; overflow-wrap: anywhere; font-size: 1.2rem; }
.bookings-page .booking-detail-sub { margin: 0 0 8px; color: var(--booking-muted); overflow-wrap: anywhere; }
.bookings-page .booking-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 14px; }
.bookings-page .booking-detail-actions .bookings-danger { color: var(--booking-unmatched-text); background: var(--booking-unmatched-bg); }

.bookings-page .booking-detail-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 146px), 1fr));
  gap: 8px;
  margin: 0;
}

.bookings-page .booking-detail-summary > div { padding: 8px; background: var(--booking-soft); border: 1px solid var(--booking-line); border-radius: 6px; }
.bookings-page .booking-detail-summary dt { color: var(--booking-muted); font-size: .825rem; }
.bookings-page .booking-detail-summary dd { margin: 2px 0 0; overflow-wrap: anywhere; }

.bookings-page .bookings-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@layer crm-admin-ui {
  /* Keep the register's surfaces and selected controls independent of legacy Finance theme rules. */
  body.crm-admin-ui.bookings-page :is(
    .bookings-workspace, .bookings-heading, .bookings-panel,
    .bookings-status-filters, .bookings-search, .bookings-search-input,
    .booking-drawer-header, .bookings-table, .bookings-row-status
  ) {
    box-shadow: none !important;
  }

  body.crm-admin-ui.bookings-page .bookings-heading {
    background: transparent !important;
    backdrop-filter: none !important;
  }

  body.crm-admin-ui.bookings-page .bookings-views > .bookings-view-button[aria-pressed="true"] {
    background: var(--booking-petrol) !important;
    border-color: var(--booking-petrol) !important;
    color: white !important;
  }

  body.crm-admin-ui.bookings-page .bookings-views > .bookings-view-button[aria-pressed="true"] > span {
    color: inherit !important;
  }

  body.crm-admin-ui.bookings-page .bookings-status-filters > .bookings-status-button[aria-pressed="true"] {
    box-shadow: inset 0 -3px var(--booking-gold) !important;
  }

  body.crm-admin-ui.bookings-page .bookings-table .bookings-detail-button {
    border-color: var(--booking-input-line) !important;
  }

  body.crm-admin-ui.bookings-page .booking-drawer-header {
    background: var(--booking-petrol) !important;
    backdrop-filter: none !important;
  }

  body.crm-admin-ui.bookings-page .booking-drawer-header h2 {
    color: white !important;
  }

  @media (max-width: 720px) {
    body.crm-has-page-hero.bookings-page > .crm-page-hero { display: none !important; }
    body.crm-has-page-hero.bookings-page .bookings-heading > .crm-page-hero-source-title {
      position: static !important;
      width: auto !important;
      height: auto !important;
      margin: 0 !important;
      overflow: visible !important;
      clip-path: none !important;
      white-space: normal !important;
    }
  }
}

@media (max-width: 720px) {
  .bookings-page .bookings-workspace {
    padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right));
  }

  .bookings-page .bookings-heading { display: grid; gap: 8px; }

  .bookings-page .bookings-heading-actions > :is(.bookings-button, button) {
    padding-inline: 8px;
    font-size: .875rem;
  }

  .bookings-page .bookings-controls { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .bookings-page .bookings-search { grid-column: 1 / -1; grid-row: 2; }
  .bookings-page #bookingsRefresh { grid-column: 2; grid-row: 1; }
  .bookings-page .bookings-extra { grid-row: 3; }

  .bookings-page :is(.bookings-workspace, .booking-drawer) :is(button, .bookings-button, summary, select, input) { min-height: 44px; }
  .bookings-page .bookings-controls :is(input, select) { font-size: 16px; }
  .bookings-page :is(.bookings-views, .bookings-status-filters) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .bookings-page :is(.bookings-views, .bookings-status-filters) > button {
    padding-inline: 6px;
    font-size: .875rem;
  }

  .bookings-page .bookings-table,
  .bookings-page .bookings-table tbody { display: block; }
  .bookings-page .bookings-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .bookings-page .bookings-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 8px;
    padding: 9px 11px;
    border-top: 1px solid var(--booking-line);
  }
  .bookings-page .bookings-table td { display: block; padding: 0; border: 0; }
  .bookings-page .bookings-table td:first-child, .bookings-page .bookings-table td.bookings-empty { grid-column: 1 / -1; }
  .bookings-page .bookings-table td.bookings-status-cell { grid-column: 1; grid-row: 2; }
  .bookings-page .bookings-table td.bookings-amount { grid-column: 2; grid-row: 1; }
  .bookings-page .bookings-table td.bookings-row-action { grid-column: 2; grid-row: 2; }
  .bookings-page .bookings-table td:first-child:not(.bookings-empty) { grid-row: 1; grid-column: 1; }

  body.bookings-page > #bookingDrawer {
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  body.bookings-page .booking-drawer > .booking-drawer-header {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 10px max(10px, env(safe-area-inset-left));
  }

  .bookings-page #bookingDrawerContent {
    padding: 12px max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
}
