/* Shared components (confirm dialog, My runs, download prefix); linked by the portal and the hosted tools. See static/js/gmb-ui.js. */
/* ---- Shared components used by the hosted tools and the portal (see static/js/gmb-ui.js) ---- */

/* Confirm dialog */
.gmb-dialog { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; border: 0; border-radius: var(--radius); padding: 0; max-width: min(440px, calc(100vw - 32px)); width: 100%; box-shadow: var(--shadow-pop); color: var(--ink); }
.gmb-dialog::backdrop { background: rgba(15, 23, 42, .5); }
.gmb-dialog form { padding: 20px 22px; margin: 0; }
.gmb-dialog h2 { margin: 0 0 8px; font-size: 18px; }
.gmb-dialog-msg { margin: 0 0 16px; color: var(--muted); line-height: 1.5; white-space: pre-line; }
.gmb-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.gmb-dialog .btn { min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); }
.gmb-dialog .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.gmb-dialog .btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.gmb-dialog .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* "My runs" panel */
#runs-panel summary { cursor: pointer; font-weight: 600; }
#runs-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.run-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--card); }
.run-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.run-when { color: var(--muted); font-size: 13px; margin-left: auto; }
.run-badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--ink); }
.run-badge.run-running { background: var(--info-hover); color: var(--info-ink); }
.run-badge.run-finished { background: var(--ok-soft); color: var(--ok); }
.run-badge.run-cancelled { background: var(--bad-soft); color: var(--bad); }
.run-bar { height: 6px; border-radius: 999px; background: var(--line); margin: 8px 0; overflow: hidden; }
.run-bar-fill { height: 100%; background: var(--brand); }
.run-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); }
.run-here { font-weight: 600; color: var(--brand); }
.run-error { color: var(--bad); }
.btn.sm { padding: 5px 12px; font-size: 13px; }

/* Inline optional file-name prefix next to the download buttons (replaces a browser prompt) */
.download-prefix { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 14px; flex-wrap: wrap; }
.download-prefix input { padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); min-width: 200px; }

@media (prefers-reduced-motion: reduce) { .gmb-dialog, .run-bar-fill { transition: none; } }

/* One focus ring for every button style system (portal .btn, the tools' own .btn). */
:where(.btn):focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Multi-pick: a checklist in a <details> (several Google Sheets) */
.multi-pick { position: relative; display: inline-block; min-width: 220px; max-width: 100%; font-weight: 400; font-size: 14px; }
.multi-pick > summary { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; box-sizing: border-box; padding: 6px 10px; font-size: 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--card, #fff); color: var(--ink); list-style: none; overflow-wrap: anywhere; }
.multi-pick > summary::-webkit-details-marker { display: none; }
.multi-pick > summary::after { content: ""; flex: none; width: 7px; height: 7px; margin-top: -3px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform .15s; }
.multi-pick[open] > summary::after { margin-top: 3px; transform: rotate(-135deg); }
.multi-pick-list { position: absolute; z-index: 20; left: 0; top: 100%; min-width: 100%; width: max-content; max-width: min(100%, calc(100vw - 32px)); box-sizing: border-box; max-height: 260px; overflow: auto; margin-top: 2px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--card, #fff); box-shadow: 0 6px 18px rgba(0, 0, 0, .15); }
.multi-pick-list label { display: flex; align-items: center; gap: 6px; padding: 3px 0; white-space: normal; overflow-wrap: anywhere; }
/* Inside a dialog the list is part of the flow, so the dialog grows instead of clipping it. */
.modal-overlay .multi-pick, dialog .multi-pick { display: block; }
.modal-overlay .multi-pick-list, dialog .multi-pick-list { position: static; width: auto; max-width: 100%; box-shadow: none; max-height: 200px; }
.multi-pick-all { border-bottom: 1px solid var(--line); margin-bottom: 4px; font-weight: 600; }
.pick-field { display: flex; align-items: center; gap: 6px; font-size: 14px; }
