/* Assistant panel — attached to the right of the nav as a menu extension.
   Sits under the sidebar in z-order and tracks sidebar width on hover.
   See /mockups/assistant-activity.html for the reference. */

#assistant-drawer-backdrop {
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, left 300ms ease;
  /* Start after the collapsed rail; menu stays interactive above. */
  left: 4rem;
  z-index: 35;
}
#assistant-drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
#assistant-drawer-panel {
  top: 0;
  bottom: 0;
  /* Docked to the menu's right edge; slides out from under it. */
  left: 4rem;
  z-index: 36; /* below #sidebar (z-40) */
  width: min(28rem, calc(100vw - 4rem));
  height: 100%;
  max-height: 100dvh;
  transform: translateX(-100%);
  /* left/width match sidebar's duration-300 expand */
  transition: transform 250ms ease, left 300ms ease, width 300ms ease;
  pointer-events: none;
  border-radius: 0;
  /* Closed panel still occupies x=0..4rem (under the sidebar). Hide it until
     the sidebar covers that strip, or the drawer is open — otherwise a white
     band flashes on login / hard refresh while #sidebar is display:none. */
  visibility: hidden;
}
/* Time-saved details: sized to fit three metric cards without right dead space. */
#assistant-drawer-panel.is-details-wide {
  width: min(74rem, calc(100vw - 4rem));
}
#sidebar.visible ~ #assistant-drawer-panel,
#assistant-drawer-panel.open {
  visibility: visible;
}
#assistant-drawer-panel.open {
  transform: translateX(0);
  pointer-events: auto;
}
/* Track sidebar expand — panel stays glued to the menu edge. */
#sidebar.visible:hover ~ #assistant-drawer-backdrop,
#sidebar.visible:hover ~ #assistant-drawer-panel {
  left: 20rem;
}
#sidebar.visible:hover ~ #assistant-drawer-panel {
  width: min(28rem, calc(100vw - 20rem));
}
#sidebar.visible:hover ~ #assistant-drawer-panel.is-details-wide {
  width: min(74rem, calc(100vw - 20rem));
}
@media (max-width: 640px) {
  #assistant-drawer-backdrop {
    left: 0;
  }
  #assistant-drawer-panel {
    left: 0;
    width: min(100vw, 28rem);
  }
  #assistant-drawer-panel.is-details-wide {
    width: min(100vw, 74rem);
  }
  #sidebar.visible:hover ~ #assistant-drawer-backdrop,
  #sidebar.visible:hover ~ #assistant-drawer-panel {
    left: 0;
  }
  #sidebar.visible:hover ~ #assistant-drawer-panel {
    width: min(100vw, 28rem);
  }
  #sidebar.visible:hover ~ #assistant-drawer-panel.is-details-wide {
    width: min(100vw, 74rem);
  }
}

