/* Simply Chatbot V2 prototype — shared components. Tokens come from v2-shell.css. */

/* ---------- Status badges: Ready is calm (static dot); Live breathes (soft 2s ring) ---------- */
.badge{position:relative}
.badge .sdot{position:relative;width:6px;height:6px;border-radius:50%;background:currentColor;flex:none}
.st-ready,.st-success{background:var(--v2-status-success-subtle);color:var(--v2-status-success-text)}
.st-live{background:var(--v2-status-success-subtle);color:var(--v2-status-success-text)}
.st-live .sdot::after,.pill.live .pdot::after{content:"";position:absolute;inset:0;border-radius:50%;background:currentColor;animation:live-ring 2s var(--v2-motion-easing-standard) infinite}
@keyframes live-ring{0%{transform:scale(1);opacity:.55}70%,100%{transform:scale(2.6);opacity:0}}
.st-warning{background:var(--v2-status-warning-subtle);color:var(--v2-status-warning-text)}
.st-danger{background:var(--v2-status-danger-subtle);color:var(--v2-status-danger-text)}
.st-attention{background:var(--v2-status-attention-subtle);color:var(--v2-status-attention-text)}
.st-info{background:var(--v2-surface-selected);color:var(--v2-text-link)}
.st-info .sdot{animation:soft-blink 1.6s ease-in-out infinite}
@keyframes soft-blink{0%,100%{opacity:1}50%{opacity:.35}}
.st-neutral{background:var(--v2-status-neutral-subtle);color:var(--v2-status-neutral-text)}
.st-paused{background:var(--v2-status-neutral-subtle);color:var(--v2-status-neutral-text)}
.st-draft{background:var(--v2-status-warning-subtle);color:var(--v2-status-warning-text)}
/* status changes cross-fade instead of snapping */
.badge,.pill{transition:background-color var(--v2-motion-duration-base) var(--v2-motion-easing-standard),color var(--v2-motion-duration-base) var(--v2-motion-easing-standard)}
@media (prefers-reduced-motion:reduce){.st-live .sdot::after,.pill.live .pdot::after,.st-info .sdot{animation:none;display:none}}

