/* ============================================================
   PULSEDECK — GLASS UI  ·  shared Liquid-Glass primitives (Part 3)
   Builds on liquid.css. Used by Helpdesk + Ticketing modules.
   Status semantics map to Apple system colors so they hold up
   in light AND dark. Backend stores status KEYS, not colors.
   ============================================================ */

:root {
  /* ---- STATUS (semantic, fixed across accent changes) ----- */
  --st-new:        #0a84ff;   /* blue   */
  --st-open:       #5e5ce6;   /* indigo */
  --st-answered:   #15b3b8;   /* teal   */
  --st-postponed:  #ff9f0a;   /* amber  */
  --st-resolved:   #28b463;   /* green  */
  --st-breach:     #ff453a;   /* red    */

  /* ---- PRIORITY ------------------------------------------- */
  --pr-urgent:  #ff453a;
  --pr-high:    #ff9f0a;
  --pr-normal:  #0a84ff;
  --pr-low:     #8e8e93;

  /* ---- INTENT TINTS --------------------------------------- */
  --auto:   #5e5ce6;   /* automation / macros  */
  --spam:   #8e8e93;   /* muted / flagged      */
  --merge:  #af52de;   /* linked / merged      */
}

/* lighter status hues in dark mode so glass pills stay legible */
.theme-dark {
  --st-new:#3a9bff; --st-open:#7d7bf0; --st-answered:#2bd4d9;
  --st-postponed:#ffb437; --st-resolved:#34d77a; --st-breach:#ff6b61;
  --pr-urgent:#ff6b61; --pr-high:#ffb437; --pr-normal:#3a9bff; --pr-low:#9a9aa0;
  --auto:#8a87f5; --spam:#9a9aa0; --merge:#c576ed;
}
@media (prefers-color-scheme: dark) {
  .theme-auto { --st-new:#3a9bff; --st-open:#7d7bf0; --st-answered:#2bd4d9;
    --st-postponed:#ffb437; --st-resolved:#34d77a; --st-breach:#ff6b61;
    --pr-urgent:#ff6b61; --pr-high:#ffb437; --pr-normal:#3a9bff; --pr-low:#9a9aa0;
    --auto:#8a87f5; --spam:#9a9aa0; --merge:#c576ed; }
}

/* ============================================================
   GLASS PANEL  (the module shell surface)
   heavy blur lives ONLY on .gpanel (large panels) — per spec.
   ============================================================ */
.gpanel {
  position: relative;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: var(--glass-border-w, 1px) solid var(--glass-border);
  border-radius: var(--r-card);
  box-shadow: inset 0 1px 0 var(--rim-top), inset 0 -1px 1px var(--rim-bottom), var(--glass-inner, 0 0 transparent), var(--panel-shadow);
}
/* text-dense panels go more solid for WCAG AA */
.gpanel.solid { background: var(--glass-solid); }

/* cursor-tracked specular highlight (set --mx/--my via JS) */
.spec::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 0%),
              rgba(255,255,255,calc(0.5 * var(--sheen-op))), transparent 60%);
  opacity: var(--spec-on, 0); transition: opacity var(--speed) var(--ease);
  z-index: 0;
}
.spec:hover::after { opacity: 1; }
.spec > * { position: relative; z-index: 1; }

/* ============================================================
   STATUS + PRIORITY PILLS  (glass · color + glow)
   ============================================================ */
.spill {
  display: inline-flex; align-items: center; gap: 6px; height: 23px; padding: 0 10px;
  border-radius: var(--r-pill); white-space: nowrap;
  font: 600 11.5px/1 var(--font); letter-spacing: 0.01em;
  background: color-mix(in srgb, var(--c) 15%, var(--glass-solid));
  border: 1px solid color-mix(in srgb, var(--c) 38%, transparent);
  color: color-mix(in srgb, var(--c) 64%, var(--ink));
  box-shadow: inset 0 1px 0 var(--rim-top);
}
.theme-dark .spill { color: color-mix(in srgb, var(--c) 72%, #fff); }
.spill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c);
  box-shadow: 0 0 7px 0 color-mix(in srgb, var(--c) 75%, transparent); }
.spill.glow { box-shadow: inset 0 1px 0 var(--rim-top), 0 0 16px -5px var(--c); }
.spill.solid-fill { background: var(--c); color: #fff; border-color: transparent;
  box-shadow: 0 6px 14px -8px var(--c), inset 0 1px 0 rgba(255,255,255,0.3); }

