/* Indicateur global des échanges avec le serveur. */
.site-theme[data-theme] .xfor-server-wait {
  display: inline-flex;
  position: fixed;
  z-index: 3000;
  top: 14px;
  left: 50%;
  max-width: calc(100vw - 28px);
  padding: 9px 14px;
  align-items: center;
  gap: 9px;
  transform: translateX(-50%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  color: var(--color-primary);
  font: inherit;
  font-size: var(--font-size-compact);
  font-weight: 700;
  pointer-events: none;
}

.site-theme[data-theme] .xfor-server-wait[hidden] {
  display: none;
}

.site-theme[data-theme] .xfor-server-wait-spinner {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 2px solid var(--color-focus);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: xfor-server-wait-spin .75s linear infinite;
}

@keyframes xfor-server-wait-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 480px) {
  .site-theme[data-theme] .xfor-server-wait {
    top: 8px;
    padding: 8px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-theme[data-theme] .xfor-server-wait-spinner {
    animation: none;
  }
}

/* Surfaces et cartes communes à tous les worksheets. */
.site-theme[data-theme] .page-body > .section-content.workbook,
.site-theme[data-theme] .section-content.workbook,
.site-theme[data-theme] .workbook-content,
.site-theme[data-theme] .workbook-tab-content,
.site-theme[data-theme] .worksheet-dashboard,
.site-theme[data-theme] .worksheet-dashboard-grid,
.site-theme[data-theme] .worksheet-dashboard .ui-dashboard,
.site-theme[data-theme] .workbook-empty,
.site-theme[data-theme] .workbook-message {
  background: var(--color-canvas);
}

.site-theme[data-theme] .ui-dashboard-card,
.site-theme[data-theme] .workbook-tab-content.worksheet-table-surface,
.site-theme[data-theme] .formula-worksheet,
.site-theme[data-theme] .workbook-upload {
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.site-theme[data-theme] .worksheet-table-topbar,
.site-theme[data-theme] .formula-card-header,
.site-theme[data-theme] .ui-dashboard-card-header {
  display: flex;
  box-sizing: border-box;
  flex: 0 0 auto;
  width: 100%;
  min-height: 42px;
  padding: 6px 14px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--color-border-soft);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--color-surface-muted);
}

.site-theme[data-theme] .formula-card-title,
.site-theme[data-theme] .worksheet-table-title,
.site-theme[data-theme] .ui-dashboard-card-title {
  overflow: hidden;
  color: var(--color-text-strong);
  font-size: var(--font-size-title);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-theme[data-theme] .formula-card-actions,
.site-theme[data-theme] .worksheet-table-topbar-actions,
.site-theme[data-theme] .ui-dashboard-card-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.site-theme[data-theme] .formula-card-actions button,
.site-theme[data-theme] .worksheet-table-toggle {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font: inherit;
  cursor: pointer;
}

.site-theme[data-theme] .formula-card-actions button:hover,
.site-theme[data-theme] .worksheet-table-toggle:hover {
  background: var(--color-surface);
  color: var(--color-primary);
}

.site-theme[data-theme] .worksheet-table-toggle.active {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 4%, var(--color-surface));
  color: var(--color-primary);
}

.site-theme[data-theme] .worksheet-table-toggle,
.site-theme[data-theme] .worksheet-table-mobile-menu .worksheet-mobile-menu-dropdown button[data-table-action] {
  display: inline-flex;
  flex: 0 0 auto;
  flex-flow: row nowrap;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.site-theme[data-theme] .worksheet-table-toggle > .uiicon,
.site-theme[data-theme] .worksheet-table-mobile-menu .worksheet-mobile-menu-dropdown button[data-table-action] > .uiicon {
  flex: 0 0 auto;
}

.site-theme[data-theme] .formula-card-search,
.site-theme[data-theme] .worksheet-table-global-search {
  width: 190px;
  height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text-strong);
  font: inherit;
  outline: none;
}

