/*
 * L’Alcôve Console UX — product-level interaction layer.
 * Loaded last on purpose: this file owns cross-page ergonomics, focus,
 * feedback, page context and responsive behavior without changing domain UI.
 */

:root {
  --control-height: 42px;
  --control-height-compact: 36px;
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--info) 28%, transparent);
  --surface-raised: color-mix(in srgb, var(--surface-2) 92%, white 8%);
  --top-progress: linear-gradient(90deg, var(--primary-strong), var(--primary), var(--info));
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---------- Navigation progress / feedback ---------- */

.app-progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 1200;
  height: 3px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
}

.app-progress > span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: 0 999px 999px 0;
  background: var(--top-progress);
  box-shadow: 0 0 18px color-mix(in srgb, var(--primary) 48%, transparent);
  transform: translateX(-110%);
}

.app-progress.is-active {
  opacity: 1;
}

.app-progress.is-active > span {
  animation: app-progress-slide 900ms cubic-bezier(.32,.72,.18,1) infinite;
}

@keyframes app-progress-slide {
  0% { transform: translateX(-110%); }
  70% { transform: translateX(190%); }
  100% { transform: translateX(245%); }
}

/* ---------- Navigation favorites ---------- */

.favorite-navigation {
  margin: 4px 0 10px;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--line));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.favorite-navigation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  padding: 0 7px 4px;
  gap: 8px;
}

.favorite-navigation-hint {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.favorite-navigation .nav-group-items {
  display: grid;
  gap: 3px;
}

.favorite-navigation button[data-page] {
  width: 100%;
}

.favorite-star {
  margin-left: auto;
  color: var(--primary);
  font-size: 13px;
}

body.sidebar-compact .favorite-navigation {
  padding: 6px;
}

body.sidebar-compact .favorite-navigation-head,
body.sidebar-compact .favorite-navigation .nav-text,
body.sidebar-compact .favorite-navigation .favorite-star {
  display: none;
}

/* ---------- Page context ---------- */

.page-heading-copy {
  position: relative;
}

.page-context-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-height: 24px;
  margin-top: 7px;
  gap: 8px;
}

.page-work-status,
.page-section-jump {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  gap: 7px;
  padding: 4px 9px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 700;
}

.page-work-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 12%, transparent);
}

.page-work-status[data-state="dirty"] {
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 32%, var(--line));
  background: var(--warning-soft);
}

.page-work-status[data-state="dirty"] .page-work-dot {
  background: var(--warning);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 13%, transparent);
}

.page-work-status[data-state="pending"] {
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 32%, var(--line));
  background: var(--info-soft);
}

.page-work-status[data-state="pending"] .page-work-dot {
  background: var(--info);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--info) 13%, transparent);
}

.page-work-status[data-state="error"] {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 32%, var(--line));
  background: var(--danger-soft);
}

.page-work-status[data-state="error"] .page-work-dot {
  background: var(--danger);
}

.page-section-jump {
  border: 0;
  cursor: pointer;
  transition: color var(--ease), background var(--ease);
}

.page-section-jump:hover,
.page-section-jump[aria-expanded="true"] {
  color: var(--text);
  background: var(--surface-hover);
}

.page-section-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 80;
  display: grid;
  width: min(390px, calc(100vw - 36px));
  max-height: min(420px, 55vh);
  padding: 7px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-1) 96%, black 4%);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(22px);
}

.page-section-option {
  display: grid;
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  text-align: left;
}

.page-section-option:hover,
.page-section-option:focus-visible {
  color: var(--text);
  background: var(--primary-soft);
}

.page-pin[aria-pressed="true"] {
  color: #171019;
  border-color: transparent;
  background: var(--primary);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 18%, transparent);
}

/* ---------- Controls: predictable targets and readable forms ---------- */

.button {
  min-height: var(--control-height);
  padding-inline: 15px;
  font-weight: 680;
}