.st-new       { --c: var(--st-new); }
.st-open      { --c: var(--st-open); }
.st-answered  { --c: var(--st-answered); }
.st-postponed { --c: var(--st-postponed); }
.st-resolved  { --c: var(--st-resolved); }

.pr-urgent { --c: var(--pr-urgent); }
.pr-high   { --c: var(--pr-high); }
.pr-normal { --c: var(--pr-normal); }
.pr-low    { --c: var(--pr-low); }

/* tiny priority flag (table cell) */
.pflag { display: inline-flex; align-items: center; gap: 7px; font: 600 12.5px var(--font); color: var(--ink); white-space: nowrap; }
.pflag-i { width: 14px; height: 14px; display: grid; place-items: center; }
.pflag-i svg { width: 14px; height: 14px; color: var(--c); }
.pr-urgent .pflag-i svg { filter: drop-shadow(0 0 4px color-mix(in srgb, var(--c) 70%, transparent)); }

/* ============================================================
   INTENT BADGES  (automation, spam, merged, channel)
   ============================================================ */
.mbadge {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px;
  border-radius: var(--r-pill); font: 600 10.5px/1 var(--font); letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--c) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 26%, transparent);
  color: color-mix(in srgb, var(--c) 70%, var(--ink)); white-space: nowrap;
}
.theme-dark .mbadge { color: color-mix(in srgb, var(--c) 78%, #fff); }
.mbadge svg { width: 12px; height: 12px; }
.mbadge.auto  { --c: var(--auto); }
.mbadge.merge { --c: var(--merge); }
.mbadge.spam  { --c: var(--spam); }
.mbadge.sla   { --c: var(--pr-high); }
.mbadge.breach{ --c: var(--st-breach); }

/* ============================================================
   TAGS
   ============================================================ */
.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px 0 11px;
  border-radius: var(--r-pill); font: 500 12.5px var(--font); color: var(--ink-2);
  background: var(--glass-solid); border: 1px solid var(--glass-border); box-shadow: inset 0 1px 0 var(--rim-top);
}
.tag .x { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; cursor: pointer; color: var(--ink-3); }
.tag .x:hover { background: color-mix(in srgb, var(--st-breach) 16%, transparent); color: var(--st-breach); }
.tag .x svg { width: 12px; height: 12px; }
.tag-add { cursor: pointer; border-style: dashed; color: var(--ink-3); }
.tag-add:hover { color: var(--accent); border-color: var(--accent-lens); }
.tag-add svg { width: 13px; height: 13px; }

/* ============================================================
   SEGMENTED CONTROL (compact, for list headers)
   ============================================================ */
.seg-sm { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-pill);
  background: var(--glass-solid); border: 1px solid var(--glass-border); box-shadow: inset 0 1px 0 var(--rim-top); }
.seg-sm button { all: unset; cursor: pointer; padding: 6px 13px; border-radius: var(--r-pill);
  font: 600 12.5px var(--font); color: var(--ink-2); transition: var(--speed) var(--ease); white-space: nowrap; }
.seg-sm button:hover { color: var(--ink); }
.seg-sm button.on { background: var(--accent); color: var(--ink-on-accent); box-shadow: 0 5px 12px -7px var(--accent-ring); }

/* ============================================================
   ICON BUTTON + GHOST + SMALL BUTTONS  (Liquid Glass)
   ============================================================ */
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto;
  border-radius: var(--r-ctrl); border: 1px solid transparent; color: var(--ink-2);
  background: transparent; cursor: pointer; transition: var(--speed) var(--ease); }
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-lens); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.sm { width: 32px; height: 32px; } .icon-btn.sm svg { width: 16px; height: 16px; }

.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-xs { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: var(--r-ctrl); }
.btn-xs svg, .btn-sm svg { width: 14px; height: 14px; }
.btn-danger { background: var(--st-breach); color: #fff; box-shadow: 0 8px 18px -10px var(--st-breach), inset 0 1px 0 rgba(255,255,255,0.3); }
.btn-danger:hover { background: color-mix(in srgb, var(--st-breach) 86%, black); }

/* chip-style filter button */
.fchip { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px; border-radius: var(--r-pill);
  border: 1px solid var(--glass-border); background: var(--glass-solid); color: var(--ink-2); cursor: pointer;
  font: 600 13px var(--font); box-shadow: inset 0 1px 0 var(--rim-top); transition: var(--speed) var(--ease); }
.fchip:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 18%, transparent); }
.fchip.on { color: var(--accent); border-color: var(--accent-lens); background: var(--accent-soft); }
.fchip svg { width: 15px; height: 15px; }
.fchip .ct { font: 700 11px var(--font); color: var(--accent); }

