/* The calendar card and the supplier share-links card (js/ui/calendar-card.js,
   js/ui/share-links-card.js). Built from the app's own buttons, badges, fields and tokens; this file
   holds only what those two cards add: the switch, the link row, the preview list and the rows of
   shared links. Loaded after app.css. test/a11y-static.mjs and test/contrast.mjs cover it. */

.sharing { display: block; }
.sharing h3 { font-family: var(--font-display); font-size: 26px; font-weight: 500; letter-spacing: -.01em; line-height: 1.15; margin: 0; }
.sharing-lead { margin: var(--space-8) 0 0; color: var(--muted); line-height: 1.55; }
.sharing-note { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
.sharing-foot { margin: var(--space-16) 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.sharing-label { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: var(--space-4); }
.sharing-caption { font-size: 15px; font-weight: 700; color: var(--muted); margin: 0 0 var(--space-16); }
.sharing-actions { display: flex; flex-wrap: wrap; gap: var(--space-8); }

/* The raised panel both cards sit in, the same surface as a dialog. */
.dialog-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow);
  padding: var(--space-32) var(--space-32); display: flex; flex-direction: column; gap: var(--space-16); min-width: 0;
}
.sharing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: var(--space-32) var(--space-48); align-items: start; }

/* ---- the link, and copying it ---- */

.link-row { display: flex; flex-wrap: wrap; gap: var(--space-8); }
.link-row input {
  flex: 1 1 260px; min-width: 0; min-height: 46px; padding: 0 var(--space-16); font: inherit; font-size: 14px;
  color: var(--text); background: var(--card); border: 1.5px solid var(--control); border-radius: var(--radius);
}
.link-row input:focus { border-color: var(--accent); }
.sharing a.btn { text-decoration: none; }

/* ---- switches ---- */

.switch-list { margin-top: var(--space-4); }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-16);
  min-height: 56px; padding: var(--space-8) 0; border-bottom: 1px solid var(--border); cursor: pointer;
}
.switch-row:last-child { border-bottom: none; }
.switch-text { display: flex; flex-direction: column; min-width: 0; }
.switch-label { font-weight: 700; }
.switch-hint { color: var(--muted); font-size: 13.5px; line-height: 1.45; }

/* The button is the whole 64 by 44 touch target, and the track inside it is only what you see. */
.switch {
  flex: none; width: 64px; min-height: 44px; padding: 0; border: 0; background: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: flex-end; border-radius: var(--radius-pill);
}
.switch-track {
  position: relative; width: 52px; height: 30px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1.5px solid var(--control); transition: background .15s, border-color .15s;
}
.switch-thumb {
  position: absolute; top: 50%; left: 4px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--control); transform: translateY(-50%); transition: left .15s, background .15s;
}
/* On is told by the thumb sitting at the right end as well as by the fill. */
.switch[aria-checked="true"] .switch-track { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"] .switch-thumb { left: 26px; background: var(--accent-ink); }
.switch:disabled { cursor: not-allowed; }
.switch:disabled .switch-track { opacity: .55; }
@media (prefers-reduced-motion: reduce) {
  .switch-track, .switch-thumb { transition: none; }
}

/* ---- the banner with the padlock ---- */

.sharing-banner {
  display: flex; align-items: flex-start; gap: var(--space-16); padding: var(--space-16) var(--space-16); border-radius: var(--radius-card);
  background: var(--surface); color: var(--text); font-weight: 500; line-height: 1.55; font-size: 14.5px;
}
.sharing-banner .lock-icon { flex: none; display: inline-flex; margin-top: var(--space-4); color: var(--muted); }
.text-link {
  font: inherit; font-weight: 700; color: var(--accent-dark); background: none; border: 0; padding: 0;
  text-decoration: underline; cursor: pointer; border-radius: 4px;
}
@media (max-width: 640px), (pointer: coarse) {
  /* An inline link in a sentence is exempt from 44px, but this one is the only way to replace a link
     that has got out, so it gets the room anyway. */
  .sharing-banner .text-link { display: inline-flex; align-items: center; min-height: 44px; }
}

/* ---- the preview: "What shows up in your calendar" ---- */

.cal-box { background: var(--surface); border-radius: var(--radius-card); padding: var(--space-8) var(--space-24); }
.cal-list { list-style: none; margin: 0; padding: 0; }
.cal-item { display: flex; align-items: center; gap: var(--space-16); padding: var(--space-16) 0; border-bottom: 1px solid var(--border-strong); }
.cal-item:last-child { border-bottom: none; }
.cal-empty, .cal-more { padding: var(--space-16) 0; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
.dchip { flex: none; min-width: 56px; display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.dchip b { font-family: var(--font-display); font-weight: 500; font-size: 24px; }
.dchip span { font-size: 12px; color: var(--muted); }
.cal-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.cal-item-text b { font-weight: 700; overflow-wrap: anywhere; }
.cal-item-text span { color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
.cal-item .badge { align-self: center; }
@media (max-width: 480px) { .cal-box { padding: var(--space-4) var(--space-16); } .dialog-panel { padding: var(--space-24) var(--space-16); } }

/* ---- the links you have shared ---- */

.share-panel { display: flex; flex-direction: column; gap: var(--space-16); min-width: 0; max-width: 760px; }
.share-list { list-style: none; margin: 0; padding: 0; }
.share-row { display: flex; align-items: center; gap: var(--space-16); flex-wrap: wrap; padding: var(--space-16) 0; border-bottom: 1px solid var(--border); }
.share-row:last-child { border-bottom: none; }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--text); font-size: 13px; font-weight: 800;
}
.share-row-text { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; }
.share-row-text b { font-weight: 700; overflow-wrap: anywhere; }
.share-row-text span { color: var(--muted); font-size: 13.5px; }
.share-row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-8); margin-left: auto; }

