/*
 * Workspace — l'espace des galeries (/account), dans le cadre du back-office (layouts/admin.css)
 *   <body class="admin"> : mêmes sidebar, page-header, panel, stat, table, list, dl que /admin
 *   en plus : .workspace-identity (monogramme, nom, ville · région), .nav-count (demandes non lues),
 *             .segmented (période), les graphiques du tableau de bord (.dashboard-*), le chargement d'une période,
 *             <dialog class="drawer"> (une demande ouverte depuis une liste), .toast (lien copié)
 * Couleurs, rayons et espacements : ceux de l'admin, aucune valeur propre.
 */

/* ── Galerie courante, sous la marque ── */
.workspace-identity { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-2); }
.workspace-identity > span:last-child { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.workspace-identity .muted { font-size: var(--text-xs); }
.workspace-identity-name { font-weight: 500; }

/* Les séries des graphiques du tableau de bord : une couleur, un sens, dans chaque graphique */
.admin {
  --chart-gallery: var(--accent);                                            /* ce que la galerie 3D amène : hors région, ART AU FÉMININ */
  --chart-home:    color-mix(in srgb, var(--foreground) 28%, transparent);   /* la région de la galerie */
  --chart-link:    color-mix(in srgb, var(--accent) 22%, var(--secondary));  /* le lien partagé par la galerie */
  --chart-track:   var(--secondary);                                         /* le fond d'une barre */
}

/* La pastille est rafraîchie par turbo stream dans son conteneur, qui s'efface de la mise en page */
.nav-count { display: contents; }

/* ── Période : deux liens sur un rail --secondary, l'option courante sur une carte claire
 *    comme la navigation ; la pastille glisse sous l'option choisie (segmented_controller) ── */
.segmented {
  position: relative;
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--secondary);
}
.segmented-thumb {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  border-radius: calc(var(--radius-md) - 2px);
  background: var(--card);
  transition: transform var(--transition-base), width var(--transition-base);
}
.segmented-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: calc(2.25rem - 6px);
  padding: 0 var(--space-3);
  border-radius: calc(var(--radius-md) - 2px);
  color: var(--muted-foreground);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.admin-main a.segmented-option:hover { color: var(--foreground); text-decoration: none; }
.segmented-option[aria-current="true"] { color: var(--foreground); font-weight: 500; }
/* Sans JavaScript, la pastille n'est pas placée : l'option courante porte son fond */
.segmented:not([data-controller]) .segmented-option[aria-current="true"] { background: var(--card); }
.segmented-option:focus-visible { outline: var(--focus-ring); outline-offset: 0; }

/* Exposition publiée : le point du badge bat doucement */
.badge-pulse::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: currentColor;
  animation: badge-pulse 2s ease-in-out infinite;
}

/* ── Tableau de bord ── */
@media (min-width: 1101px) { .dashboard-lead { grid-template-columns: 1.35fr 1fr; } }
.stat-value .muted { font-size: var(--text-base); font-weight: 400; }

/* Une pastille par demande, cuivre hors région */
.dashboard-dots { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.dashboard-dot { width: var(--space-3); height: var(--space-3); border-radius: var(--radius-pill); background: var(--chart-home); }
.dashboard-dot.is-out { background: var(--chart-gallery); }
.dashboard-legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); font-size: var(--text-xs); }
.dashboard-legend > span { display: inline-flex; align-items: center; gap: var(--space-2); }
.dashboard-swatch { display: inline-block; flex-shrink: 0; width: var(--space-2); height: var(--space-2); border-radius: var(--radius-pill); background: var(--chart-home); }
.dashboard-swatch.is-out { background: var(--chart-gallery); }
.dashboard-swatch.is-link { background: var(--chart-link); }
.dl .dashboard-swatch { margin-right: var(--space-1); }

/* Barres : la part d'un total, depuis le bord gauche */
.dashboard-track,
.dashboard-origin-bar { display: block; height: var(--space-2); overflow: hidden; border-radius: var(--radius-pill); background: var(--chart-track); }
.dashboard-origin-bar { background: var(--chart-link); }   /* ce que la barre ne couvre pas : le lien de la galerie */
.dashboard-bar { display: block; height: 100%; background: var(--chart-gallery); transform-origin: left center; transform: scaleX(var(--v, 0)); }
.dashboard-region .dashboard-track { flex-basis: 100%; }
.dashboard-region.is-home .dashboard-bar { background: var(--chart-home); }   /* comme sa pastille de légende */
.dashboard-sold { color: var(--destructive); }

/* Avant les premiers chiffres : un cadre vide qui se dessine */
.dashboard-empty-frame { display: block; width: 8rem; color: color-mix(in srgb, var(--accent) 55%, transparent); }
.dashboard-empty-frame rect { stroke-dasharray: 1; stroke-dashoffset: 1; animation: frame-draw 2.4s var(--ease-curator) forwards; }
.dashboard-empty-frame rect + rect { animation-delay: 0.4s; }
@keyframes frame-draw { to { stroke-dashoffset: 0; } }

/* Chargement d'une période : les chiffres en squelette */
turbo-frame[aria-busy="true"] [data-skeleton] {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--secondary);
  color: transparent;
}
turbo-frame[aria-busy="true"] [data-skeleton] > * { visibility: hidden; }
turbo-frame[aria-busy="true"] [data-skeleton]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--card) 70%, transparent) 50%, transparent 80%);
  transform: translateX(-100%);
  animation: sweep 1.6s ease-in-out infinite;
}
@keyframes sweep { to { transform: translateX(100%); } }

/* ── Tiroir d'une demande : le panneau de la page, sur le bord droit ── */
.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: 100%;
  max-width: 28rem;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid transparent;
  background: var(--card);
  background-clip: padding-box;
  color: var(--foreground);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--transition-base);
}
.drawer.is-open { transform: none; }
.drawer::backdrop { background: var(--overlay); }
.drawer-panel { position: relative; display: flex; flex-direction: column; height: 100%; }
.drawer-close { position: absolute; top: var(--space-2); right: var(--space-3); z-index: 1; }
.drawer-frame { display: flex; flex: 1; flex-direction: column; min-height: 0; }

.inquiry.panel { max-width: 40rem; }
.drawer .inquiry { display: flex; flex: 1; flex-direction: column; min-height: 0; max-width: none; border: 0; border-radius: 0; box-shadow: none; }
.drawer .inquiry .panel-header { padding-right: 3.5rem; }
.drawer .inquiry-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.drawer .dl > div { grid-template-columns: 7rem minmax(0, 1fr); }

/* ── Toast : la confirmation d'une copie, au bas de l'écran ── */
.toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  z-index: 50;
  max-width: calc(100vw - var(--space-8));
  padding: var(--space-3) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translate(-50%, var(--space-1));
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast:empty { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  .badge-pulse::before, .dashboard-empty-frame rect, turbo-frame[aria-busy="true"] [data-skeleton]::after { animation: none; }
  .dashboard-empty-frame rect { stroke-dashoffset: 0; }
  .drawer, .toast, .segmented-thumb { transition: none; }
}
