/* --- Google Drive and Slack connections (Delivery page, schedule setup) --- */
/* The errors are Polaris text the scripts show and hide, and Polaris overrides
   [hidden] on its own elements. */
[data-drive-picker-error][hidden],
[data-slack-channel-error][hidden] { display: none !important; }

/* Bulk invoice export: the dialog and its progress banner. The banner reuses the
   sync banner's loader classes so it inherits that animation without a second
   copy of it, but keeps its own element - an export and a sync can be running at
   the same time and neither may hide the other.

   It used to be a --panel-subtle slab holding one line of text and a far-right
   button: on the Orders ground that background is barely a shade off the page,
   so the only actionable thing on the screen read as the quietest. It's now a
   white result card - status rail down the left edge, icon tile, a title line
   over a detail line, and a filled Download - with the rail, tile and title
   switched off data-status so the poller only has to rewrite that attribute. */
.export-banner {
  display: grid;
  /* icon | copy | action | close. The close column is always present even when
     hidden, because `auto` collapses to zero width and that is cheaper than
     re-templating the grid per state. */
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 4px 14px;
  margin: 0 0 18px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  /* Rail as an inset shadow rather than a border-left: no layout shift, and the
     colour can change per state without moving the copy. */
  box-shadow: inset 3px 0 0 var(--accent), 0 1px 2px rgba(16, 35, 28, 0.04);
  font-size: 13px;
}
.export-banner[data-status="queued"],
.export-banner[data-status="running"] { box-shadow: inset 3px 0 0 var(--faint), 0 1px 2px rgba(16, 35, 28, 0.04); }
/* The old rule here reached for --amber-line and --amber-bg, which are defined
   nowhere in this stylesheet - so a failed export silently kept the neutral
   panel it was trying to tint. These are the warn tokens the rest of the app
   uses. */
.export-banner[data-status="failed"],
.export-banner[data-status="too_large"] {
  border-color: color-mix(in srgb, var(--amber) 25%, transparent);
  box-shadow: inset 3px 0 0 var(--amber), 0 1px 2px rgba(16, 35, 28, 0.04);
}

.export-banner-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent-weak);
  color: var(--accent);
}
.export-banner[data-status="queued"] .export-banner-icon,
.export-banner[data-status="running"] .export-banner-icon { background: var(--line-soft); color: var(--muted); }
.export-banner[data-status="failed"] .export-banner-icon,
.export-banner[data-status="too_large"] .export-banner-icon { background: var(--amber-weak); color: var(--amber); }

/* One glyph per state, chosen by the status attribute. The title is text, so it
   is swapped in the markup instead - see the note in orders.erb. */
.export-banner .exb-ico { display: none; }
.export-banner[data-status="ready"] .exb-ico-ready,
.export-banner[data-status="queued"] .exb-ico-working,
.export-banner[data-status="running"] .exb-ico-working,
.export-banner[data-status="failed"] .exb-ico-failed,
.export-banner[data-status="too_large"] .exb-ico-failed { display: block; }

.export-banner[data-status="running"] .exb-ico-working { animation: export-spin 1s linear infinite; }
@keyframes export-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .export-banner[data-status="running"] .exb-ico-working { animation: none; }
}

.export-banner-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.export-banner-title { font-size: 13.5px; font-weight: 650; letter-spacing: -0.005em; color: var(--text); }
.export-banner-meta { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.export-banner[data-status="failed"] .export-banner-meta,
.export-banner[data-status="too_large"] .export-banner-meta { color: var(--amber); }

/* Progress spans the full width on its own row - the copy keeps column 2 so the
   bar never squeezes the sentence. */
.export-banner .sync-loader { grid-column: 1 / -1; margin-top: 4px; }
.export-banner[data-status="running"] .sync-loader-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  transform: translateX(-100%);
  animation: sync-shimmer 1.4s linear infinite;
}

.export-banner-action { grid-column: 3; }
.export-banner-action svg { opacity: 0.88; }

/* Close.

   display:none rather than visibility/opacity while the export is still building:
   it takes the button out of the accessibility tree as well as the layout, so a
   merchant tabbing through a running banner cannot reach a control that would be
   refused server-side anyway (dismiss_invoice_export ignores queued and running). */
.export-banner-dismiss { grid-column: 4; display: flex; }
.export-banner[data-status="queued"] .export-banner-dismiss,
.export-banner[data-status="running"] .export-banner-dismiss { display: none; }
.export-banner-close {
  color: var(--muted);
  /* Quieter than the download beside it - this is the way out, not the point of
     the banner. */
  opacity: 0.7;
}
.export-banner-close:hover { opacity: 1; color: var(--text); }

@media (max-width: 600px) {
  /* The close keeps its own column on the top row so it stays reachable at the
     corner; only the download drops to a full-width row of its own. */
  .export-banner { grid-template-columns: auto minmax(0, 1fr) auto; }
  .export-banner-dismiss { grid-column: 3; }
  .export-banner-action { grid-column: 1 / -1; width: 100%; }
}

/* Bulk export (partials/export_dialog) is a Polaris s-modal; Polaris draws the
   fields, buttons and list. What's left is the progress bar, which Polaris has
   no component for. The bar only moves forward, one document at a time; the
   transition stops it jumping on each poll. */
.export-progress-bar { height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.export-progress-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.3s ease; }
.export-progress[data-status="cancelled"] .export-progress-fill { background: var(--faint); }