/* ---------- Avatars ---------- */
.av{--av-bg:var(--v2-status-neutral-subtle);--av-fg:var(--v2-status-neutral-text);position:relative;display:inline-grid;place-items:center;flex:none;border-radius:50%;background:var(--av-bg);color:var(--av-fg);font-weight:600;overflow:hidden;line-height:1;user-select:none}
.av img{width:100%;height:100%;object-fit:cover;position:absolute;inset:0}
.av .av-ini{letter-spacing:.2px}
/* Sizes match the Figma V2/Avatar component: XS 20, S 24, M 32, L 40, XL 64 */
.av-xs{width:20px;height:20px;font-size:9px}.av-sm{width:24px;height:24px;font-size:10px}.av-md{width:32px;height:32px;font-size:12px}.av-lg{width:40px;height:40px;font-size:14px}.av-xl{width:64px;height:64px;font-size:22px}
.av-emoji{background:var(--v2-surface-subtle);box-shadow:inset 0 0 0 1px var(--v2-border-subtle)}
.av-emoji.av-xs{font-size:12px}.av-emoji.av-sm{font-size:15px}.av-emoji.av-md{font-size:18px}.av-emoji.av-lg{font-size:22px}.av-emoji.av-xl{font-size:36px}
.acc-av{display:inline-flex}
.tone-picker{border:0;padding:0;margin:0}
.tone-picker legend{font-weight:500;margin-bottom:6px;padding:0}
.tones{display:flex;flex-wrap:wrap;gap:6px}
.tone{position:relative}
.tone input{position:absolute;opacity:0;inset:0;margin:0;cursor:pointer}
.tone-chip{display:grid;place-items:center;width:40px;height:40px;border-radius:10px;border:1px solid var(--v2-border-subtle);background:#fff;font-size:22px;transition:border-color var(--v2-motion-duration-fast) var(--v2-motion-easing-standard),box-shadow var(--v2-motion-duration-fast) var(--v2-motion-easing-standard)}
.tone input:checked + .tone-chip{border-color:var(--v2-border-focus);box-shadow:0 0 0 1px var(--v2-border-focus) inset;background:var(--v2-surface-selected)}
.tone input:focus-visible + .tone-chip{outline:2px solid var(--v2-border-focus);outline-offset:2px}

/* ---------- Brand logo tiles (Simple Icons). Standard sizes, centred glyph at 60% ---------- */
.logo-tile{--brand:#434954;display:inline-grid;place-items:center;flex:none;border-radius:8px;background:#fff;border:1px solid var(--v2-border-subtle);color:var(--brand)}
.logo-tile svg{width:60%;height:60%;fill:currentColor;stroke:none}
.lt-filled{background:var(--brand);border-color:transparent;color:#fff}
.lt-mono{background:var(--v2-surface-subtle);color:var(--v2-text-secondary);font-weight:600}
.lt-sm{width:28px;height:28px;border-radius:6px;font-size:11px}.lt-md{width:40px;height:40px;font-size:14px}.lt-lg{width:48px;height:48px;border-radius:10px;font-size:16px}

/* ---------- Toolbar, search, filters, chips ---------- */
.toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.toolbar .grow{flex:1}
.search-field{position:relative;display:flex;align-items:center;flex:1 1 240px;max-width:340px;min-width:0}
.search-field svg{position:absolute;left:12px;color:var(--v2-icon-default);pointer-events:none}
.search-field input{width:100%;height:40px;border:1px solid var(--v2-border-default);border-radius:8px;padding:0 12px 0 36px;font:inherit;color:var(--v2-text-primary);background:#fff;transition:border-color var(--v2-motion-duration-fast) var(--v2-motion-easing-standard)}
.search-field input::placeholder{color:var(--v2-text-tertiary)}
.filter-wrap{position:relative}
.filter-btn,.select-field{display:inline-flex;align-items:center;gap:6px;min-height:36px;padding:0 10px 0 12px;border:1px solid var(--v2-border-default);border-radius:8px;background:#fff;color:var(--v2-text-primary);font:500 14px/20px var(--v2-font);cursor:pointer;white-space:nowrap;transition:background-color var(--v2-motion-duration-fast) var(--v2-motion-easing-standard),border-color var(--v2-motion-duration-fast) var(--v2-motion-easing-standard)}
.filter-btn:hover,.select-field:hover{background:var(--v2-surface-subtle)}
.filter-btn.active{background:var(--v2-surface-selected);border-color:var(--v2-border-focus);color:#24389E}
.fcount{display:inline-grid;place-items:center;min-width:18px;height:18px;padding:0 5px;border-radius:999px;background:var(--v2-action-primary);color:#fff;font-size:11px;line-height:1}
.filter-btn svg,.select-field svg{width:14px;height:14px}
.filter-btn[aria-expanded="true"] svg{transform:rotate(180deg)}
.filter-btn svg{transition:transform var(--v2-motion-duration-fast) var(--v2-motion-easing-standard)}
.select-field{position:relative;padding:0}
.select-field .sel-label{padding-left:12px;color:var(--v2-text-secondary);font-weight:400}
.select-field select{appearance:none;border:0;background:transparent;font:500 14px/20px var(--v2-font);color:var(--v2-text-primary);padding:7px 30px 7px 8px;cursor:pointer;min-height:34px;border-radius:8px}
.select-field select:focus-visible{outline:2px solid var(--v2-border-focus);outline-offset:2px}
.select-field svg{position:absolute;right:10px;pointer-events:none}
.popover{position:absolute;top:calc(100% + 4px);left:0;z-index:40;min-width:220px;max-height:min(360px,60dvh);overflow:auto;padding:6px;border:1px solid var(--v2-border-subtle);border-radius:10px;background:#fff;box-shadow:var(--v2-elev-3);
  opacity:0;visibility:hidden;transform:translateY(-4px) scale(.98);transform-origin:top left;transition:opacity var(--v2-motion-duration-instant) var(--v2-motion-easing-exit),transform var(--v2-motion-duration-instant) var(--v2-motion-easing-exit),visibility 0s linear var(--v2-motion-duration-instant)}
.popover.flip{left:auto;right:0;transform-origin:top right}
.popover.open{opacity:1;visibility:visible;transform:none;transition:opacity var(--v2-motion-duration-fast) var(--v2-motion-easing-enter),transform var(--v2-motion-duration-fast) var(--v2-motion-easing-enter),visibility 0s}
.pop-opt{display:flex;align-items:center;gap:10px;min-height:36px;padding:0 8px;border-radius:6px;cursor:pointer}
.pop-opt:hover{background:var(--v2-surface-hover)}
.pop-opt input{width:16px;height:16px;accent-color:var(--v2-action-primary);margin:0}
.pop-opt span:first-of-type{flex:1}
.pop-count{color:var(--v2-text-secondary);font-size:12px;font-variant-numeric:tabular-nums}
.pop-foot{display:flex;justify-content:flex-end;border-top:1px solid var(--v2-border-subtle);margin-top:4px;padding-top:2px}
.chips{display:flex;flex-wrap:wrap;gap:6px;align-items:center;min-height:28px}
.chips-count{color:var(--v2-text-secondary);font-size:13px;margin-right:4px}
.chip{display:inline-flex;align-items:center;gap:4px;min-height:28px;padding:0 6px 0 10px;border-radius:999px;border:1px solid var(--v2-border-focus);background:var(--v2-surface-selected);color:#24389E;font:500 13px/18px var(--v2-font);cursor:pointer;animation:fade-in var(--v2-motion-duration-fast) var(--v2-motion-easing-enter) both}
.chip svg{width:14px;height:14px}
.chip:hover{background:#E0E7FF}
.segmented{display:inline-flex;gap:2px;padding:2px;background:var(--v2-surface-subtle);border:1px solid var(--v2-border-subtle);border-radius:8px;flex-wrap:wrap}
.seg{display:inline-flex;align-items:center;gap:6px;min-height:32px;padding:0 12px;border:0;border-radius:6px;background:none;color:var(--v2-text-secondary);font:500 13px/18px var(--v2-font);cursor:pointer;transition:background-color var(--v2-motion-duration-fast) var(--v2-motion-easing-standard),color var(--v2-motion-duration-fast) var(--v2-motion-easing-standard),box-shadow var(--v2-motion-duration-fast) var(--v2-motion-easing-standard)}
.seg:hover{color:var(--v2-text-primary)}
.seg.on{background:#fff;color:var(--v2-text-primary);box-shadow:0 0 0 1px var(--v2-border-default)}
.seg-count{font-variant-numeric:tabular-nums;color:var(--v2-text-secondary)}

/* ---------- Tables ---------- */
.table-wrap{border:1px solid var(--v2-border-subtle);border-radius:12px;overflow:auto;max-width:100%}
table.data{width:100%;border-collapse:collapse;font-size:14px}
table.data th{position:sticky;top:0;z-index:1;background:var(--v2-surface-subtle);text-align:left;font-weight:500;font-size:13px;color:var(--v2-text-secondary);padding:0 12px;height:40px;border-bottom:1px solid var(--v2-border-subtle);white-space:nowrap}
table.data td{padding:10px 12px;border-bottom:1px solid var(--v2-border-subtle);vertical-align:middle}
table.data tr:last-child td{border-bottom:0}
table.data tbody tr{transition:background-color var(--v2-motion-duration-fast) var(--v2-motion-easing-standard)}
table.data tbody tr:hover{background:var(--v2-surface-subtle)}
table.data tbody tr[aria-selected="true"]{background:var(--v2-surface-selected)}
.th-sort{display:inline-flex;align-items:center;gap:4px;border:0;background:none;font:inherit;color:inherit;cursor:pointer;padding:6px 0;min-height:32px}
.th-sort .sort-ic{width:14px;height:14px;opacity:.6}
.th-sort .sort-ic.asc{transform:rotate(180deg);opacity:1}.th-sort .sort-ic.desc{opacity:1}
.cell-main{font-weight:500;color:var(--v2-text-primary)} .cell-sub{color:var(--v2-text-secondary);font-size:13px;line-height:18px}
.row-link{color:inherit;text-decoration:none} .row-link:hover{text-decoration:underline}
@media (max-width:767px){ table.data.stack thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)} table.data.stack tr{display:grid;gap:4px;padding:12px;border-bottom:1px solid var(--v2-border-subtle)} table.data.stack td{border:0;padding:0} table.data.stack td[data-label]::before{content:attr(data-label) ": ";color:var(--v2-text-secondary);font-size:12px} }

/* ---------- Pagination ---------- */
.pager{display:flex;align-items:center;gap:8px;justify-content:flex-end;padding:8px 0;flex-wrap:wrap}
.pager-info{color:var(--v2-text-secondary);font-size:13px;margin-right:auto}
.pager-page{font-size:13px;color:var(--v2-text-secondary)}
.icon-btn:disabled{opacity:.45;cursor:not-allowed}

/* ---------- Empty state ---------- */
.empty{display:grid;justify-items:center;text-align:center;gap:6px;padding:40px 16px;border:1px dashed var(--v2-border-subtle);border-radius:12px;animation:fade-in var(--v2-motion-duration-base) var(--v2-motion-easing-enter) both}
.empty-ic{display:grid;place-items:center;width:40px;height:40px;border-radius:50%;background:var(--v2-surface-subtle);color:var(--v2-icon-default)}
.empty h3,.empty .empty-title{margin:4px 0 0;font-size:16px;line-height:24px}
.empty p{margin:0;color:var(--v2-text-secondary);max-width:420px}
@keyframes fade-in{from{opacity:0}to{opacity:1}}

/* ---------- Cards, panels, forms ---------- */
.card{border:1px solid var(--v2-border-subtle);border-radius:12px;background:#fff;padding:20px;min-width:0}
.card h2{font-size:16px;line-height:24px;margin:0}
.card > p.sub{margin:2px 0 0;color:var(--v2-text-secondary);font-size:13px;line-height:20px}
.grid-2{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,340px),1fr));gap:16px}
.grid-3{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,260px),1fr));gap:16px}
.stack{display:flex;flex-direction:column;gap:16px}
.form-row{display:flex;flex-direction:column;gap:6px}
.form-row label,.form-label{font-weight:500}
.form-row .help{font-size:13px;line-height:20px;color:var(--v2-text-secondary)}
.input,.textarea,.form-row input:not([type=checkbox]):not([type=radio]),.form-row textarea,.form-row select{width:100%;border:1px solid var(--v2-border-default);border-radius:8px;padding:8px 12px;font:inherit;color:var(--v2-text-primary);background:#fff;min-height:40px;transition:border-color var(--v2-motion-duration-fast) var(--v2-motion-easing-standard)}
.form-row textarea,.textarea{min-height:96px;resize:vertical}
[aria-invalid="true"]{border-color:var(--v2-status-danger)!important}
.err{color:var(--v2-status-danger-text);font-size:13px;line-height:20px;animation:fade-in var(--v2-motion-duration-base) var(--v2-motion-easing-enter) both}
.switch{position:relative;width:40px;height:24px;flex:none;border-radius:12px;border:0;background:var(--v2-border-default);cursor:pointer;transition:background-color var(--v2-motion-duration-fast) var(--v2-motion-easing-standard)}
.switch .knob{position:absolute;top:2px;left:2px;width:20px;height:20px;border-radius:50%;background:#fff;transition:transform var(--v2-motion-duration-fast) var(--v2-motion-easing-standard)}
.switch[aria-checked="true"]{background:var(--v2-action-primary)}
.switch[aria-checked="true"] .knob{transform:translateX(16px)}
.setting{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:14px 0;border-bottom:1px solid var(--v2-border-subtle)}
.setting:last-child{border-bottom:0}
.setting p{margin:2px 0 0;color:var(--v2-text-secondary);font-size:13px;line-height:20px}
.btn.danger{background:var(--v2-action-danger);border-color:var(--v2-action-danger);color:#fff}
.btn.danger:hover{background:#912018}
.sim-tag{display:inline-block;margin-top:4px;font-size:11px;line-height:16px;font-weight:600;letter-spacing:.3px;text-transform:uppercase;color:var(--v2-text-secondary)}
.sim-note{display:flex;gap:8px;align-items:flex-start;padding:10px 12px;border-radius:8px;background:var(--v2-surface-subtle);color:var(--v2-text-secondary);font-size:13px;line-height:20px}
.sim-note svg{margin-top:2px}

/* ---------- Generic dialog ---------- */
dialog.gen{width:520px}
dialog.gen.wide{width:720px}
dialog.gen .db{padding:0 24px 20px;display:flex;flex-direction:column;gap:16px}
dialog.gen form{margin:0}

/* ---------- Tabs (route-driven) ---------- */
.tabs{display:flex;gap:4px;border-bottom:1px solid var(--v2-border-subtle);overflow-x:auto}
.tab{position:relative;display:inline-flex;align-items:center;min-height:40px;padding:0 12px;color:var(--v2-text-secondary);font-weight:500;text-decoration:none;white-space:nowrap;border-radius:6px 6px 0 0;transition:color var(--v2-motion-duration-fast) var(--v2-motion-easing-standard),background-color var(--v2-motion-duration-fast) var(--v2-motion-easing-standard)}
.tab:hover{color:var(--v2-text-primary);background:var(--v2-surface-subtle)}
.tab[aria-current="page"]{color:var(--v2-text-primary)}
.tab[aria-current="page"]::after{content:"";position:absolute;left:8px;right:8px;bottom:-1px;height:2px;border-radius:2px;background:var(--v2-action-primary);animation:tab-in var(--v2-motion-duration-base) var(--v2-motion-easing-standard) both}
@keyframes tab-in{from{transform:scaleX(.4);opacity:0}to{transform:none;opacity:1}}

/* ---------- Toast extras ---------- */
.toasts.top{bottom:auto;top:72px}

/* Target size (WCAG 2.5.8): standalone links in lists, definition lists and cards get a 24 px tall target; table checkboxes 20 px with row spacing */
#view :is(li,dd,.card,.int-desc) > a:not(.btn):not(.row-link):not(.nav-link){display:inline-block;min-height:24px;line-height:24px}
table.data input[type=checkbox]{width:20px;height:20px;margin:2px;accent-color:var(--v2-action-primary)}

/* Closed popovers are removed from layout (a visibility-hidden popover near the right edge widened the page on phones) */
.popover:not(.open){display:none}
.popover.open{animation:pop-in var(--v2-motion-duration-fast) var(--v2-motion-easing-enter) both}
@keyframes pop-in{from{opacity:0;transform:translateY(-4px) scale(.98)}to{opacity:1;transform:none}}
.popover{max-width:calc(100vw - 32px)}
