/* ParkOps console — shared UI components (v0.15.0): page header + sub-tabs,
   list toolbar, data tables, slide-out drawer, confirmation dialog, toasts.
   Uses the console tokens (styles.css :root) and the navigation accent (nav.css). */

:root {
  --ui-radius: 12px;
  --ui-gap: 1rem;
  --ui-ease: cubic-bezier(.2, .7, .2, 1);
  --drw-z: 90;
  --ui-ink: #1E2433;                 /* 15.5:1 on white */
  --ui-mut: #4A5468;                 /*  7.9:1 on white (AAA) */
}

/* ------------------------------------------------------------------ page header + sub-tabs */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: .4rem 1rem; margin: .2rem 0 1rem; }
.page-head h1 { font-size: 1.35rem; color: var(--deep); line-height: 1.2; }
.page-head .page-crumb { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ui-mut);
  font-weight: 700; margin-bottom: .15rem; }
.subtabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); width: 100%;
  margin-top: .5rem; }
.subtabs a { display: inline-flex; align-items: center; gap: .45rem; padding: .55rem .9rem; border-radius: 8px 8px 0 0;
  color: var(--ui-mut); text-decoration: none; font-size: .9rem; font-weight: 600; border-bottom: 3px solid transparent;
  margin-bottom: -1px; transition: color .15s, background .15s, border-color .15s; }
.subtabs a:hover { color: var(--deep); background: #EEF2F8; }
.subtabs a[aria-current="page"] { color: var(--deep); border-bottom-color: var(--amber); }
.subtabs a:focus-visible { outline: 3px solid var(--amber); outline-offset: 1px; }
[data-page][hidden] { display: none !important; }

/* ------------------------------------------------------------------ list pages */
.list-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .5rem 1rem;
  margin-bottom: .4rem; }
