/**
 * ib-side-panel.css: the ONE right side panel (IB-DESIGN-SPEC, "Desktop Your dosages, both ways + one side panel",
 * operator 22 Nov). Your dosages (public/ib-dosages.js, DosagesDrawer.tsx on desktop) and the plotter Editor share it;
 * only the contents differ.
 *
 *   <div class="ib-side-panel-dim"></div>                       Your dosages only: the standard dim (not when docked)
 *   <div class="ib-side-panel" role="dialog">                    480 over the page (add .ib-side-panel--docked: 400, no dim, page reflows)
 *     <header class="ib-side-panel__head">                       64 tall
 *       <h2 class="ib-side-panel__title">…</h2>                  17/700, left
 *       <div class="ib-side-panel__tools">                       round 40 glass icon buttons, right
 *         <button class="ib-side-panel__icon" aria-label="Close">…</button>
 *     <div class="ib-side-panel__body">                          scrolls
 *       <ul class="ib-side-panel__list">
 *         <li class="ib-side-panel__row">                        Card surface, r16
 *           <span class="ib-side-panel__tile" data-tint="teal|blue|violet|pink">…</span>   36 drug tint
 *           <div class="ib-side-panel__text"><span class="ib-side-panel__name">…</span><span class="ib-side-panel__detail">…</span></div>
 *           <div class="ib-side-panel__actions"><button class="ib-side-panel__act">…</button>…</div>
 *     <footer class="ib-side-panel__band">                       the one main button, full width
 *       <a class="ib-side-panel__main">New protocol</a>          Teal (add --secondary for the plotter's E4 Add dosage)
 *
 * Motion: from the right, 300 ms in, 240 ms out. Close by adding .is-closing (or Radix data-state=closed) to the panel
 * and its dim, then remove them on animationend. Desktop component; the phone keeps its own drawer (spec 3.6).
 * Tokens only (ib-tokens.css).
 */
.ib-side-panel-dim {
  position: fixed; inset: 0; z-index: var(--ib-dash-z-scrim);
  background: var(--ib-dash-dim);
  -webkit-backdrop-filter: var(--ib-dash-dim-blur); backdrop-filter: var(--ib-dash-dim-blur);
  animation: ib-side-panel-fade var(--ib-dash-drawer-in) ease-out both;
}
.ib-side-panel-dim.is-closing, .ib-side-panel-dim[data-state=closed] {
  animation: ib-side-panel-fadeout var(--ib-dash-drawer-out) ease-in both; pointer-events: none;
}

.ib-side-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: var(--ib-dash-z-panel);
  display: flex; flex-direction: column; box-sizing: border-box;
  width: min(var(--ib-side-panel-w), 100%);
  border: 0; border-left: 1px solid var(--ib-side-panel-edge);
  background: none;
  box-shadow: var(--ib-dash-shadow-dialog);
  color: var(--ib-ui-ink); font-family: var(--ib-font-family); font-size: var(--ib-font-size-base); line-height: 1.5;
  outline: none;
  animation: ib-side-panel-in var(--ib-dash-drawer-in) cubic-bezier(.25, 1, .5, 1) backwards;
}
/* The in-animation fills backwards only: a held transform (even identity) would make the panel the containing block
   of position:fixed children. The glass sits on ::before for the same reason: a backdrop-filter on the panel itself would trap position:fixed children (the delete
   confirm) inside it. */
.ib-side-panel::before {
  content: ''; position: absolute; inset: 0; z-index: var(--ib-z-below); pointer-events: none;
  background: var(--ib-ui-paper);
  -webkit-backdrop-filter: var(--ib-dash-glass-blur); backdrop-filter: var(--ib-dash-glass-blur);
}
.ib-side-panel *, .ib-side-panel *::before, .ib-side-panel *::after { box-sizing: border-box; }
.ib-side-panel.is-closing, .ib-side-panel[data-state=closed] {
  animation: ib-side-panel-out var(--ib-dash-drawer-out) cubic-bezier(.4, 0, 1, 1) both;
}
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .ib-side-panel::before { background: var(--ib-dash-glass-solid); }
}

/* Docked (plotter Editor, round 4: moved here from the plotter's index.html): 400 wide, no dim, no shadow, toggled
   with .open (it stays in the page closed). Open, the page gives up the width (body padding, sliding with the panel:
   300 ms in, 240 ms out, same easing as the plotter's main column) and stays live; --ib-side-panel-inset tells the
   desktop vial button (ib-rail.css) where the panel starts. The foot band (.ib-side-panel-foot) holds its main button.
   Two classes deep so a host's own panel rules (the plotter's .cp-erail) don't win on width, edge or motion. */
.ib-side-panel.ib-side-panel--docked {
  width: min(var(--ib-side-panel-docked-w), 100%); border: 0; border-left: 1px solid var(--ib-side-panel-edge);
  box-shadow: none; z-index: var(--ib-shell-z-rail);
  animation: none; transform: translateX(100%); visibility: hidden;
  transition: transform var(--ib-shell-sheet-down) var(--ib-ease-cal-out), visibility 0s linear var(--ib-shell-sheet-down);
}
.ib-side-panel.ib-side-panel--docked.open { transform: none; visibility: visible; transition: transform var(--ib-motion-slow) var(--ib-ease-cal), visibility 0s; }
.ib-side-panel-dim:has(+ .ib-side-panel--docked) { display: none; }
:root:has(.ib-side-panel--docked.open) { --ib-side-panel-inset: var(--ib-side-panel-docked-w); }
:root:has(.ib-side-panel--docked.open) body { padding-right: var(--ib-side-panel-inset); }
.ib-side-panel-foot { flex: none; padding: 12px 20px calc(20px + env(safe-area-inset-bottom, 0px)); }
@media (prefers-reduced-motion: reduce) {
  .ib-side-panel.ib-side-panel--docked, .ib-side-panel.ib-side-panel--docked.open { transition: none; }
}

