/* ============================================================
   HARD DÉCO — Lot 9K-4
   Harmonisation des headers de toutes les pages.
   Présentation uniquement : aucun comportement métier modifié.
   ============================================================ */

:root {
  --hd-header-max-width: var(--hd-dedicated-max-width, 1480px);
  --hd-header-title-size: clamp(24px, 2vw, 28px);
  --hd-header-radius: 13px;
  --hd-header-control-height: 38px;
  --hd-header-shadow: 0 3px 14px rgba(15, 23, 42, .045);
  --hd-header-page-top: 16px;
}

/* Barre supérieure : listes et fiches ------------------------ */
body.app-shell-visible #main-content > .toolbar:not(:empty) {
  border-bottom: 1px solid color-mix(in srgb, var(--hd-color-border, var(--border)) 78%, transparent);
  background: color-mix(in srgb, var(--hd-color-surface, var(--panel)) 97%, var(--bg));
  box-shadow: 0 1px 0 rgba(15, 23, 42, .02);
}

body.app-shell-visible #main-content > .toolbar:not(:empty) > .inner {
  width: 100%;
  max-width: var(--hd-header-max-width);
  min-height: 58px;
  margin-inline: auto;
  padding: 8px 24px;
  box-sizing: border-box;
}

body.app-shell-visible #main-content > .toolbar:not(:empty) :is(.title, [class$="-page-breadcrumb"]) {
  min-width: 0;
  gap: 9px;
  color: var(--hd-color-text, var(--text));
  font-size: 19px;
  font-weight: 720;
  line-height: 1.2;
  letter-spacing: -.015em;
}

body.app-shell-visible #main-content > .toolbar:not(:empty) :is(.title, [class$="-page-breadcrumb"]) > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.app-shell-visible #main-content > .toolbar:not(:empty) :is(.title, [class$="-page-breadcrumb"]) > .ico {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--accent);
}