.site-theme[data-theme] .formula-card-search:focus,
.site-theme[data-theme] .worksheet-table-global-search:focus {
  border-color: var(--color-primary);
}

.site-theme[data-theme] .formula-card-actions .formula-card-insert {
  display: inline-flex;
  min-width: auto;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--color-border-soft);
  background: var(--color-surface);
}

.site-theme[data-theme] .formula-body .formula-name-cell,
.site-theme[data-theme] .formula-body .formula-equals-cell,
.site-theme[data-theme] .formula-body .formula-value-cell {
  background: var(--color-surface);
}

/* Espacement commun des headers et cellules de toutes les tables worksheet. */
.site-theme[data-theme] .ui-table th,
.site-theme[data-theme] .ui-table td,
.site-theme[data-theme] .formula-table th,
.site-theme[data-theme] .formula-table td,
.site-theme[data-theme] .formula-name-cell,
.site-theme[data-theme] .formula-value-cell {
  padding: 8px 10px !important;
}

.site-theme[data-theme] .ui-table td.worksheet-table-cell-error {
  padding-right: 32px !important;
}

.site-theme[data-theme] .ui-table th.ui-table-column-header {
  text-transform: none;
}

.site-theme[data-theme] .worksheet-mobile-menu { position: relative; display: none; margin: 0; }
.site-theme[data-theme] .worksheet-mobile-menu-toggle { display: inline-flex; width: 30px; height: 30px; padding: 0; border: 0; border-radius: var(--radius-control); align-items: center; justify-content: center; list-style: none; background: transparent; color: var(--color-text-muted); cursor: pointer; }
.site-theme[data-theme] .worksheet-mobile-menu-toggle::-webkit-details-marker { display: none; }
.site-theme[data-theme] .worksheet-mobile-menu-toggle:hover,
.site-theme[data-theme] .worksheet-mobile-menu-toggle:focus-visible { background: var(--color-surface); color: var(--color-primary); outline: none; }
.site-theme[data-theme] .worksheet-mobile-menu-dropdown { position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; display: none; min-width: 170px; padding: 5px; border: 1px solid var(--color-border-soft); border-radius: var(--radius-control); flex-direction: column; gap: 2px; background: var(--color-surface); box-shadow: var(--shadow-menu); }
.site-theme[data-theme] .worksheet-mobile-menu[open] > .worksheet-mobile-menu-dropdown { display: flex; }
.site-theme[data-theme] .worksheet-mobile-menu-dropdown button { display: block; width: 100%; min-width: 0; height: auto; padding: 8px 10px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--color-text-strong); font: inherit; text-align: left; white-space: nowrap; cursor: pointer; }
.site-theme[data-theme] .worksheet-mobile-menu-dropdown button:hover,
.site-theme[data-theme] .worksheet-mobile-menu-dropdown button:focus-visible,
.site-theme[data-theme] .worksheet-mobile-menu-dropdown button.active { background: var(--color-surface); color: var(--color-primary); outline: none; }
@media (max-width: 767px) {
  .site-theme[data-theme] .worksheet-mobile-menu { display: block; }
  .site-theme[data-theme] .worksheet-table-direct-toggle,
  .site-theme[data-theme] .formula-card-actions .formula-card-insert,
  .site-theme[data-theme] .worksheet-table-title,
  .site-theme[data-theme] .formula-card-title { display: none; }

  .site-theme[data-theme] .formula-card-actions,
  .site-theme[data-theme] .worksheet-table-topbar-actions {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    justify-content: space-between;
  }

  .site-theme[data-theme] .formula-card-search,
  .site-theme[data-theme] .worksheet-table-global-search {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .site-theme * { transition-duration: 0ms !important; }
}

.site-theme[data-theme] .ui-table-progress-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.site-theme[data-theme] .ui-table-progress-label {
  min-width: 44px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.site-theme[data-theme] .ui-table-progress-track {
  flex: 1 1 auto;
  min-width: 40px;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--color-border-soft);
}

.site-theme[data-theme] .ui-table-progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--color-primary);
}

