/* ============================================================
   HARD DÉCO — Lot 9K-6
   Modales restantes et fenêtres utilitaires.
   Présentation uniquement : logique et contenus inchangés.
   ============================================================ */

:root {
  --hd-modal-radius: 14px;
  --hd-modal-header-height: 62px;
  --hd-modal-shadow: 0 28px 80px rgba(15, 23, 42, .3);
  --hd-modal-overlay: rgba(15, 23, 42, .54);
  --hd-modal-body-pad-x: 22px;
}

/* Coque générique --------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  background: var(--hd-modal-overlay);
  backdrop-filter: blur(3px);
  box-sizing: border-box;
}

.modal-backdrop.modal-backdrop--transparent {
  padding: 20px;
  background: transparent !important;
  backdrop-filter: none !important;
}

.modal {
  position: relative;
  inset: auto;
  width: min(92vw, 800px);
  height: auto;
  max-width: calc(100vw - 40px);
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--hd-color-border, var(--border)) 92%, transparent);
  border-radius: var(--hd-modal-radius);
  background: var(--hd-color-surface, var(--panel));
  color: var(--hd-color-text, var(--text));
  box-shadow: var(--hd-modal-shadow);
  box-sizing: border-box;
}

.modal.small { width: min(420px, calc(100vw - 40px)); }
.modal.medium { width: min(660px, calc(100vw - 40px)); }
.modal.large { width: min(880px, calc(100vw - 40px)); }
.modal.xlarge { width: min(1240px, calc(100vw - 40px)); }
.modal.modal-wide { width: min(1040px, calc(100vw - 40px)); }

@media (min-width: 1200px) {
  .modal.xlarge {
    position: relative;
    left: auto;
    top: auto;
    transform: translateY(20px);
    max-height: calc(100dvh - 40px);
  }

  .modal.xlarge.show {
    transform: translateY(0);
  }
}

/* En-tête ------------------------------------------------------ */
.modal-header {
  min-height: var(--hd-modal-header-height);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px 12px var(--hd-modal-body-pad-x);
  overflow: visible;
  border-bottom: 1px solid var(--hd-color-border, var(--border));
  background: color-mix(in srgb, var(--hd-color-surface, var(--panel)) 95%, var(--accent) 5%);
  box-sizing: border-box;
}

.modal-header-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.modal-header .icon-wrap {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 11%, var(--panel));
  color: var(--accent);
}

.modal-header .icon-wrap .lucide {
  width: 17px;
  height: 17px;
  color: currentColor;
}

.modal-header h3 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--hd-color-text, var(--text));
  font-size: 16px;
  font-weight: 720;
  line-height: 1.25;
  letter-spacing: -.012em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-header .closeModalBtn,
.modal-header > .btn-icon {
  flex: 0 0 auto;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid var(--hd-color-border, var(--border));
  border-radius: 9px;
  background: var(--hd-color-surface, var(--panel));
  color: var(--hd-color-text-muted, var(--muted));
  box-shadow: none;
}

.modal-header .closeModalBtn:hover,
.modal-header > .btn-icon:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
  color: var(--accent);
}

.modal-header .closeModalBtn .lucide,
.modal-header > .btn-icon .lucide {
  width: 16px;
  height: 16px;
}