/* ============================================================
   TOPBAR ADD-ONS  ·  department switcher + availability menu
   ============================================================ */
.tb-control { position: relative; }

.dept-btn, .avail-btn {
  display: inline-flex; align-items: center; gap: 9px; height: 38px; padding: 0 12px;
  border-radius: var(--r-pill); border: 1px solid var(--glass-border); background: var(--glass-solid);
  color: var(--ink); cursor: pointer; font: 600 13.5px var(--font); box-shadow: inset 0 1px 0 var(--rim-top);
  transition: var(--speed) var(--ease); white-space: nowrap;
}
.dept-btn:hover, .avail-btn:hover { border-color: color-mix(in srgb, var(--ink) 16%, transparent); }
.dept-btn .ic, .avail-btn .chev { color: var(--ink-3); }
.dept-btn .ic svg { width: 16px; height: 16px; }
.avail-btn .chev svg, .dept-btn .chev svg { width: 14px; height: 14px; }
.dept-btn .lead { width: 9px; height: 9px; border-radius: 3px; background: var(--accent); }

.avail-btn .pdot { width: 9px; height: 9px; border-radius: 50%; }
.pdot.online  { background: var(--st-resolved); box-shadow: 0 0 7px var(--st-resolved); }
.pdot.away    { background: var(--st-postponed); }
.pdot.break   { background: var(--merge); }
.pdot.offline { background: var(--ink-3); box-shadow: none; }

/* glass popover menu */
.menu {
  position: absolute; top: calc(100% + 8px); z-index: 60; min-width: 220px; padding: 6px;
  border-radius: 18px; background: var(--glass-solid);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--rim-top), 0 24px 60px -20px rgba(40,52,86,0.4);
}
.menu.right { right: 0; } .menu.left { left: 0; }
.menu-h { padding: 8px 12px 6px; font: 600 11px var(--font); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.menu-item {
  display: flex; align-items: center; gap: 11px; height: 40px; padding: 0 12px; border-radius: 11px;
  cursor: pointer; color: var(--ink); font: 500 14px var(--font); transition: var(--speed) var(--ease);
}
.menu-item:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.menu-item.sel { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.menu-item .pdot, .menu-item .lead { flex: 0 0 auto; }
.menu-item .lead { width: 10px; height: 10px; border-radius: 3px; }
.menu-item svg { width: 17px; height: 17px; color: var(--ink-2); }
.menu-item.sel svg { color: var(--accent); }
.menu-item .sub { font: 400 11.5px var(--font); color: var(--ink-3); margin-left: auto; }
.menu-item .ck { margin-left: auto; color: var(--accent); display: none; }
.menu-item.sel .ck { display: grid; place-items: center; }
.menu-item .ck svg { width: 16px; height: 16px; color: var(--accent); }
.menu-sep { height: 1px; background: var(--glass-border); margin: 5px 8px; }

/* checkbox-in-menu (column visibility) */
.menu-check { display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 12px; border-radius: 11px; cursor: pointer; }
.menu-check:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.menu-check .lbl { font: 500 13.5px var(--font); color: var(--ink); flex: 1; }
.menu-check .box { width: 19px; height: 19px; border-radius: 6px; border: 1.5px solid color-mix(in srgb, var(--ink) 24%, transparent);
  display: grid; place-items: center; transition: var(--speed) var(--ease); }
.menu-check .box svg { width: 12px; height: 12px; color: #fff; opacity: 0; }
.menu-check.on .box { background: var(--accent); border-color: var(--accent); }
.menu-check.on .box svg { opacity: 1; }

/* ============================================================
   CHECKBOX (rows + table)
   ============================================================ */
.cbx { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; border-radius: 6px; flex: 0 0 auto;
  border: 1.5px solid color-mix(in srgb, var(--ink) 26%, transparent); background: var(--glass-solid);
  cursor: pointer; display: grid; place-items: center; transition: var(--speed) var(--ease); position: relative; }
.cbx:hover { border-color: var(--accent); }
.cbx:checked { background: var(--accent); border-color: var(--accent); box-shadow: 0 4px 10px -5px var(--accent-ring); }
.cbx:checked::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(43deg) translateY(-1px); }
.cbx.dash:checked::after { content: ""; width: 9px; height: 0; border: none; border-top: 2px solid #fff; transform: none; }

/* ============================================================
   MASS-ACTIONS BAR  (floating glass)
   ============================================================ */
.massbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px;
  background: var(--accent-soft); border-bottom: 1px solid var(--accent-lens);
  box-shadow: inset 0 1px 0 var(--rim-top);
}
.massbar .n { font: 700 13.5px var(--font); color: var(--accent); display: flex; align-items: center; gap: 9px; }
.massbar .n .pip { background: var(--accent); color: var(--ink-on-accent); min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: var(--r-pill); display: grid; place-items: center; font: 700 12px var(--font); }
.massbar .grow { flex: 1; }
.mass-btn { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: var(--r-ctrl);
  border: 1px solid var(--glass-border); background: var(--glass-solid); color: var(--ink); cursor: pointer;
  font: 600 12.5px var(--font); box-shadow: inset 0 1px 0 var(--rim-top); transition: var(--speed) var(--ease); }
.mass-btn:hover { border-color: color-mix(in srgb, var(--ink) 18%, transparent); }
.mass-btn.danger { color: var(--st-breach); } .mass-btn.danger:hover { background: color-mix(in srgb, var(--st-breach) 12%, var(--glass-solid)); }
.mass-btn svg { width: 14px; height: 14px; }

/* ============================================================
   EMPTY + LOADING (shimmer skeleton)
   ============================================================ */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 48px; text-align: center; }
.empty .orb { width: 76px; height: 76px; border-radius: 26px; display: grid; place-items: center; color: var(--accent);
  background: var(--accent-soft); box-shadow: inset 0 1px 0 var(--rim-top), inset 0 0 0 1px var(--accent-lens), 0 12px 28px -14px var(--accent-ring); }
.empty .orb svg { width: 32px; height: 32px; }
.empty h3 { margin: 0; font: 600 17px var(--font); color: var(--ink); letter-spacing: -0.01em; }
.empty p { margin: 0; max-width: 280px; color: var(--ink-2); font: 400 13.5px var(--font); line-height: 1.55; }

.sk { border-radius: 7px; background: color-mix(in srgb, var(--ink) 8%, transparent); position: relative; overflow: hidden; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 7%, transparent), transparent); animation: gshimmer 1.5s infinite; }
@keyframes gshimmer { 100% { transform: translateX(100%); } }
.a11y-no-motion .sk::after { animation: none; }