/* Header: 64, title 17/700 left, round 40 glass icon buttons right. */
.ib-side-panel__head {
  display: flex; flex: none; align-items: center; gap: 12px;
  height: var(--ib-side-panel-head); padding: 0 16px 0 24px;
}
.ib-side-panel__title {
  flex: 1; min-width: 0; margin: 0; padding: 0; border: 0;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: var(--ib-font-size-header); line-height: 24px; font-weight: 700; color: var(--ib-ui-ink); text-align: left;
}
.ib-side-panel__tools { display: flex; flex: none; align-items: center; gap: 8px; }
.ib-side-panel__icon {
  display: grid; flex: none; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--ib-dash-line); border-radius: var(--ib-radius-round);
  background: var(--ib-dash-round-btn); color: var(--ib-ui-ink); font: inherit; cursor: pointer;
}
.ib-side-panel__icon svg { width: 18px; height: 18px; }

/* Body and rows: Card surface r16, 36 drug-tint tile, name 15/600 and detail 13/400 Text 2 on one line each, actions on the row. */
.ib-side-panel__body {
  flex: 1 1 auto; min-height: 0; padding: 4px 24px 16px;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
}
.ib-side-panel__list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.ib-side-panel__row {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 12px 12px 12px 14px;
  border: 1px solid var(--ib-ui-card-surface-line); border-radius: var(--ib-radius-2xl);
  background: var(--ib-ui-card-surface);
}
.ib-side-panel__tile {
  display: grid; flex: none; place-items: center;
  width: var(--ib-side-panel-tile); height: var(--ib-side-panel-tile); border-radius: var(--ib-radius-round);
  background: var(--ib-dash-tile-teal); color: var(--ib-ui-ink);
}
.ib-side-panel__tile[data-tint=blue] { background: var(--ib-dash-tile-blue); }
.ib-side-panel__tile[data-tint=violet] { background: var(--ib-dash-tile-violet); }
.ib-side-panel__tile[data-tint=pink] { background: var(--ib-dash-tile-pink); }
.ib-side-panel__tile svg { width: 16px; height: 16px; }
.ib-side-panel__text { flex: 1 1 auto; min-width: 0; text-align: left; }
.ib-side-panel__name, .ib-side-panel__detail { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ib-side-panel__name { font-size: var(--ib-font-size-lg); line-height: 20px; font-weight: 600; color: var(--ib-ui-ink); }
.ib-side-panel__detail { margin-top: 2px; font-size: var(--ib-font-size-md); line-height: 18px; font-weight: 400; color: var(--ib-ui-ink-2); }
/* Round 4: gaps 10/4 and 10 side padding so a 480 panel row shows "Testosterone Cypionate" in full. */
.ib-side-panel__actions { display: flex; flex: none; align-items: center; gap: 4px; }
.ib-side-panel__act {
  display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 0 10px;
  border: 1px solid var(--ib-dash-line-strong); border-radius: var(--ib-radius-lg);
  background: var(--ib-dash-round-btn); color: var(--ib-ui-ink);
  font: inherit; font-size: var(--ib-font-size-md); font-weight: 600; line-height: 1; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.ib-side-panel__act--danger { padding: 0 6px; border-color: transparent; background: none; color: var(--ib-danger); }
.ib-side-panel__act--danger:hover { background: none; text-decoration: underline; }
.ib-side-panel__act[aria-disabled=true], .ib-side-panel__act:disabled { opacity: .5; cursor: wait; }

/* Bottom band: the one main button, full width (Teal; --secondary = E4). */
.ib-side-panel__band { flex: none; padding: 16px 24px 24px; border-top: 1px solid var(--ib-dash-line); }
.ib-side-panel__main {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; padding: 0 20px;
  border: 1px solid transparent; border-radius: var(--ib-radius-pill);
  background: var(--ib-ui-navy); color: var(--ib-ui-pick-fg);
  font: inherit; font-size: var(--ib-font-size-lg); font-weight: 700; text-decoration: none; cursor: pointer;
}
.ib-side-panel__main--secondary { border-color: var(--ib-dash-line-strong); background: var(--ib-dash-round-btn); color: var(--ib-ui-ink); }

/* The panel itself takes focus on open (spec 1: no ring then); beats the calculator pages' !important ring. */
html body .ib-side-panel[tabindex]:focus, html body .ib-side-panel[tabindex]:focus-visible { outline: none !important; }
.ib-side-panel :focus { outline: none; }
.ib-side-panel :focus-visible { outline: 2px solid var(--ib-ui-focus-on-blue); outline-offset: 2px; }

@keyframes ib-side-panel-in { from { transform: translateX(100%); } to { transform: none; } }
@keyframes ib-side-panel-out { from { transform: none; } to { transform: translateX(100%); } }
@keyframes ib-side-panel-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ib-side-panel-fadeout { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .ib-side-panel, .ib-side-panel-dim { animation: none !important; }
}