.modal-header.success {
  border-bottom-color: color-mix(in srgb, var(--hd-color-success, #15803d) 30%, var(--border));
  background: color-mix(in srgb, var(--hd-color-success, #15803d) 10%, var(--panel));
  color: var(--hd-color-text, var(--text));
}

.modal-header.success .icon-wrap {
  background: color-mix(in srgb, var(--hd-color-success, #15803d) 14%, var(--panel));
  color: var(--hd-color-success, #15803d);
}

.modal-header.success .btn-icon {
  color: var(--hd-color-text-muted, var(--muted));
}

/* Corps et défilement ----------------------------------------- */
.modal-body {
  min-height: 0;
  flex: 1 1 auto;
  padding: 18px var(--hd-modal-body-pad-x) 22px;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--hd-color-surface, var(--panel));
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 55%, var(--border)) transparent;
}

.modal-body::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.modal-body::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 55%, var(--border));
  background-clip: padding-box;
}

.modal-content {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.modal-content > :first-child { margin-top: 0; }
.modal-content > :last-child { margin-bottom: 0; }

.modal .tabs {
  position: sticky;
  top: -18px;
  z-index: 4;
  margin-inline: calc(var(--hd-modal-body-pad-x) * -1);
  padding-inline: var(--hd-modal-body-pad-x);
  border-bottom: 1px solid var(--hd-color-border, var(--border));
  background: color-mix(in srgb, var(--hd-color-surface, var(--panel)) 94%, transparent);
  backdrop-filter: blur(8px);
}

/* Pied d’actions ---------------------------------------------- */
.modal-actions {
  min-height: 62px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 11px var(--hd-modal-body-pad-x);
  border-top: 1px solid var(--hd-color-border, var(--border));
  background: color-mix(in srgb, var(--bg) 62%, var(--panel));
  box-sizing: border-box;
}

.modal-actions-dynamic {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-actions :is(.btn, .btn-secondary, .btn-primary, .btn-accent, .btn-warning, .btn-danger, .modal-footer-btn) {
  min-width: 96px;
  min-height: var(--hd-action-height, 38px);
}

.modal-actions button {
  opacity: 1;
}

/* Fenêtre de création rapide de l’accueil --------------------- */
.home-modal-backdrop {
  padding: 20px;
  background: var(--hd-modal-overlay);
  backdrop-filter: blur(3px);
  box-sizing: border-box;
}

.home-modal {
  width: min(760px, calc(100vw - 40px));
  max-height: calc(100dvh - 40px);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--hd-color-border, var(--border)) 92%, transparent);
  border-radius: var(--hd-modal-radius);
  background: var(--hd-color-surface, var(--panel));
  box-shadow: var(--hd-modal-shadow);
}

.home-modal .hd {
  min-height: var(--hd-modal-header-height);
  padding: 12px 16px 12px var(--hd-modal-body-pad-x);
  border-bottom: 1px solid var(--hd-color-border, var(--border));
  background: color-mix(in srgb, var(--panel) 95%, var(--accent) 5%);
  box-sizing: border-box;
}

.home-modal .hd :is(h2, h3, strong) {
  margin: 0;
  font-size: 16px;
  font-weight: 720;
  letter-spacing: -.012em;
}

.home-modal .hd .close {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 9px;
  font-size: 0;
}

.home-modal .bd {
  min-height: 0;
  padding: 18px var(--hd-modal-body-pad-x) 22px;
  overflow-y: auto;
}

.home-modal .ft {
  min-height: 62px;
  align-items: center;
  padding: 11px var(--hd-modal-body-pad-x);
  background: color-mix(in srgb, var(--bg) 62%, var(--panel));
}

.home-modal .grid-new {
  gap: 10px;
}

.home-new-card {
  min-height: 104px;
  gap: 11px;
  padding: 14px;
  border-color: var(--hd-color-border, var(--border));
  border-radius: 11px;
  background: var(--hd-color-surface, var(--panel));
  box-shadow: none;
}

.home-new-card:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  background: color-mix(in srgb, var(--accent) 6%, var(--panel));
  box-shadow: 0 5px 14px rgba(15, 23, 42, .07);
  transform: translateY(-1px);
}

.home-new-card .titleHomecard {
  margin: 0 0 3px;
  font-size: 13px;
  font-weight: 700;
}

.home-new-card .desc {
  font-size: 10px;
  line-height: 1.45;
}

/* Pickers utilitaires ----------------------------------------- */
.picker-backdrop {
  padding: 16px;
  background: var(--hd-modal-overlay);
  backdrop-filter: blur(3px);
  box-sizing: border-box;
}

.picker-modal {
  width: min(500px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--hd-color-border, var(--border)) 92%, transparent);
  border-radius: 13px;
  background: var(--hd-color-surface, var(--panel));
  color: var(--hd-color-text, var(--text));
  box-shadow: var(--hd-modal-shadow);
}

.picker-modal h4 {
  min-height: 58px;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 13px 18px;
  border-bottom: 1px solid var(--hd-color-border, var(--border));
  background: color-mix(in srgb, var(--panel) 95%, var(--accent) 5%);
  box-sizing: border-box;
  font-size: 15px;
  font-weight: 720;
}

.picker-body {
  min-height: 0;
  gap: 13px;
  padding: 17px 18px;
  overflow-y: auto;
}

.picker-row {
  gap: 10px;
}

.picker-row label {
  color: var(--hd-color-text-muted, var(--muted));
  font-size: 10px;
  font-weight: 680;
}

.picker-actions {
  justify-content: flex-end;
  gap: 8px;
  padding: 11px 18px;
  border-top: 1px solid var(--hd-color-border, var(--border));
  background: color-mix(in srgb, var(--bg) 62%, var(--panel));
}

.type-grid {
  gap: 9px;
}

.type-grid .type-btn {
  min-height: 42px;
  padding: 9px 10px;
  border-color: var(--hd-color-border, var(--border));
  border-radius: 9px;
  background: var(--hd-color-surface, var(--panel));
  font-size: 11px;
}

.type-grid .type-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
  transform: none;
}