/* pulse ring — determinate-less spinner; full spectrum conic sweep */
.ring { --ring-w: 3px; width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto;
  background: conic-gradient(from 0deg, #ff3b30, #ff9500, #ffcc00, #34c759, #00c7be, #0a84ff, #5e5ce6, #bf5af2, #ff2d92, #ff3b30);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--ring-w)), #000 calc(100% - var(--ring-w)));
  mask: radial-gradient(farthest-side, transparent calc(100% - var(--ring-w)), #000 calc(100% - var(--ring-w)));
  animation: ringspin 1.15s linear infinite; }
.ring.sm { width: 17px; height: 17px; --ring-w: 2.2px; }
.ring.lg { width: 48px; height: 48px; --ring-w: 4px; }
@keyframes ringspin { to { transform: rotate(360deg); } }
.a11y-no-motion .ring { animation-duration: 4s; }

/* ============================================================
   THEME TOGGLE (topbar) — lets reviewers see light & dark
   ============================================================ */
.theme-toggle { display: inline-flex; align-items: center; height: 38px; padding: 3px; border-radius: var(--r-pill);
  background: var(--glass-solid); border: 1px solid var(--glass-border); box-shadow: inset 0 1px 0 var(--rim-top); gap: 2px; }
.theme-toggle button { all: unset; cursor: pointer; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  color: var(--ink-3); transition: var(--speed) var(--ease); }
.theme-toggle button:hover { color: var(--ink); }
.theme-toggle button.on { background: var(--accent); color: var(--ink-on-accent); box-shadow: 0 5px 12px -7px var(--accent-ring); }
.theme-toggle button svg { width: 16px; height: 16px; }

/* small KV pair */
.kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--glass-border); }
.kv:last-child { border-bottom: none; }
.kv .k { font: 500 13px var(--font); color: var(--ink-2); display: flex; align-items: center; gap: 9px; }
.kv .k svg { width: 15px; height: 15px; color: var(--ink-3); }
.kv .v { font: 600 13px var(--font); color: var(--ink); text-align: right; }

[x-cloak] { display: none !important; }
