/* ==========================================================================
   ESH Portal prototype - "Manage Portal" admin widget styles
   Reuses tokens from portal.css.
   ========================================================================== */

/* Sidebar entry, sits just above the user menu */
.sb-admin { padding: 6px 8px; border-top: 1px solid var(--border); flex: none; }
.sb-admin:has(> [hidden]) { display: none; }
.sb-admin + .sb-user { border-top: 0; padding-top: 0; }
.app.collapsed .sb-admin .sb-link { justify-content: center; padding: 0; }

.view.wide > * { max-width: 1400px; }

.adm { padding-bottom: 24px; }
.adm-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 12px 0 14px; }
.adm-head p { margin-top: 4px; }
.adm-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.adm-tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.adm-tabs a:hover { color: var(--text); }
.adm-tabs a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.adm-split { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.adm-list { position: sticky; top: 0; }
.adm-editor { min-width: 0; }
.adm-empty { display: grid; place-items: center; gap: 8px; padding: 80px 20px; color: var(--muted); border: 1.5px dashed var(--border); border-radius: var(--radius); }
.adm-empty .i { width: 32px; height: 32px; }

/* ---------- Left list ---------- */
.al-group { margin-bottom: 14px; }
.al-head { display: flex; align-items: center; gap: 8px; padding: 0 4px 6px; font-weight: 600; font-size: 13px; }
.al-head .icon-btn { margin-left: auto; }
.al-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.al-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.al-item:hover { border-color: var(--brand-softer); }
.al-item.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.al-item.off .al-name { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border); }
.al-item.dragging { opacity: .4; }
.al-item.drag-over { border-color: var(--brand); border-style: dashed; }
.al-items { min-height: 40px; border-radius: 10px; }
.al-items.drag-over { outline: 1.5px dashed var(--brand); outline-offset: 2px; background: var(--brand-soft); }
.al-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.al-name { font-weight: 550; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.al-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.al-none { font-size: 12px; color: var(--muted); padding: 6px 8px; }
.al-hint { display: flex; gap: 8px; font-size: 12px; color: var(--muted); line-height: 1.5; padding: 4px; }
.al-hint .i { width: 16px; height: 16px; margin-top: 1px; }
.grip { color: var(--muted); cursor: grab; display: grid; }
.grip .i { width: 14px; height: 14px; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 11.5px; }
.dirty-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); vertical-align: middle; margin-left: 4px; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm .i { width: 15px; height: 15px; }