/* Fenêtres de succès ------------------------------------------ */
.devis-success-backdrop {
  padding: 18px;
  background: var(--hd-modal-overlay);
  backdrop-filter: blur(3px);
  box-sizing: border-box;
}

.devis-success-modal {
  width: min(500px, calc(100vw - 36px));
  max-height: calc(100dvh - 36px);
  padding: 0;
  overflow: hidden auto;
  border: 1px solid color-mix(in srgb, var(--hd-color-border, var(--border)) 92%, transparent);
  border-radius: 14px;
  background: var(--hd-color-surface, var(--panel));
  color: var(--hd-color-text, var(--text));
  box-shadow: var(--hd-modal-shadow);
}

.devis-success-header {
  gap: 11px;
  margin: 0;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--hd-color-border, var(--border));
  background: color-mix(in srgb, var(--hd-color-success, #15803d) 8%, var(--panel));
}

.devis-success-icon,
.ms-success-icon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  margin: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--hd-color-success, #15803d) 13%, var(--panel));
  color: var(--hd-color-success, #15803d);
}

.devis-success-icon .lucide,
.ms-success-icon .lucide {
  width: 21px;
  height: 21px;
  color: currentColor;
}

.devis-success-title h2,
.ms-success-title {
  margin: 0;
  color: var(--hd-color-text, var(--text));
  font-size: 16px;
  font-weight: 720;
  line-height: 1.25;
}

.devis-success-title p,
.ms-success-subtitle,
.ms-success-meta {
  margin: 4px 0 0;
  color: var(--hd-color-text-muted, var(--muted));
  font-size: 10px;
  line-height: 1.45;
}

.devis-success-body {
  margin: 0;
  padding: 14px 20px;
}

.devis-success-tag,
.ms-success-tag {
  padding: 5px 8px;
  border: 1px solid var(--hd-color-border, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 72%, var(--panel));
  color: var(--hd-color-text-muted, var(--muted));
  font-size: 9px;
}

.devis-success-footer {
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--hd-color-border, var(--border));
  background: color-mix(in srgb, var(--bg) 62%, var(--panel));
}

.devis-success-footer .btn {
  min-height: var(--hd-action-height, 38px);
  padding: 8px 12px;
  border-radius: var(--hd-action-radius, 9px);
  font-size: var(--hd-action-font-size, 11px);
}

.modal-body .ms-success-card {
  max-width: 540px;
  margin: 0 auto;
}

.ms-success-card {
  gap: 9px;
  padding: 18px 4px 4px;
  color: var(--hd-color-text, var(--text));
}

.ms-success-actions {
  gap: 8px;
  margin-top: 8px;
}

.ms-success-action {
  min-height: 54px;
  gap: 10px;
  padding: 10px 12px;
  border-color: var(--hd-color-border, var(--border));
  border-radius: 10px;
  background: var(--hd-color-surface, var(--panel));
}

.ms-success-action:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
  transform: none;
}

.ms-success-action-label { font-size: 11px; font-weight: 700; }
.ms-success-action-caption { color: var(--hd-color-text-muted, var(--muted)); font-size: 9px; }

/* Suggestions et panneaux flottants --------------------------- */
.suggest-fly__card {
  border: 1px solid var(--hd-color-border, var(--border));
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: var(--hd-color-surface, var(--panel));
  box-shadow: 0 16px 36px rgba(15, 23, 42, .15);
}

.suggest__search input {
  min-height: 40px;
  border-color: var(--hd-color-border, var(--border)) !important;
  border-radius: 0 !important;
  background: color-mix(in srgb, var(--bg) 72%, var(--panel)) !important;
  font-size: 11px;
}

.suggest__item {
  min-height: 40px;
  padding: 9px 12px;
  border-bottom-color: color-mix(in srgb, var(--border) 72%, transparent);
  background: var(--hd-color-surface, var(--panel));
  color: var(--hd-color-text, var(--text));
  font-size: 11px;
}

.suggest__item:hover,
.suggest__item:focus-visible {
  outline: 0;
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
  color: var(--accent);
}