.site-theme[data-theme] .ui-table-footer-dropdown {
  position: absolute;
  z-index: 60;
  inset: 0;
  margin: 0;
  font-size: var(--font-size-small);
  font-weight: 500;
}

.site-theme[data-theme] .ui-table-footer-trigger {
  width: 100%;
  height: 100%;
  list-style: none;
  cursor: pointer;
}

.site-theme[data-theme] .ui-table-footer,
.site-theme[data-theme] .ui-table-footer-cell {
  overflow: visible !important;
}
.site-theme[data-theme] .ui-table-footer-dropdown:not(.is-open) .ui-table-footer-menu {
  display: none;
}


.site-theme[data-theme] .ui-table-footer {
  z-index: 20;
}

.site-theme[data-theme] .ui-table-footer-menu {
  position: absolute;
  z-index: 10000;
  bottom: calc(100% + 4px);
  left: 0;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-menu);
  overscroll-behavior: contain;
}

.site-theme[data-theme] .ui-table-footer-menu-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 5px 7px;
  white-space: nowrap;
  cursor: pointer;
}

.site-theme[data-theme] .ui-table-footer-menu-separator {
  display: block;
  height: 1px;
  margin: 5px 3px;
  background: var(--color-border-soft);
}

/* Modales communes Workbook / Workspace, alignées sur les propriétés de colonne. */
.site-theme[data-theme] .xfor-app-modal .modal-dialog {
  box-sizing: border-box;
  width: min(620px, calc(100vw - 32px));
  max-width: 620px;
  margin-inline: auto;
  overflow-x: hidden;
}

.site-theme[data-theme] .xfor-app-modal .modal-content {
  display: flex;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0 20px 20px;
  gap: 16px;
  overflow: hidden;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-modal);
  color: var(--color-text);
  font-family: var(--application-font);
  font-size: var(--font-size-base);
  flex-direction: column;
}

.site-theme[data-theme] .xfor-app-modal .modal-header,
.site-theme[data-theme] .xfor-app-modal .modal-body,
.site-theme[data-theme] .xfor-app-modal .modal-footer {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
}

.site-theme[data-theme] .xfor-app-modal .modal-header > *,
.site-theme[data-theme] .xfor-app-modal .modal-body > *,
.site-theme[data-theme] .xfor-app-modal .modal-footer > * {
  min-width: 0;
  max-width: 100%;
}