/* Identité immédiate et stable de toutes les fiches métier. */
:is(.project-page-toolbar, .project-page) { --entity-type-color: #4f46e5; }
:is(.quote-page-toolbar, .quote-page) { --entity-type-color: #d97706; }
:is(.invoice-page-toolbar, .invoice-page) { --entity-type-color: #0f766e; }
:is(.client-page-toolbar, .client-page) { --entity-type-color: #2563eb; }
:is(.artist-page-toolbar, .artist-page) { --entity-type-color: #7c3aed; }

body.app-shell-visible #main-content > :is(.project-page-toolbar, .quote-page-toolbar, .invoice-page-toolbar, .client-page-toolbar, .artist-page-toolbar)
  :is(.project-page-breadcrumb, .quote-page-breadcrumb, .invoice-page-breadcrumb, .client-page-breadcrumb, .artist-page-breadcrumb) > .ico {
  width: 32px;
  height: 32px;
  padding: 7px;
  border: 1px solid color-mix(in srgb, var(--entity-type-color) 28%, var(--border));
  border-radius: 9px;
  background: color-mix(in srgb, var(--entity-type-color) 10%, var(--panel));
  color: var(--entity-type-color);
  box-sizing: border-box;
}

body.app-shell-visible #main-content > .toolbar:not(:empty) .actions,
body.app-shell-visible #main-content > .toolbar:not(:empty) [class$="-page-actions"] {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

body.app-shell-visible #main-content > .toolbar:not(:empty) :is(.actions, [class$="-page-actions"]) :is(.btn, .btn-secondary),
body.app-shell-visible #main-content > .toolbar:not(:empty) > .inner > :is(.btn, .btn-secondary) {
  min-height: var(--hd-header-control-height);
  padding: 8px 12px;
  border-radius: 9px;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 680;
}

/* Sur une fiche, le retour reste discret et le nom devient le repère principal. */
:is(.project-page-toolbar, .quote-page-toolbar, .invoice-page-toolbar, .client-page-toolbar, .artist-page-toolbar) > .inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

:is(.project-page-toolbar, .quote-page-toolbar, .invoice-page-toolbar, .client-page-toolbar, .artist-page-toolbar)
  > .inner > :is(.project-page-back, .quote-page-back, .invoice-page-back, .client-page-back, #artistPageBack) {
  min-height: var(--hd-header-control-height);
  gap: 7px;
  padding: 8px 11px;
  border-radius: 9px;
  color: var(--hd-color-text-muted, var(--muted));
  font-size: 11px;
}

:is(.project-page-toolbar, .quote-page-toolbar, .invoice-page-toolbar, .client-page-toolbar, .artist-page-toolbar)
  > .inner > :is(.project-page-back, .quote-page-back, .invoice-page-back, .client-page-back, #artistPageBack):hover {
  color: var(--hd-color-text, var(--text));
}

/* Grand header des fiches ------------------------------------- */
:is(.project-page, .quote-page, .invoice-page, .client-page, .artist-page)
  :is(.project-page-hero, .quote-page-hero, .invoice-page-hero, .client-page-hero, .artist-page-hero) {
  min-height: 116px;
  gap: 20px;
  padding: 20px 22px;
  border: 1px solid color-mix(in srgb, var(--hd-color-border, var(--border)) 90%, transparent);
  border-radius: var(--hd-header-radius);
  background: var(--hd-color-surface, var(--panel));
  box-shadow: var(--hd-header-shadow);
}

:is(.project-page-heading, .quote-page-heading, .invoice-page-heading, .client-page-heading, .artist-page-heading) {
  min-width: 0;
}

:is(.project-page-kicker, .quote-page-kicker, .invoice-page-kicker, .client-page-kicker, .artist-page-kicker) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 6px;
  color: var(--hd-color-text-muted, var(--muted));
  font-size: 9px;
  font-weight: 760;
  line-height: 1.2;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.entity-page-kind {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 3px;
  padding: 5px 10px 5px 7px;
  border: 1px solid color-mix(in srgb, var(--entity-type-color) 28%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--entity-type-color) 10%, var(--panel));
  color: var(--entity-type-color);
  box-sizing: border-box;
  box-shadow: 0 2px 7px color-mix(in srgb, var(--entity-type-color) 9%, transparent);
}

.entity-page-kind > .lucide {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  stroke-width: 2;
}

.entity-page-kind > b {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .075em;
  line-height: 1;
}

:is(.project-page-heading, .quote-page-heading, .invoice-page-heading, .client-page-heading, .artist-page-heading) h1 {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--hd-color-text, var(--text));
  font-size: var(--hd-header-title-size);
  font-weight: 740;
  line-height: 1.13;
  letter-spacing: -.025em;
}

:is(.project-page-status, .quote-page-status, .invoice-page-status, .client-page-type, .artist-page-role, .artist-page-status) {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 720;
  line-height: 1;
  letter-spacing: .01em;
  text-transform: none;
}

:is(.project-page-client, .quote-page-relations button, .invoice-page-relations button, .client-page-primary-contact, #artistPageIdentity) {
  margin-top: 8px;
  color: var(--hd-color-text-muted, var(--muted));
  font-size: 11px;
  line-height: 1.4;
}

:is(.project-page-hero-meta, .quote-page-hero-meta, .invoice-page-hero-meta, .client-page-hero-meta, .artist-page-hero-meta) {
  gap: 8px;
}

:is(
  .project-page-hero-meta > div,
  .quote-page-hero-meta > div,
  .invoice-page-hero-meta > div,
  .client-page-hero-meta > *,
  .artist-page-hero-meta > *
) {
  min-width: 0;
  min-height: 48px;
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--hd-color-border, var(--border)) 72%, transparent);
  border-radius: 9px;
  background: color-mix(in srgb, var(--bg) 72%, var(--panel));
  box-sizing: border-box;
}