.button.small {
  min-height: var(--control-height-compact);
  padding: 7px 11px;
}

.icon-button,
.shortcut-button,
.sidebar-link {
  min-width: var(--control-height);
  min-height: var(--control-height);
}

.input,
.select,
textarea,
input[type="search"] {
  min-height: var(--control-height);
}

textarea.input {
  min-height: 92px;
}

.field {
  gap: 7px;
}

.field > label,
.field-label-row > label {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 720;
  letter-spacing: .01em;
  text-transform: none;
}

.field-help,
.field small {
  line-height: 1.55;
}

.input:focus,
.select:focus,
textarea:focus {
  border-color: color-mix(in srgb, var(--info) 72%, var(--line));
  box-shadow: var(--focus-ring);
}

.button[data-busy="true"],
.icon-button[data-busy="true"] {
  position: relative;
  pointer-events: none;
  opacity: .72;
}

.button[data-busy="true"]::after,
.icon-button[data-busy="true"]::after {
  width: 14px;
  height: 14px;
  margin-left: 2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  animation: ux-spin 700ms linear infinite;
}

@keyframes ux-spin { to { transform: rotate(360deg); } }

/* ---------- Cards / tables / bulk actions ---------- */

.card,
.panel {
  transition: border-color var(--ease), background var(--ease), box-shadow var(--ease);
}

.card:hover {
  border-color: color-mix(in srgb, var(--line-strong) 78%, var(--primary) 22%);
}

.table-wrap {
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}

.table th {
  color: var(--muted-strong);
  font-weight: 780;
}

.table tbody tr:focus-within td {
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.bulk-bar.visible {
  position: sticky;
  bottom: 14px;
  z-index: 15;
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--line));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-1) 94%, transparent);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
}

.empty {
  min-height: 100px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-1) 48%, transparent);
}

/* ---------- Dialogs ---------- */

dialog {
  max-height: min(88vh, 920px);
  overflow: hidden;
}

dialog form[method="dialog"] {
  display: flex;
  flex-direction: column;
  max-height: inherit;
}