/* Switch */
.sw { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; flex: none; }
.sw input { position: absolute; opacity: 0; pointer-events: none; }
.sw-track { width: 32px; height: 18px; border-radius: 10px; background: var(--border); position: relative; transition: background .15s; flex: none; }
.sw-thumb { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.sw input:checked + .sw-track { background: var(--brand); }
.sw input:checked + .sw-track .sw-thumb { transform: translateX(14px); }
.sw input:focus-visible + .sw-track { box-shadow: 0 0 0 3px var(--brand-softer); }
.sw-lbl { font-size: 13px; color: var(--text-2); }

/* ---------- Editor ---------- */
.ed-bar { position: sticky; top: -8px; z-index: 5; display: flex; align-items: center; gap: 14px; padding: 10px 14px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.ed-title { flex: 1; min-width: 0; font-size: 18px; font-weight: 650; border: 1px solid transparent; border-radius: 8px; padding: 4px 8px; background: transparent; outline: none; color: var(--text); }
.ed-title:hover { border-color: var(--border); }
.ed-title:focus { border-color: var(--brand); background: var(--bg); }
.ed-list { font-size: 12px; font-weight: 600; color: var(--brand); background: var(--brand-soft); padding: 3px 10px; border-radius: 12px; white-space: nowrap; }
.ed-actions { display: flex; align-items: center; gap: 6px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary:disabled:hover { background: var(--brand); }

.ed-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.ed-preview { position: sticky; top: 64px; }

.adm-step { padding: 16px 18px; }
.step-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.step-head p { margin-top: 2px; }
.step-n { width: 24px; height: 24px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 12px; display: grid; place-items: center; flex: none; }

.fld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.fld > span { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.fld i { font-style: normal; }
.fld input, .fld select, .qb select, .qb input, .qb textarea, .pv-head select, .pv-bar select {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; background: var(--surface); outline: none; min-width: 0; color: var(--text);
}
.fld input:focus, .fld select:focus, .qb select:focus, .qb input:focus, .qb textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.fld .seg { align-self: flex-start; margin-bottom: 0; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 12px; }

/* ---------- Condition builder ---------- */
.qb { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.qb-group { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.qb-row { display: grid; grid-template-columns: 54px minmax(120px, 1fr) minmax(130px, 1fr) minmax(130px, 1.1fr) 28px; gap: 6px; align-items: center; }
.qb-row select, .qb-row input { width: 100%; }
.qb-join { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; text-align: center; padding: 4px 0; border-radius: 6px; }
.qb-join.first { color: var(--muted); }
.qb-join.and { background: var(--neutral-bg); color: var(--text-2); }
.qb-join.or { background: var(--warn-bg); color: var(--warn); }
button.qb-join:hover { outline: 1px solid var(--brand); }
.qb-val { min-width: 0; }
.qb-multi { display: flex; flex-wrap: wrap; gap: 4px; }
.qb-chk { font-size: 12px; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 2px 9px; cursor: pointer; }
.qb-chk input { display: none; }
.qb-chk.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.qb-add { display: flex; gap: 4px; padding-left: 60px; }
.qb-or-sep { width: 100%; display: flex; align-items: center; gap: 8px; color: var(--warn); font-size: 11px; font-weight: 700; }
.qb-or-sep::before, .qb-or-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-txt { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 550; color: var(--brand); padding: 4px 8px; border-radius: 6px; }
.btn-txt:hover { background: var(--brand-soft); }
.btn-txt .i { width: 14px; height: 14px; }
.btn-txt.muted { color: var(--text-2); }
.qb-adv { width: 100%; font-size: 12.5px; }
.qb-adv summary { cursor: pointer; color: var(--muted); padding: 2px 0; }
.qb-adv textarea { width: 100%; margin: 6px 0 2px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; resize: vertical; }

.sum { display: flex; gap: 10px; margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--brand-soft); line-height: 1.6; }
.sum > .i { color: var(--brand); margin-top: 2px; }
.sum b { font-weight: 600; }
.sum i { font-style: normal; color: var(--text); background: var(--surface); padding: 0 5px; border-radius: 4px; }
.sum .me { background: var(--brand); color: #fff; padding: 0 6px; border-radius: 4px; font-weight: 600; font-size: 12px; }
.sum .kw { color: var(--muted); font-size: 12px; text-transform: uppercase; font-weight: 600; }
.kw-or { color: var(--warn); font-size: 11px; font-weight: 700; margin: 2px 0; }
.warn-box { display: flex; gap: 10px; margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--text); font-size: 13px; }
.warn-box .i { color: var(--warn); margin-top: 1px; }

.radio-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-bottom: 12px; }
.rc { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.rc input { display: none; }
.rc:hover { border-color: var(--brand-softer); }
.rc.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand); }

/* ---------- Preview rail ---------- */
.pv-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.pv-head select { max-width: 170px; }
.pv-stats { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.pv-stats b { color: var(--brand); font-size: 15px; }
.pv-list { display: flex; flex-direction: column; }
.pv-row { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.pv-row:last-child { border-bottom: 0; }
.pv-row .row-icon { width: 30px; height: 30px; }
.pv-row .row-icon .i { width: 16px; height: 16px; }
.tag { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.tag.open { color: var(--brand); }
.pv-note { margin-top: 8px; }
.enc h2 { margin-bottom: 8px; }
.enc dl { margin: 0; display: grid; gap: 4px; }
.enc dt { font-size: 12px; color: var(--muted); }
.enc dd { margin: 0 0 6px; word-break: break-all; background: var(--bg); padding: 6px 8px; border-radius: 6px; }

/* ---------- Layout designer ---------- */
.designer { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 14px; }
.palette-col { display: flex; flex-direction: column; gap: 8px; }
.palette-col .filter-box { margin: 0; min-width: 0; }
.pal-list { display: flex; flex-direction: column; gap: 4px; max-height: 420px; overflow-y: auto; padding: 4px; border-radius: 10px; border: 1px dashed transparent; }
.pal-list.drag-over { border-color: var(--danger); background: var(--danger-bg); }
.pal-item { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: grab; font-size: 13px; }
.pal-item:hover { border-color: var(--brand); }
.pal-item > span:nth-child(2) { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-type { font-size: 10.5px; color: var(--muted); text-transform: uppercase; }

.canvas { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.canvas-card { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.cc-left { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cc-progress { display: flex; align-items: center; gap: 0; padding: 4px 6px; position: relative; }
.cc-progress span { flex: 1; height: 2px; background: var(--brand-softer); position: relative; }
.cc-progress span::before { content: ""; position: absolute; left: 0; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-softer); }
.cc-progress em { font-style: normal; font-size: 11px; color: var(--muted); margin-left: 10px; }

.lz { border: 1.5px dashed var(--border); border-radius: 10px; padding: 8px; background: var(--surface); transition: border-color .1s, background .1s; }
.lz.drag-over { border-color: var(--brand); background: var(--brand-soft); }
.lz-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 6px; font-size: 12.5px; flex-wrap: wrap; }
.lz-head .small { font-size: 11px; }
.lz-n { width: 18px; height: 18px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 700; display: inline-grid; place-items: center; align-self: center; }
.lz-body { display: flex; flex-direction: column; gap: 4px; min-height: 34px; }
.z-details .lz-body { flex-direction: row; flex-wrap: wrap; }
.lz-empty { font-size: 12px; color: var(--muted); padding: 8px; }
.lf-chip { display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: grab; font-size: 13px; box-shadow: var(--shadow); }
.lf-chip:hover { border-color: var(--brand-softer); }
.lf-chip.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.lf-chip.dragging { opacity: .4; }
.lf-name { min-width: 0; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lf-as { font-size: 10.5px; color: var(--brand); background: var(--brand-soft); padding: 1px 6px; border-radius: 8px; white-space: nowrap; margin-left: auto; }
.lf-x { width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; color: var(--muted); flex: none; }
.lf-x .i { width: 13px; height: 13px; }
.lf-x:hover { background: var(--danger-bg); color: var(--danger); }
.lf-x.add:hover { background: var(--brand-soft); color: var(--brand); }

.inspector { border: 1px solid var(--brand); border-radius: var(--radius); padding: 12px 14px 2px; background: var(--surface); box-shadow: 0 0 0 3px var(--brand-soft); }
.insp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.insp-head .icon-btn { margin-left: auto; }

.pv-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.pv-ticket { margin: 0; background: var(--surface); }
.person-inline { display: inline-flex; align-items: center; gap: 10px; }
.person-inline > span:last-child { display: flex; flex-direction: column; }

.opts { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.opts .fgrid { width: 100%; padding-left: 40px; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .ed-grid { grid-template-columns: 1fr; }
  .ed-preview { position: static; }
}
@media (max-width: 980px) {
  .adm-split { grid-template-columns: 1fr; }
  .adm-list { position: static; }
  .designer { grid-template-columns: 1fr; }
  .canvas-card { grid-template-columns: 1fr; }
  .qb-row { grid-template-columns: 44px 1fr 1fr; }
  .qb-row .qb-val { grid-column: 2 / 4; }
  .qb-add { padding-left: 0; }
}