.assistant-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.assistant-status--progress { background: #eff6ff; color: #1d4ed8; }
.assistant-status--review { background: #fffbeb; color: #b45309; }
.assistant-status--waiting { background: #f8fafc; color: #64748b; }
.assistant-status--ready { background: #ecfdf5; color: #047857; }
.assistant-status--error { background: #fef2f2; color: #b91c1c; }
.assistant-status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* Progress bar shown inside the card aside for in-progress/waiting rows. */
.assistant-status-progress {
  width: 8rem;
  margin-top: auto;
}
.assistant-status-progress__bar {
  height: 0.375rem;
  border-radius: 9999px;
  background: #e2e8f0;
  overflow: hidden;
  margin-bottom: 2px;
}
.assistant-status-progress__fill {
  height: 100%;
  background: #2563eb;
  border-radius: inherit;
  transition: width 0.4s ease;
}
.assistant-status-progress__pct {
  font-size: 0.6875rem;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}

.assistant-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 9999px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.assistant-action-btn:hover { background: #f8fafc; }
/* Merged status+CTA: status chip colors must beat .assistant-action-btn white fill. */
.assistant-action-btn--status {
  border-color: transparent;
}
.assistant-action-btn.assistant-status--review {
  background: #fffbeb;
  color: #b45309;
}
.assistant-action-btn.assistant-status--ready {
  background: #ecfdf5;
  color: #047857;
}
.assistant-action-btn.assistant-status--error {
  background: #fef2f2;
  color: #b91c1c;
}
.assistant-action-btn.assistant-status--progress {
  background: #eff6ff;
  color: #1d4ed8;
}
.assistant-action-btn.assistant-status--waiting {
  background: #f8fafc;
  color: #64748b;
}
.assistant-action-btn.assistant-status--review:hover {
  background: #fef3c7;
}
.assistant-action-btn.assistant-status--ready:hover {
  background: #d1fae5;
}
.assistant-action-btn.assistant-status--error:hover {
  background: #fee2e2;
}
.assistant-action-btn.assistant-status--progress:hover {
  background: #dbeafe;
}
.assistant-action-btn.assistant-status--waiting:hover {
  background: #f1f5f9;
}

.assistant-drawer-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  font-size: 0.8125rem;
  color: #94a3b8;
}

/* Time-saved stat buttons (jobs view header). */
.assistant-stats {
  display: flex;
  align-items: stretch;
  width: 100%;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.assistant-stat {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
}
.assistant-stat--click {
  cursor: pointer;
  border-radius: 0.75rem;
  padding: 0.75rem 2.25rem 0.75rem 0.85rem;
  position: relative;
  border: 1px solid transparent;
}
.assistant-stat--click:hover,
.assistant-stat--click:focus,
.assistant-stat--click.is-hot {
  background: #f8fafc;
  border-color: #e2e8f0;
}
.assistant-stat--click:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}
.assistant-stat-chevron {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: #64748b;
  opacity: 0;
  transition: opacity 150ms;
  pointer-events: none;
}
.assistant-stat--click:hover .assistant-stat-chevron,
.assistant-stat--click:focus .assistant-stat-chevron,
.assistant-stat--click.is-hot .assistant-stat-chevron {
  opacity: 1;
}
.assistant-stat-label {
  display: block;
  font-size: 12px;
  color: #64748b;
}
.assistant-stat-value {
  display: block;
  margin-top: 0.15rem;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

/* All / Unchecked view tabs. */
.assistant-review-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.assistant-review-tab {
  height: 30px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 9999px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  cursor: pointer;
  transition: background 150ms, border-color 150ms, color 150ms;
}
.assistant-review-tab:hover { background: #f8fafc; }
.assistant-review-tab.active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
  font-weight: 500;
}
.assistant-review-tab .count { color: #94a3b8; margin-left: 2px; }
.assistant-review-tab.active .count { color: #3b82f6; }

/* Task cards. */
.assistant-task-list { display: flex; flex-direction: column; gap: 0.6rem; }
.assistant-task-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.85rem;
  background: #fff;
  transition: opacity 150ms;
}
.assistant-task-card.is-done { opacity: 0.55; }
.assistant-task-card.is-done:hover { opacity: 1; }

.assistant-task-lead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* "Mark as reviewed" toggle — revealed on hover, persistent once done. */
.assistant-task-done-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: none;
  color: #94a3b8;
  font-size: 15px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms, color 150ms;
}
.assistant-task-card:hover .assistant-task-done-btn,
.assistant-task-card:focus-within .assistant-task-done-btn {
  opacity: 1;
}
.assistant-task-done-btn:hover { color: #059669; }
.assistant-task-done-btn:focus-visible {
  opacity: 1;
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  border-radius: 9999px;
}
.assistant-task-done-btn.is-done {
  opacity: 1;
  color: #059669;
}

.assistant-task-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.assistant-task-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.assistant-task-heading {
  min-width: 0;
}
.assistant-task-time {
  margin: 0 0 0.15rem;
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.assistant-task-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  flex-shrink: 0;
  margin-left: auto;
}
.assistant-task-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.assistant-task-file {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0.15rem 0 0;
  font-size: 11px;
  font-weight: 400;
  color: #94a3b8;
  line-height: 1.3;
}
.assistant-task-file i {
  font-size: 10px;
  width: 12px;
  text-align: center;
}
.assistant-task-detail {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  margin: 0.35rem 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: #64748b;
  width: 100%;
}
.assistant-task-detail--sse {
  color: #64748b;
}
.assistant-task-detail > span:last-child {
  min-width: 0;
  flex: 1;
}
.assistant-task-outcome {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Source legend + time-saved detail metric lines. */
.assistant-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.35rem;
  margin: 0.85rem 0 0;
  font-size: 12px;
  color: #94a3b8;
}
.assistant-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
/* Align period cards with the sparkle (offset = back button + gap). */
#assistant-details-view {
  margin-left: 2.25rem;
  width: max-content;
  max-width: 100%;
}
#assistant-details-view > .grid {
  width: max-content;
  max-width: 100%;
}
.assistant-period-card {
  width: max-content;
  max-width: 100%;
  box-sizing: border-box;
}
.assistant-period-card__hero {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.25rem;
  margin-bottom: 0.85rem;
}
.assistant-period-card__total {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #0f172a;
}
.assistant-period-card__days {
  margin: 0;
  font-size: 0.8125rem;
  color: #94a3b8;
  white-space: nowrap;
}
.assistant-time-bar {
  display: flex;
  width: 100%;
  height: 8px;
  border-radius: 9999px;
  overflow: hidden;
  background: #e2e8f0;
  margin-bottom: 1rem;
}
.assistant-time-bar.is-empty { display: none; }
.assistant-time-bar__seg { display: block; height: 100%; min-width: 0; }
.assistant-time-bar__seg--unplanned { background: #ea580c; }
.assistant-time-bar__seg--planned { background: #16a34a; }
.assistant-time-bar__seg--structure { background: #2563eb; }

.assistant-metrics-sections {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  gap: 0.75rem;
  align-items: stretch;
  justify-content: start;
}
.assistant-metric-section {
  width: max-content;
  max-width: none;
  background: #f8fafc;
  border-radius: 0.75rem;
  padding: 0.85rem 0.9rem;
}
.assistant-metric-section__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.assistant-metric-section__title {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}
.assistant-metric-section__dot {
  flex: 0 0 auto;
  width: 0.5rem;
  height: 0.5rem;
  margin-top: 0.3rem;
  border-radius: 9999px;
  background: currentColor;
}
.assistant-metric-section__hours {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
}
.assistant-metric-section--unplanned .assistant-metric-section__title,
.assistant-tone-text--unplanned { color: #ea580c; }
.assistant-metric-section--planned .assistant-metric-section__title,
.assistant-tone-text--planned { color: #16a34a; }
.assistant-metric-section--structure .assistant-metric-section__title,
.assistant-tone-text--structure { color: #2563eb; }
.assistant-metric-section__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
}
.assistant-metric-section__empty {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #94a3b8;
}
.assistant-metric-line {
  display: grid;
  grid-template-columns: 5ch 1fr;
  column-gap: 0.4rem;
  align-items: baseline;
  padding: 0.45rem 0;
  border-top: 1px solid #e2e8f0;
  font-size: 0.8125rem;
  line-height: 1.45;
  text-align: left;
  white-space: nowrap;
}
.assistant-metric-line:first-child { border-top: 0; padding-top: 0; }
.assistant-metric-line__count {
  font-weight: 700;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.assistant-metric-line__phrase {
  color: #64748b;
  text-align: left;
}
@media (max-width: 640px) {
  #assistant-details-view,
  #assistant-details-view > .grid,
  .assistant-period-card,
  .assistant-metric-section {
    width: 100%;
    max-width: 100%;
  }
  .assistant-metrics-sections {
    grid-template-columns: 1fr;
  }
  .assistant-metric-line {
    white-space: normal;
    grid-template-columns: auto 1fr;
  }
}

/* Sidebar Assistant trigger badge (in-progress job count). */
#link-assistant { position: relative; }
.assistant-nav-badge {
  position: absolute;
  top: -0.375rem;
  right: -0.5rem;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.25rem;
  border-radius: 9999px;
  background: #2563eb;
  color: #fff;
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1rem;
  pointer-events: none;
  box-shadow: 0 0 0 1.5px #fff;
}
.assistant-nav-badge.hidden { display: none; }

/* Nested saved-records picker (validated paramétrage jobs). */
.assistant-records-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.assistant-records-group-title {
  margin: 0 0 0.45rem;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #94a3b8;
}
.assistant-records-group-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.assistant-records-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  background: #fff;
  text-align: left;
  cursor: pointer;
  color: #0f172a;
  transition: background 150ms, border-color 150ms;
}
.assistant-records-row:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.assistant-records-row:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}
.assistant-records-row-label {
  min-width: 0;
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
}
.assistant-records-row-chevron {
  flex-shrink: 0;
  color: #94a3b8;
  font-size: 11px;
}