.site-theme[data-theme] .xfor-app-modal .modal-header {
  padding-top: 10px;
  display: flex;
  flex: 0 0 auto;
  min-height: 30px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.site-theme[data-theme] .xfor-app-modal .modal-body {
  display: flex;
  min-height: 0;
  padding-top: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  flex-direction: column;
  gap: 16px;
}

.site-theme[data-theme] .xfor-app-modal .modal-footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.site-theme[data-theme] .xfor-app-modal .modal-title,
.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor-header h5 {
  margin: 0;
  color: var(--color-text-strong);
  font-size: var(--font-size-title);
  font-weight: 600;
  line-height: 1.35;
}

.site-theme[data-theme] .xfor-app-modal .inspector-group,
.site-theme[data-theme] .xfor-app-modal .workspace-settings-field {
  display: flex;
  margin: 0;
  flex-direction: column;
  gap: 6px;
}

.site-theme[data-theme] .xfor-app-modal .workspace-settings-field + .workspace-settings-field {
  margin-top: 0;
}

.site-theme[data-theme] .profile-modal .profile-form,
.site-theme[data-theme] .profile-modal .profile-password-fields {
  display: flex;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  flex-direction: column;
  gap: 8px;
}

.site-theme[data-theme] .profile-modal .profile-form { min-height: 0; gap: 0; }
.site-theme[data-theme] .profile-modal .modal-body { display: flex; flex-direction: column; gap: 8px; }
.site-theme[data-theme] .profile-modal .profile-modal-description { margin: 0; color: var(--color-text-muted); line-height: 1.45; }
.site-theme[data-theme] .profile-modal .profile-password-fields { padding-top: 0; border-top: 1px solid var(--color-border-soft); }
.site-theme[data-theme] .profile-modal .profile-password-fields legend { padding: 0; margin-bottom: 8px; color: var(--color-text); font-weight: 600; }
.site-theme[data-theme] .profile-modal .profile-form-error { min-height: 1.4em; line-height: 1.4; }
.site-theme[data-theme] .profile-modal .profile-form-error[hidden] { display: none; }

.site-theme[data-theme] .users-modal .modal-dialog { width: min(720px, calc(100vw - 32px)); max-width: 720px; }
.site-theme[data-theme] .users-modal .modal-body { overflow-x: hidden; overflow-y: auto; }
.site-theme[data-theme] .users-modal-status { margin: 0; color: var(--color-text-muted); }
.site-theme[data-theme] .users-modal-status:empty { display: none; }
.site-theme[data-theme] .users-modal-list { display: grid; gap: 8px; }
.site-theme[data-theme] .users-modal-item { display: grid; min-width: 0; padding: 10px; gap: 4px; border: 1px solid var(--color-border-soft); border-radius: var(--radius-md); background: var(--color-surface); overflow-wrap: anywhere; }
.site-theme[data-theme] .users-modal-email { color: var(--color-text-muted); }
.site-theme[data-theme] .users-modal-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.site-theme[data-theme] .users-modal-detail > :first-child { color: var(--color-text-muted); }

@media (max-width: 480px) {
  .site-theme[data-theme] .users-modal .modal-dialog { width: calc(100vw - 16px); }
  .site-theme[data-theme] .users-modal-detail { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 480px) {
  .site-theme[data-theme] .profile-modal .modal-dialog { width: calc(100vw - 16px); }
  .site-theme[data-theme] .profile-modal .modal-content { max-height: calc(100dvh - 16px); padding: 0 16px 16px; }
}

.site-theme[data-theme] .xfor-app-modal .inspector-group > label,
.site-theme[data-theme] .xfor-app-modal .workspace-settings-field > label {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: 1.25;
  text-transform: uppercase;
}

/* Native form controls: independent from Bootstrap. */
body :where(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"]), textarea, select, .form-control, .theme-control) {
  box-sizing: border-box;
  max-width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background-color: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

body :where(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"]), textarea, select, .form-control, .theme-control):focus {
  border-color: var(--color-focus);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-focus) 25%, transparent);
}

body :where(input[type="checkbox"], input[type="radio"], .form-check-input) { accent-color: var(--color-primary); }
body :where(input, textarea, select):disabled { background-color: var(--color-surface-disabled); color: var(--color-text-disabled); cursor: default; }

.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor .form-label {
  margin: 0 0 6px;
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: 1.25;
  text-transform: uppercase;
}

.site-theme[data-theme] .xfor-app-modal .form-control {
  box-sizing: border-box;
  width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: var(--font-size-control);
  box-shadow: none;
  outline: none;
}

.site-theme[data-theme] .xfor-app-modal .form-control:focus {
  border-color: var(--color-focus);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-focus) 25%, transparent);
}

.site-theme[data-theme] .xfor-app-modal textarea.form-control {
  min-height: 96px;
  resize: vertical;
}

.site-theme[data-theme] .xfor-app-modal .btn {
  min-height: 32px;
  padding: 6px 14px;
  border-radius: var(--radius-control);
  font-size: var(--font-size-base);
  font-weight: 500;
  line-height: 1.4;
}

.site-theme[data-theme] .xfor-app-modal .form-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.site-theme[data-theme] .xfor-app-modal .form-check-input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--color-primary);
}

.site-theme[data-theme] .xfor-app-modal .form-check-label { cursor: pointer; }
.site-theme[data-theme] .xfor-app-modal .btn.is-disabled { opacity: .55; }