.modal-head {
  flex: 0 0 auto;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.modal-foot {
  position: sticky;
  bottom: 0;
  z-index: 2;
  flex: 0 0 auto;
  background: color-mix(in srgb, var(--surface-1) 96%, transparent);
  backdrop-filter: blur(16px);
}

/* ---------- Toasts ---------- */

.toast-zone {
  width: min(440px, calc(100vw - 28px));
}

.toast {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  width: 100%;
  max-width: none;
  padding: 13px 13px 13px 14px;
  border-left-width: 1px;
  background: color-mix(in srgb, var(--surface-2) 95%, black 5%);
  box-shadow: var(--shadow-lg);
  animation: toast-in 180ms ease-out;
}

.toast::before {
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
  content: "";
}

.toast.error::before { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.toast.warning::before { background: var(--warning); box-shadow: 0 0 0 4px var(--warning-soft); }
.toast.info::before { background: var(--info); box-shadow: 0 0 0 4px var(--info-soft); }

.toast-message {
  min-width: 0;
  color: var(--text-soft);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.toast-close {
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.toast-close:hover {
  color: var(--text);
  background: var(--surface-hover);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Page transition ---------- */

.content {
  scroll-margin-top: calc(var(--topbar-height) + 14px);
}

.content[data-page-ready="true"] {
  animation: content-enter 160ms ease-out;
}

@keyframes content-enter {
  from { opacity: .72; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- High-value long pages ---------- */

.config-index,
.ticket-filter-card,
.runtime-log-toolbar {
  box-shadow: var(--shadow-sm);
}

.config-section > summary {
  min-height: 52px;
}

.config-section > summary:hover {
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.section-head h2,
.section-head h3 {
  text-wrap: balance;
}

.page-description,
.muted,
.field-help {
  text-wrap: pretty;
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .page-context-row {
    margin-top: 5px;
  }

  .page-work-label {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 920px) {
  .favorite-navigation {
    margin-inline: 4px;
  }

  .page-section-menu {
    position: fixed;
    top: auto;
    right: 14px;
    bottom: 14px;
    left: 14px;
    width: auto;
    max-height: 54vh;
  }

  .bulk-bar.visible {
    bottom: 10px;
  }
}

@media (max-width: 680px) {
  .topbar-actions {
    gap: 7px;
  }

  .page-context-row {
    gap: 6px;
  }

  .page-work-status,
  .page-section-jump {
    min-height: 26px;
    padding: 3px 8px;
  }

  .page-pin {
    display: none;
  }

  .button:not(.small) {
    min-height: 44px;
  }

  .modal-foot {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .toast-zone {
    right: 14px;
    bottom: max(14px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media (forced-colors: active) {
  .page-work-dot,
  .toast::before { forced-color-adjust: none; }
  .card, .panel, .button, .input, .select, textarea { border-color: CanvasText; }
}

/* Cockpit quotidien */
.overview-cockpit{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(320px,.9fr);gap:16px;margin-top:16px}
.overview-attention-row{width:100%;display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:12px;text-align:left;border:0;border-top:1px solid var(--border);background:transparent;color:inherit;padding:12px 4px;cursor:pointer;border-radius:8px}
.overview-attention-row:first-of-type{border-top:0}
.overview-attention-row:hover,.overview-attention-row:focus-visible{background:var(--surface-hover,rgba(255,255,255,.04))}
.overview-attention-row strong,.overview-attention-row small{display:block}.overview-attention-row small{margin-top:2px;color:var(--muted)}
.overview-runtime-grid{display:grid;gap:14px}.overview-runtime-grid>div{display:grid;gap:3px;padding:10px 0;border-top:1px solid var(--border)}.overview-runtime-grid>div:first-child{border-top:0}.overview-runtime-grid small{color:var(--muted)}
.overview-quick-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px}
.overview-quick-link{position:relative;display:grid;gap:5px;min-height:92px;text-align:left;cursor:pointer;padding-right:44px}.overview-quick-link>span:not(.overview-quick-arrow){color:var(--muted);font-size:.9rem}.overview-quick-arrow{position:absolute;right:16px;top:50%;translate:0 -50%;font-size:1.25rem}.overview-quick-link:hover,.overview-quick-link:focus-visible{translate:0 -1px}
.overview-feature-list{display:flex;flex-wrap:wrap;gap:6px}
@media(max-width:900px){.overview-cockpit{grid-template-columns:1fr}}
@media(prefers-reduced-motion:reduce){.overview-quick-link:hover,.overview-quick-link:focus-visible{translate:none}}

/* XP workspace */
.xp-member-head{display:flex;align-items:center;justify-content:space-between;gap:1rem}.xp-member-score{display:flex;flex-direction:column;align-items:flex-end;gap:.15rem}.xp-member-score strong{font-size:1.7rem;line-height:1}.xp-member-score span{color:var(--muted)}.xp-activity-chart{height:180px;display:flex;align-items:flex-end;gap:3px;padding:.75rem .25rem .25rem;border-bottom:1px solid var(--border);overflow:hidden}.xp-activity-day{flex:1;min-width:3px;height:100%;display:flex;align-items:flex-end}.xp-activity-bar{display:block;width:100%;min-height:4px;border-radius:4px 4px 1px 1px;background:linear-gradient(180deg,var(--accent),color-mix(in srgb,var(--accent) 45%,transparent));opacity:.88}.xp-member-picker{max-width:760px}.xp-recalc-cards .metric strong{font-variant-numeric:tabular-nums}.xp-toolbar{position:relative}.xp-metrics .metric{min-width:0}
@media(max-width:700px){.xp-member-head{align-items:flex-start;flex-direction:column}.xp-member-score{align-items:flex-start}.xp-activity-chart{height:130px}.xp-recalc-cards{grid-template-columns:1fr!important}}