/* ---- the dialog that makes a link ---- */

.share-dialog .field select { padding-right: var(--space-32); }
.check-lines { display: flex; flex-direction: column; }
.check-line {
  display: flex; align-items: flex-start; gap: var(--space-16); padding: var(--space-8) 0; min-height: 44px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.check-line:last-child { border-bottom: none; }
.check-line input { flex: none; width: 22px; height: 22px; margin: 0 0 0; accent-color: var(--accent); }
.check-text { display: flex; flex-direction: column; min-width: 0; }
.check-text b { font-weight: 600; }
.check-hint { color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.check-hint:empty { display: none; }
.share-expiry { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-8) var(--space-16); margin: var(--space-8) 0 var(--space-16); }
.share-expiry .field-label { margin: 0; }
.share-expiry .field-hint { flex-basis: 100%; margin: 0; }
.seg button:disabled { opacity: .5; cursor: not-allowed; }
.share-problem { color: var(--error); font-weight: 600; font-size: 14px; margin: 0 0 var(--space-8); }
.share-problem:empty { display: none; }
.share-dialog .link-row { margin: var(--space-16) 0; }
.share-dialog .sharing-note { margin-bottom: var(--space-4); }

/* ---- waiting and failing ---- */

.sharing-skeleton { display: flex; flex-direction: column; gap: var(--space-16); padding: var(--space-8) 0; }
.sharing-skeleton .bar { display: block; height: 18px; border-radius: 9px; background: var(--track); }
.sharing-skeleton .bar:nth-child(odd) { width: 100%; }
.sharing-skeleton .bar:nth-child(even) { width: 70%; }
.sharing-failure p { margin: 0 0 var(--space-16); color: var(--error); font-weight: 600; }

/* "Collect details by link" (js/ui/collector.js): the four switches as a tight list. */
.collector .sharing-note { margin-top: var(--space-8); }
.collector-opts { display: grid; gap: var(--space-4); margin: var(--space-16) 0 var(--space-8); }
.collector-opts .check-row { margin: 0; min-height: 40px; }

/* The operator's payment test page (js/ui/payment-test.js). */
.paytest { display: grid; gap: var(--space-16); max-width: 640px; }
.paytest-card { position: relative; display: grid; gap: var(--space-8); padding: var(--space-24); border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--card); }
.paytest-card h3, .paytest-cards h3 { font-family: var(--font-display); font-weight: 500; font-size: 22px; margin: 0; }
.paytest-card p { margin: 0; }
.paytest-card .btn { justify-self: start; }
.paytest-badge { position: absolute; top: 14px; right: 14px; font-size: 12px; font-weight: 700; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius-pill); padding: var(--space-4) var(--space-8); }
/* On a phone the badge sits in the flow above the title, so the two never overlap. */
@media (max-width: 640px) { .paytest-badge { position: static; justify-self: start; } }
.paytest-price strong { font-size: 28px; font-family: var(--font-display); font-weight: 500; }
.paytest-price span { color: var(--muted); }
.paytest-result { display: grid; gap: var(--space-4); padding: var(--space-16) var(--space-16); border-radius: var(--radius-card); background: var(--surface); }
.paytest-result.good { background: var(--good-soft); }
.paytest-result.bad { background: var(--surface); border: 1px solid var(--error); }
.paytest-cards { display: grid; gap: var(--space-8); }
.paytest-table { border-collapse: collapse; width: 100%; }
.paytest-table td { padding: var(--space-8) var(--space-8) var(--space-8) 0; border-top: 1px solid var(--border); vertical-align: top; }
.paytest-table code { font-size: 15px; white-space: nowrap; }



/* "See an example of what a supplier sees" (js/ui/share-links-card.js): a plain link with room to tap. */
.sharing-example-link { display: inline-flex; align-items: center; gap: var(--space-8); min-height: 44px; margin-top: var(--space-4); color: var(--accent-dark); font-weight: 700; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.sharing-example-link .material-symbols-rounded { font-size: 18px; text-decoration: none; }