.site-theme[data-theme] .xfor-app-modal .btn:disabled {
  opacity: .55;
  cursor: wait;
}

.site-theme[data-theme] .xfor-app-modal .close,
.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor-close {
  display: inline-grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 20px;
  line-height: 1;
  opacity: 1;
}

.site-theme[data-theme] .xfor-app-modal .close:hover,
.site-theme[data-theme] .xfor-app-modal .close:focus-visible,
.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor-close:hover,
.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor-close:focus-visible {
  background: transparent;
  color: var(--color-primary);
  outline: none;
}

.site-theme[data-theme] .xfor-app-modal.workspace-settings-modal .modal-dialog {
  width: min(540px, calc(100vw - 32px));
  max-width: 540px;
}

.site-theme[data-theme] .xfor-app-modal.workbook-column-editor-modal .modal-dialog {
  width: min(480px, calc(100vw - 32px));
  max-width: 480px;
}

.site-theme[data-theme] .xfor-app-modal.workbook-column-editor-modal.is-formula-column .modal-dialog,
.site-theme[data-theme] .xfor-app-modal.workbook-formula-help-modal .modal-dialog {
  width: min(900px, calc(100vw - 32px));
  max-width: 900px;
}

.site-theme[data-theme] .workbook-assistant-help-modal .modal-dialog { width: min(760px, calc(100vw - 32px)); max-width: 760px; }
.site-theme[data-theme] .workbook-assistant-help-modal .modal-content { height: min(680px, calc(100dvh - 32px)); background: var(--color-surface); color: var(--color-text); }
.site-theme[data-theme] .workbook-assistant-help-modal .modal-body { overflow: hidden; }
.site-theme[data-theme] .workbook-assistant-help-results { display: flex; min-height: 0; flex: 1 1 auto; padding: 4px; overflow-x: hidden; overflow-y: auto; flex-direction: column; gap: 10px; }
.site-theme[data-theme] .workbook-assistant-help-empty { margin: auto; color: var(--color-text-muted); text-align: center; }
.site-theme[data-theme] .workbook-assistant-help-message { display: flex; max-width: 86%; margin: 0; }
.site-theme[data-theme] .workbook-assistant-help-message.is-user { align-self: flex-end; }
.site-theme[data-theme] .workbook-assistant-help-message.is-assistant { align-self: flex-start; }
.site-theme[data-theme] .workbook-assistant-help-message-content { padding: 9px 12px; border: 1px solid var(--color-border-soft); border-radius: var(--radius-md); background: var(--color-surface-muted); color: var(--color-text); line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.site-theme[data-theme] .workbook-assistant-help-message-time { display: block; margin-top: 5px; color: var(--color-text-muted); font-size: var(--font-size-small); line-height: 1.2; text-align: right; }
.site-theme[data-theme] .workbook-assistant-help-message.is-user .workbook-assistant-help-message-content { border-color: var(--color-primary); background: var(--color-primary-soft); }
.site-theme[data-theme] .workbook-assistant-help-composer { display: flex; flex: 0 0 auto; align-items: flex-end; gap: 8px; }
.site-theme[data-theme] .xfor-app-modal .workbook-assistant-help-input { min-height: 58px; max-height: 180px; resize: vertical; }
.site-theme[data-theme] .workbook-assistant-help-send,
.site-theme[data-theme] .workbook-assistant-help-clear { display: inline-flex; width: 32px; height: 32px; padding: 0; border: 0; border-radius: var(--radius-sm); align-items: center; justify-content: center; background: transparent; color: var(--color-text-muted); cursor: pointer; }
.site-theme[data-theme] .workbook-assistant-help-send { flex: 0 0 32px; background: var(--color-primary-soft); color: var(--color-primary); }
.site-theme[data-theme] .workbook-assistant-help-send:hover,
.site-theme[data-theme] .workbook-assistant-help-send:focus,
.site-theme[data-theme] .workbook-assistant-help-clear:hover,
.site-theme[data-theme] .workbook-assistant-help-clear:focus { background: var(--color-surface-hover); color: var(--color-primary); outline: none; }
.site-theme[data-theme] .workbook-assistant-help-send:disabled,
.site-theme[data-theme] .workbook-assistant-help-clear:disabled { opacity: .5; cursor: default; }
.site-theme[data-theme] .workbook-assistant-help-status { min-height: 18px; margin: 0; color: var(--color-text-muted); font-size: var(--font-size-small); }

@media (max-width: 480px) {
  .site-theme[data-theme] .workbook-assistant-help-modal .modal-dialog { width: calc(100vw - 16px); }
  .site-theme[data-theme] .workbook-assistant-help-modal .modal-content { height: calc(100dvh - 16px); padding: 0 16px 16px; }
  .site-theme[data-theme] .workbook-assistant-help-message { max-width: 94%; }
}

.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor {
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  background: transparent;
  flex-direction: column;
  gap: 16px;
}

.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor-header,
.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor-body,
.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor-footer {
  margin: 0;
  padding: 0;
  border: 0;
}

.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor-header,
.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor-footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor-header {
  padding-top: 10px;
  min-height: 30px;
  justify-content: space-between;
}

.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor-body {
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor-body .row {
  width: 100%;
  max-width: 100%;
  margin-right: 0;
  margin-left: 0;
}

.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor-body :where([class^="col-"], [class*=" col-"]) {
  min-width: 0;
  max-width: 100%;
}

.site-theme[data-theme] .xfor-app-modal .dashboard-card-editor-footer {
  justify-content: flex-end;
}

.site-theme[data-theme] .ui-table-column-name {
  display: flex;
  width: fit-content;
  min-width: fit-content;
  max-width: max-content;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
}

.site-theme[data-theme] .ui-table-column-name .ui-table-column-title {
  flex: 0 0 auto;
  min-width: 0;
  max-width: none;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.site-theme[data-theme] .ui-table-column-name .ui-table-column-title > span:last-child {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.site-theme[data-theme] .ui-table-column-header .ui-table-sort-button,
.site-theme[data-theme] .ui-table-column-header .worksheet-sort-glyph {
  display: inline-flex;
  height: 24px;
  align-items: center;
  justify-content: center;
  font-family: var(--application-font);
  font-size: inherit;
  line-height: 1;
  vertical-align: middle;
}

.site-theme[data-theme] .ui-table-header-content > .worksheet-column-actions {
  flex: 0 0 auto;
  margin-left: auto;
}

.site-theme[data-theme] .ui-table-column-header:focus-within .worksheet-column-actions {
  opacity: 1;
}

@media (hover: none), (pointer: coarse) {
  .site-theme[data-theme] .worksheet-column-actions {
    opacity: 1;
    visibility: visible;
  }
}

.site-theme[data-theme] .worksheet-formula-calculating .formula-table-scroll {
  pointer-events: none;
  cursor: progress;
}

/* En portrait tablette, la carte suit son contenu sans dépasser la fenêtre. */
@media (min-width: 600px) and (max-width: 1024px) and (orientation: portrait) {
  .site-theme[data-theme] .workbook-tab-content.worksheet-table-surface {
    flex: 0 1 auto;
    align-self: center;
    height: fit-content;
    min-height: 0;
    max-height: calc(100% - 12px);
    overflow: hidden;
  }

  .site-theme[data-theme] .worksheet-table-surface > .ui-table-wrapper {
    flex: 0 1 auto;
    min-height: 0;
    max-height: 100%;
  }

  .site-theme[data-theme] .formula-worksheet {
    flex: 0 1 auto;
    align-self: center;
    height: fit-content;
    min-height: 0;
    max-height: min(700px, calc(100dvh - 230px));
    overflow: hidden;
  }

  .site-theme[data-theme] .formula-worksheet-host { display: contents; }

  .site-theme[data-theme] .formula-worksheet > .formula-table-scroll {
    flex: 0 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow: auto;
    overscroll-behavior: contain;
  }
}

/* Les menus des headers doivent sortir du cadre, même quand la carte est vide. */
.site-theme[data-theme] .workbook-tab-content.worksheet-table-surface {
  overflow: hidden;
}
.site-theme[data-theme] .worksheet-table-topbar,
.site-theme[data-theme] .formula-card-header {
  position: relative;
  z-index: 100;
}

.site-theme[data-theme] .worksheet-mobile-menu[open] {
  z-index: 1001;
}

.site-theme[data-theme] .worksheet-mobile-menu-dropdown {
  z-index: 1000;
}

.site-theme[data-theme] .worksheet-table-surface > .ui-table-wrapper,
.site-theme[data-theme] .formula-worksheet > .formula-table-scroll {
  position: relative;
  z-index: 1;
  min-height: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Les menus du Workbook et des tableaux restent au-dessus des headers de cartes. */
.site-theme[data-theme] .workbook-command-menu {
  position: relative;
  z-index: 200;
}

.site-theme[data-theme] .workbook-tabs {
  position: relative;
  z-index: 220;
}

.site-theme[data-theme] .workbook-command-menu.has-open-command-menu {
  z-index: 230;
}

.site-theme[data-theme] .workbook-tab-dropdown {
  z-index: 210;
}

.site-theme[data-theme] .workbook-menu-children {
  z-index: 211;
}

.site-theme[data-theme] .worksheet-table-surface > .ui-table-wrapper:has(.ui-table-footer-dropdown.is-open) {
  z-index: 240;
}

/* Le menu du footer doit pouvoir dépasser sa carte et rester devant les cartes voisines. */
.site-theme[data-theme] .worksheet-dashboard .grid-stack-item:has(.ui-table-footer-dropdown.is-open) {
  z-index: 10000 !important;
}

.site-theme[data-theme] .worksheet-dashboard .ui-dashboard-card:has(.ui-table-footer-dropdown.is-open),
.site-theme[data-theme] .worksheet-dashboard .ui-dashboard-card-body:has(.ui-table-footer-dropdown.is-open) {
  overflow: visible !important;
}

.site-theme[data-theme] .worksheet-dashboard .ui-table-wrapper:has(.ui-table-footer-dropdown.is-open) {
  position: relative;
  z-index: 10001;
}

.site-theme[data-theme] .profile-modal [hidden] { display: none; }
.site-theme[data-theme] .profile-modal .form-group { margin: 0; }
.site-theme[data-theme] .profile-modal .account-invite-fields,
.site-theme[data-theme] .profile-modal .account-share-fields,
.site-theme[data-theme] .profile-modal .profile-email-confirmation,
.site-theme[data-theme] .profile-modal .account-share-sheets {
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.site-theme[data-theme] .profile-modal textarea { resize: vertical; }
.site-theme[data-theme] .profile-modal .account-share-sheets label { display: flex; gap: 8px; align-items: center; }
.site-theme[data-theme] .profile-modal .account-invitation-message { white-space: pre-wrap; overflow-wrap: anywhere; }
.site-theme[data-theme] .workbook.is-read-only .workbook-formula-bar,
.site-theme[data-theme] .workbook.is-read-only .workbook-command-menu-group[data-menu-category="creation"],
.site-theme[data-theme] .workbook.is-read-only .workbook-command-menu-group[data-menu-category="about"],
.site-theme[data-theme] .workbook.is-read-only .workbook-menu-toggle,
.site-theme[data-theme] .workbook.is-read-only .workbook-add-toggle,
.site-theme[data-theme] .workbook.is-read-only .workbook-tab-close { display: none; }

.site-theme[data-theme] .workbook.is-read-only .ui-dashboard-card-action[data-action="configure"],
.site-theme[data-theme] .workbook.is-read-only .ui-dashboard-card-action[data-action="remove"] { display: none; }