/* Anciennes fiches latérales, si elles sont encore appelées --- */
:is(.artiste-sidebar-backdrop, .client-sidebar-backdrop) {
  position: fixed;
  inset: 0;
  z-index: 2050;
  background: var(--hd-modal-overlay);
  backdrop-filter: blur(2px);
}

:is(.artiste-sidebar-panel, .client-sidebar-panel) {
  position: absolute;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--hd-color-border, var(--border));
  background: var(--hd-color-surface, var(--panel));
  color: var(--hd-color-text, var(--text));
  box-shadow: -18px 0 55px rgba(15, 23, 42, .2);
}

:is(.artiste-sidebar-header, .client-sidebar-header) {
  min-height: var(--hd-modal-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 12px 18px;
  border-bottom: 1px solid var(--hd-color-border, var(--border));
  background: color-mix(in srgb, var(--panel) 95%, var(--accent) 5%);
}

:is(.artiste-sidebar-scroll, .client-sidebar-scroll) {
  min-height: 0;
  flex: 1 1 auto;
  padding: 18px;
  overflow-y: auto;
}

/* Tablette ----------------------------------------------------- */
@media (max-width: 960px) {
  .modal-backdrop {
    padding: 0;
  }

  .modal,
  .modal.small,
  .modal.medium,
  .modal.large,
  .modal.xlarge,
  .modal.modal-wide {
    width: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border-width: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .modal-header {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .modal-actions {
    padding-bottom: calc(11px + env(safe-area-inset-bottom, 0px));
  }

  .home-modal-backdrop {
    align-items: stretch;
    padding: 0;
  }

  .home-modal {
    width: 100%;
    max-height: 100dvh;
    border-width: 0;
    border-radius: 0;
  }
}

/* Mobile ------------------------------------------------------- */
@media (max-width: 680px) {
  :root {
    --hd-modal-body-pad-x: 14px;
  }

  .modal-header {
    min-height: 58px;
    padding-right: 11px;
  }

  .modal-header .icon-wrap {
    width: 31px;
    height: 31px;
  }

  .modal-header h3 {
    font-size: 15px;
  }

  .modal-body {
    padding-top: 14px;
    padding-bottom: 18px;
  }

  .modal .tabs {
    top: -14px;
  }

  .modal-actions {
    min-height: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .modal-actions-dynamic {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-actions-dynamic > :only-child,
  .modal-actions-dynamic > :nth-last-child(3):first-child,
  .modal-actions-dynamic > :nth-last-child(3):first-child ~ :last-child {
    grid-column: 1 / -1;
  }

  .modal-actions :is(.btn, .btn-secondary, .btn-primary, .btn-accent, .btn-warning, .btn-danger, .modal-footer-btn) {
    width: 100%;
    min-width: 0;
  }

  .home-modal .grid-new {
    grid-template-columns: 1fr;
  }

  .home-new-card {
    min-height: 82px;
  }

  .picker-backdrop {
    align-items: flex-end;
    padding: 10px;
  }

  .picker-modal {
    width: 100%;
    max-height: calc(100dvh - 20px);
    border-radius: 14px 14px 10px 10px;
  }

  .picker-row {
    align-items: stretch;
    flex-direction: column;
  }

  .picker-actions > * {
    flex: 1 1 0;
  }

  .devis-success-backdrop {
    align-items: flex-end;
    padding: 10px;
  }

  .devis-success-modal {
    width: 100%;
    max-height: calc(100dvh - 20px);
    border-radius: 14px 14px 10px 10px;
  }

  .devis-success-footer :is(.primary-actions, .secondary-actions) {
    display: grid;
    grid-template-columns: 1fr;
  }

  .devis-success-footer .btn {
    width: 100%;
    justify-content: center;
  }

  :is(.artiste-sidebar-panel, .client-sidebar-panel) {
    width: 100%;
    border-left: 0;
  }
}

@media (forced-colors: active) {
  .modal,
  .home-modal,
  .picker-modal,
  .devis-success-modal,
  :is(.artiste-sidebar-panel, .client-sidebar-panel) {
    border: 1px solid CanvasText;
  }
}

@media (prefers-reduced-motion: reduce) {
  :is(
    .modal-backdrop,
    .modal,
    .home-modal,
    .picker-backdrop,
    .picker-modal,
    .devis-success-modal,
    .ms-success-action,
    .suggest-fly__card,
    .artiste-sidebar-panel,
    .client-sidebar-panel
  ) {
    animation: none !important;
    transition: none !important;
  }
}