:is(.project-page-hero-meta, .quote-page-hero-meta, .invoice-page-hero-meta) small {
  color: var(--hd-color-text-muted, var(--muted));
  font-size: 9px;
  font-weight: 580;
}

:is(.project-page-hero-meta, .quote-page-hero-meta, .invoice-page-hero-meta) strong,
:is(.client-page-hero-meta, .artist-page-hero-meta) span {
  color: var(--hd-color-text, var(--text));
  font-size: 11px;
  font-weight: 650;
  line-height: 1.35;
}

/* Pages opérationnelles : Demandes, Planning et Charges ------- */
.operations-page-header {
  width: 100%;
  min-height: 116px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 22px;
  border: 1px solid color-mix(in srgb, var(--hd-color-border, var(--border)) 90%, transparent);
  border-radius: var(--hd-header-radius);
  background: var(--hd-color-surface, var(--panel));
  box-shadow: var(--hd-header-shadow);
  box-sizing: border-box;
}

.operations-page-header > div:first-child {
  min-width: 0;
}

.operations-page-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 760;
  line-height: 1.2;
  letter-spacing: .065em;
  text-transform: uppercase;
}

.operations-page-header h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--hd-color-text, var(--text));
  font-size: var(--hd-header-title-size);
  font-weight: 740;
  line-height: 1.13;
  letter-spacing: -.025em;
}

.operations-page-header h1 .lucide {
  flex: 0 0 auto;
  width: 23px;
  height: 23px;
  color: var(--accent);
}

.operations-page-header p:not(.operations-page-kicker) {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--hd-color-text-muted, var(--muted));
  font-size: 11px;
  line-height: 1.5;
}