.list-head h2 { margin-bottom: .15rem; }
.list-head .hint { margin-bottom: 0; max-width: 72ch; }
.list-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn .ico { vertical-align: -3px; }
.btn.with-ico { display: inline-flex; align-items: center; gap: .4rem; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { margin-left: .25rem; }

/* data tables */
.dt-bar { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: .4rem 0 .5rem; }
.dt-search { position: relative; flex-direction: row; align-items: center; color: var(--ui-mut); }
.dt-search .ico { position: absolute; left: .6rem; pointer-events: none; }
.dt-search input { padding-left: 2rem; min-width: 260px; }
.dt-count { font-size: .78rem; color: var(--ui-mut); }
table.dt th.dt-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.dt th.dt-sortable::after { content: "↕"; opacity: .35; margin-left: .3rem; font-size: .8em; }
table.dt th[aria-sort="ascending"]::after { content: "↑"; opacity: .9; }
table.dt th[aria-sort="descending"]::after { content: "↓"; opacity: .9; }
table.dt th.dt-sortable:focus-visible { outline: 3px solid var(--amber); outline-offset: -3px; }
table.dt tbody tr, table.dt tr { transition: background .12s; }
table.dt tr.click:hover, table.dt tr[data-enreq]:hover { background: #F3F6FB; }
.dt-pager { display: flex; align-items: center; justify-content: flex-end; gap: .3rem; margin-top: .6rem; flex-wrap: wrap; }
.dt-pager .btn { min-width: 2.1rem; display: inline-flex; align-items: center; justify-content: center; }
.dt-range { font-size: .78rem; color: var(--ui-mut); margin-right: .5rem; }
.dt-gap { color: var(--ui-mut); padding: 0 .2rem; }

/* ------------------------------------------------------------------ drawer */
html.drw-locked, html.drw-locked body { overflow: hidden; }
.drw-root { position: fixed; inset: 0; z-index: var(--drw-z); pointer-events: none; }
.drw-scrim { position: absolute; inset: 0; background: rgba(15, 20, 48, .2);   /* the list stays readable */
  opacity: 0; transition: opacity .22s var(--ui-ease); pointer-events: auto; }
.drw { position: absolute; top: 0; right: 0; bottom: 0; width: min(var(--drw-w, 520px), 100vw);
  display: flex; flex-direction: column; background: #fff; color: var(--ui-ink); pointer-events: auto;
  box-shadow: -24px 0 60px rgba(15, 20, 48, .22), -1px 0 0 rgba(15, 20, 48, .08);
  transform: translateX(104%); transition: transform .24s var(--ui-ease); }
.drw-root.open .drw-scrim { opacity: 1; }
.drw-root.open .drw { transform: none; }
.drw-root.closing .drw-scrim { opacity: 0; }
.drw-root.closing .drw { transform: translateX(104%); }

.drw-head { display: flex; align-items: flex-start; gap: .8rem; padding: 1.05rem 1.25rem .9rem;
  border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #FBFCFE, #fff); }
.drw-titles { flex: 1; min-width: 0; }
.drw-mode { display: block; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ui-mut); }
.drw-head h2 { font-size: 1.15rem; margin: .1rem 0 0; color: var(--deep); overflow-wrap: anywhere; }
.drw-sub { font-size: .82rem; color: var(--ui-mut); margin-top: .15rem; }
.drw-sub[hidden] { display: none; }
.drw-x { flex: 0 0 auto; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--ui-ink); cursor: pointer;
  transition: background .15s, border-color .15s; }
.drw-x:hover { background: #F1F4F9; border-color: var(--line); }
.drw-x:focus-visible, .drw :focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

.drw-progress { height: 3px; background: transparent; overflow: hidden; }
.drw.is-busy .drw-progress { background: linear-gradient(90deg, transparent, var(--teal), transparent);
  background-size: 40% 100%; background-repeat: no-repeat; animation: drw-load 1s linear infinite; }
@keyframes drw-load { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.drw-err:empty { display: none; }
.drw-err { display: flex; gap: .5rem; align-items: flex-start; margin: .8rem 1.25rem 0; padding: .65rem .8rem;
  border-radius: 9px; background: #FCEDEB; border: 1px solid #E8B4AD; color: #7A1F15; font-size: .86rem; }
.drw-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 1rem 1.25rem 1.4rem; }
.drw-body:focus { outline: none; }
.drw-body .formrow { flex-wrap: wrap; }
.drw-body .formrow label { flex: 1 1 180px; }
.drw-body .formrow .chips { flex: 1 1 100%; }
.drw-body .chips label { flex: 0 0 auto; flex-direction: row; align-items: center; gap: .35rem; }
.drw-body label:has(> input[type=checkbox]) { flex-direction: row; align-items: center; gap: .45rem; color: var(--ui-ink); }
.drw-body .formrow input:not([type=checkbox]):not([type=radio]), .drw-body .formrow select { min-width: 0; width: 100%; }
.drw-body h3 { margin-top: 1.1rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.drw-body h3:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.drw-body .card { box-shadow: none; border: 0; padding: 0; margin: 0; }
.drw-body .card > h2:first-child { display: none; }       /* the drawer header carries the title */
.drw-section { border: 1px solid var(--line); border-radius: 10px; padding: .8rem .9rem; margin-bottom: .9rem; }
.drw-section > legend, .drw-legend { font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ui-mut); padding: 0 .3rem; }
.drw-foot { display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .8rem 1.25rem; border-top: 1px solid var(--line); background: #FBFCFE; }
.drw-foot-btns { display: flex; gap: .55rem; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.drw-foot .btn { display: inline-flex; align-items: center; gap: .4rem; }
.drw-primary { min-width: 6.5rem; justify-content: center; }
.drw.is-busy .drw-primary span::after { content: "…"; }
.drw[data-mode="view"] .drw-mode { color: var(--teal); }
@media (max-width: 640px) {
  .drw { width: 100vw; }
  .drw-head, .drw-body, .drw-foot { padding-left: 1rem; padding-right: 1rem; }
  .drw-foot-btns .btn { flex: 1; justify-content: center; }
}

/* ------------------------------------------------------------------ confirmation dialog */
.cdlg-wrap { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem;
  background: rgba(15, 20, 48, .42); animation: ui-fade .15s ease-out; }
.cdlg { display: flex; gap: .9rem; width: min(460px, 100%); background: #fff; color: var(--ui-ink);
  border-radius: 14px; padding: 1.2rem 1.25rem; box-shadow: 0 24px 70px rgba(15, 20, 48, .35);
  animation: ui-pop .18s var(--ui-ease); }
.cdlg-ico { flex: 0 0 auto; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: #E6F0F6; color: var(--blue); }
.cdlg-ico.danger { background: #FCEDEB; color: #A3261A; }
.cdlg-main { flex: 1; min-width: 0; }
.cdlg h2 { font-size: 1.05rem; margin: .15rem 0 .35rem; }
.cdlg p { font-size: .9rem; color: var(--ui-mut); }
.cdlg-reason { margin-top: .7rem; color: var(--ui-ink); font-size: .82rem; }
.cdlg-reason textarea { width: 100%; font: inherit; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 8px; }
.cdlg-err { color: #A3261A; font-size: .8rem; min-height: 1em; margin-top: .25rem; }
.cdlg-actions { display: flex; justify-content: flex-end; gap: .55rem; margin-top: 1rem; }
.cdlg :focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
@keyframes ui-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ui-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ toasts */
.toast-stack { position: fixed; top: 1rem; right: 1rem; z-index: 110; display: flex; flex-direction: column; gap: .5rem;
  width: min(380px, calc(100vw - 2rem)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: .6rem; padding: .75rem .8rem;
  background: #fff; color: var(--ui-ink); border-radius: 11px; border: 1px solid var(--line); border-left: 4px solid var(--green);
  box-shadow: 0 12px 34px rgba(15, 20, 48, .18); font-size: .88rem; animation: toast-in .22s var(--ui-ease); }
.toast .ico { flex: 0 0 auto; margin-top: .05rem; color: var(--green); }
.toast-bad { border-left-color: var(--red); } .toast-bad .ico { color: var(--red); }
.toast-warn { border-left-color: var(--amber); } .toast-warn .ico { color: #8A5A00; }
.toast-msg { flex: 1; }
.toast-act { border: 0; background: transparent; color: var(--blue); font: inherit; font-weight: 700; cursor: pointer; padding: 0 .2rem; }
.toast-x { border: 0; background: transparent; color: var(--ui-mut); cursor: pointer; padding: 0; display: inline-grid; }
.toast.out { opacity: 0; transform: translateX(12px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* sources of drawer content live hidden in the page until opened */
.drawer-src[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .drw, .drw-scrim, .cdlg, .cdlg-wrap, .toast, .subtabs a { transition: none !important; animation: none !important; }
}
@media print { .drw-root, .toast-stack, .cdlg-wrap { display: none !important; } }

/* misc layout helpers */
.narrow-wide { max-width: 980px; }
label.inline-check { flex-direction: row; align-items: center; gap: .45rem; color: var(--ui-ink); }
.view > .card + .card { margin-top: 0; }

/* Required marker (fieldcfg .fc-req) sits beside the label text, not on its own row */
.fc-req { color: #B42318; font-weight: 700; margin-left: .15rem; }
label:has(> .fc-req):not(:has(> input[type=checkbox])) { flex-direction: row; flex-wrap: wrap; align-items: baseline; column-gap: 0; }
label:has(> .fc-req):not(:has(> input[type=checkbox])) > :is(input, select, textarea) { flex-basis: 100%; }
.drw-body input[readonly] { background: #F1F4F8; color: var(--ui-ink); cursor: default; }
/* keep visually-hidden header text inside the table's scroll box (no page-level horizontal scroll) */
table.dt { position: relative; }

/* v0.15.0 rate plan editor: price steps, "then … per …", example prices */
#rp-tiers { display: grid; gap: .5rem; margin: .5rem 0; }
.rp-tier { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.rp-tier label { flex-direction: row; align-items: center; gap: .4rem; color: var(--ui-ink); font-size: .85rem; }
.rp-tier .rp-t-len { width: 5.5em; }
.rp-tier .rp-t-price { width: 7em; }
.rp-tier .rp-t-del { margin-left: auto; }
.rp-then { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .75rem; font-size: .85rem; color: var(--ui-ink); }
.rp-then label { flex-direction: row; }
.rp-then-lbl { font-weight: 600; }
table.rp-prev { width: auto; min-width: 16rem; }
table.rp-prev td, table.rp-prev th { padding: .3rem .9rem .3rem 0; }
@media (max-width: 640px) { .rp-tier .rp-t-del { margin-left: 0; } }
.rp-tier input, .rp-tier select, .rp-then input, .rp-then select { flex: none; min-width: 0; }
.rp-tier .rp-t-len, .rp-then #rp-inc-len { width: 5.5em; }
.rp-tier select, .rp-then select { width: 5em; }
.rp-tier .rp-t-price, .rp-then #rp-inc-price { width: 7em; }