.operations-page-header :is(.operations-page-actions, .charges-page-actions) {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.operations-page-header :is(.btn, .btn-secondary) {
  min-height: var(--hd-header-control-height);
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 680;
  white-space: nowrap;
}

/* Lot 9K-4.1 — précision géométrique des en-têtes de listes.
   Les pages opérationnelles utilisaient encore un rythme vertical de 20 px,
   contre 16 px pour les listes Devis/Factures/Clients/Artistes. */
.operations-page {
  padding-top: var(--hd-header-page-top);
}

.requests-page .operations-page-header {
  align-items: center;
}

.requests-page .request-toolbar {
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: end;
  gap: 8px;
  padding: 10px 14px 12px;
}

.requests-page :is(.request-search input, .request-filter select) {
  min-height: 40px;
  box-sizing: border-box;
}

.requests-page .request-visible-counter {
  display: none;
}

.requests-page .request-toolbar-actions {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.requests-page .request-toolbar-actions :is(.operations-page-count, .btn-secondary) {
  min-height: 40px;
  box-sizing: border-box;
}

.requests-page .request-toolbar-actions .operations-page-count {
  align-items: center;
  padding-block: 6px;
}

.requests-page .request-toolbar-actions .btn-secondary {
  padding: 8px 12px;
  border-radius: 9px;
  white-space: nowrap;
}

/* Accueil : même typographie, composition spécifique conservée */
.home-command .hero-title {
  margin: 0;
  color: var(--hd-color-text, var(--text));
  font-size: var(--hd-header-title-size);
  font-weight: 740;
  line-height: 1.13;
  letter-spacing: -.025em;
}

.home-command .hero-sub {
  margin-top: 7px;
  color: var(--hd-color-text-muted, var(--muted));
  font-size: 11px;
  line-height: 1.45;
}

.home-command .home-new-button {
  min-height: var(--hd-header-control-height);
  border-radius: 9px;
  font-size: 11px;
  font-weight: 680;
}

/* Tablette ----------------------------------------------------- */
@media (max-width: 960px) {
  body.app-shell-visible #main-content > .toolbar:not(:empty) > .inner {
    padding-inline: 16px;
  }

  :is(.project-page, .quote-page, .invoice-page, .client-page, .artist-page)
    :is(.project-page-hero, .quote-page-hero, .invoice-page-hero, .client-page-hero, .artist-page-hero) {
    gap: 16px;
    padding: 18px;
  }

  .operations-page-header {
    min-height: 0;
    align-items: flex-start;
    padding: 18px;
  }

  .requests-page .request-toolbar {
    grid-template-columns: minmax(180px, 1fr) auto;
  }

  .requests-page .request-toolbar-actions {
    grid-column: 1 / -1;
  }
}

/* Mobile ------------------------------------------------------- */
@media (max-width: 720px) {
  :root {
    --hd-header-title-size: 23px;
  }

  body.app-shell-visible #main-content > .toolbar:not(:empty) > .inner {
    min-height: 54px;
    padding: 8px 10px;
  }

  body.app-shell-visible #main-content > .toolbar:not(:empty) :is(.title, [class$="-page-breadcrumb"]) {
    font-size: 17px;
  }

  :is(.project-page-toolbar, .quote-page-toolbar, .invoice-page-toolbar, .client-page-toolbar, .artist-page-toolbar)
    > .inner {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 8px;
  }

  :is(.project-page-toolbar, .quote-page-toolbar, .invoice-page-toolbar, .client-page-toolbar, .artist-page-toolbar)
    > .inner > :is(.project-page-back, .quote-page-back, .invoice-page-back, .client-page-back, #artistPageBack) {
    width: 38px;
    min-width: 38px;
    padding: 0;
    justify-content: center;
  }

  :is(.project-page-toolbar, .quote-page-toolbar, .invoice-page-toolbar, .client-page-toolbar, .artist-page-toolbar)
    > .inner > :is(.project-page-back, .quote-page-back, .invoice-page-back, .client-page-back, #artistPageBack) span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  :is(.project-page-toolbar, .quote-page-toolbar, .invoice-page-toolbar, .client-page-toolbar, .artist-page-toolbar)
    [class$="-page-actions"] :is(.btn, .btn-secondary) span,
  .project-page-toolbar .actions .btn span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  :is(.project-page-toolbar, .quote-page-toolbar, .invoice-page-toolbar, .client-page-toolbar, .artist-page-toolbar)
    :is(.actions, [class$="-page-actions"]) :is(.btn, .btn-secondary) {
    width: 38px;
    min-width: 38px;
    padding: 0;
    justify-content: center;
  }

  :is(.project-page, .quote-page, .invoice-page, .client-page, .artist-page)
    :is(.project-page-hero, .quote-page-hero, .invoice-page-hero, .client-page-hero, .artist-page-hero) {
    min-height: 0;
    gap: 14px;
    padding: 16px;
  }

  :is(.project-page-hero-meta, .quote-page-hero-meta, .invoice-page-hero-meta, .client-page-hero-meta, .artist-page-hero-meta) {
    grid-template-columns: 1fr;
  }

  :is(
    .project-page-hero-meta > div,
    .quote-page-hero-meta > div,
    .invoice-page-hero-meta > div,
    .client-page-hero-meta > *,
    .artist-page-hero-meta > *
  ) {
    min-height: 44px;
    padding: 8px 10px;
  }

  .operations-page-header {
    flex-direction: column;
    gap: 16px;
    padding: 16px;
  }

  .operations-page-header :is(.operations-page-actions, .charges-page-actions) {
    width: 100%;
  }

  .requests-page .request-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .requests-page .request-toolbar-actions {
    grid-column: auto;
    width: 100%;
  }

  .requests-page .request-toolbar-actions > * {
    flex: 1 1 0;
    justify-content: center;
  }

  .operations-page-header :is(.operations-page-actions, .charges-page-actions) > *,
  .operations-page-header > .btn {
    flex: 1 1 0;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.app-shell-visible #main-content > .toolbar:not(:empty) *,
  .operations-page-header * {
    transition: none !important;
  }
}
