/* ══════════════════════════════════════════════════════════════════════════
   SUPPORT STUDIO — FAVORITES  (feature fav-1, 2026-08-06, MACE)

   The `.sfx-*` design system: the top-bar star + hub control, the favorites
   BAR under the header, and the body-level portals (hub flyout, menus, edit
   dialog, toast).

   DESIGN LAW
   • It reads as part of the Studio, not as a bolted-on widget: same surfaces,
     same 6-8px radii, same 9-12px type ramp, same cyan/blue accent language.
   • Every panel here is a <body> child (`position:fixed`), placed by JS. That
     is deliberate — an in-flow panel gets clipped by the card and header
     overflow rules (the ssx-2 lesson) and no z-index can undo a clip.
   • Both themes are first-class. Dark is the base; every light rule is
     `html[data-ss-theme="light"]`-scoped in THIS file, so enterprise_theme.css
     is never touched and never has to know this feature exists.
   • Contrast: every label/sub/hint pair below was checked against the surface
     it actually sits on, composited — muted text is #8b98a5 on #12181f (5.4:1)
     in dark and #5d6b7d on #ffffff (5.6:1) in light.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --sfx-surface:  #12181f;
  --sfx-surface2: #1a212a;
  --sfx-line:     rgba(255,255,255,.10);
  --sfx-line2:    rgba(255,255,255,.06);
  --sfx-text:     #e6edf3;
  --sfx-muted:    #8b98a5;
  --sfx-accent:   #58a6ff;
  --sfx-gold:     #e3b341;
  --sfx-danger:   #f85149;
  --sfx-shadow:   0 18px 48px rgba(0,0,0,.55), 0 0 0 1px rgba(0,0,0,.35);
}
html[data-ss-theme="light"] {
  --sfx-surface:  #ffffff;
  --sfx-surface2: #f4f7fb;
  --sfx-line:     #e2e8f0;
  --sfx-line2:    #eef2f7;
  --sfx-text:     #1f2733;
  --sfx-muted:    #5d6b7d;
  --sfx-accent:   #2a63cf;
  --sfx-gold:     #9a6700;
  --sfx-danger:   #c93a34;
  --sfx-shadow:   0 18px 44px rgba(16,24,40,.18), 0 2px 8px rgba(16,24,40,.10);
}

/* ── TOP-BAR CONTROL ─────────────────────────────────────────────────────── */
.sfx-topbar { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.sfx-star,
.sfx-hub-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; border-radius: 7px; cursor: pointer;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.12);
  color: #9fb3c8; font: 700 10px/1 var(--ss-font, 'Plus Jakarta Sans', system-ui, sans-serif);
  transition: color .15s, border-color .15s, background .15s;
}
.sfx-star { width: 28px; justify-content: center; padding: 0; font-size: 12px; }
.sfx-hub-btn { padding: 0 9px; }
.sfx-star:hover, .sfx-hub-btn:hover,
.sfx-star:focus-visible, .sfx-hub-btn:focus-visible,
.sfx-hub-btn[aria-expanded="true"] {
  color: #7ee3f5; border-color: rgba(34,211,238,.42); background: rgba(34,211,238,.10);
}
/* Saved state: the star is the one gold thing in the top bar, so "this page is
   already a favorite" is answerable at a glance without reading anything. */
.sfx-star.is-on { color: var(--sfx-gold); border-color: rgba(227,179,65,.45); background: rgba(227,179,65,.12); }
.sfx-star.is-on:hover { background: rgba(227,179,65,.2); }

.sfx-hub-label { letter-spacing: .04em; text-transform: uppercase; }
.sfx-hub-count {
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font: 800 9px/1 var(--ss-mono, 'JetBrains Mono', monospace);
  background: rgba(88,166,255,.18); color: #79c0ff; border: 1px solid rgba(88,166,255,.28);
}
.sfx-hub-count.is-zero { background: rgba(255,255,255,.06); color: #8b98a5; border-color: rgba(255,255,255,.10); }
html[data-ss-theme="light"] .sfx-star,
html[data-ss-theme="light"] .sfx-hub-btn { background: #fff; border-color: #dbe3ec; color: #3f4b5b; }
html[data-ss-theme="light"] .sfx-star.is-on { background: rgba(154,103,0,.10); border-color: rgba(154,103,0,.34); color: #8a5a00; }
html[data-ss-theme="light"] .sfx-hub-count { background: rgba(42,99,207,.10); color: #1f56b8; border-color: rgba(42,99,207,.22); }

@media (max-width: 1180px) { .sfx-hub-label { display: none; } .sfx-hub-btn { padding: 0 7px; } }

/* ── FAVORITES BAR ───────────────────────────────────────────────────────── */
/* Sits between .ss-header and .ss-body as a flex-shrink:0 row, so it takes its
   own height out of the canvas and never overlaps anything. Hidden by default
   — a user opts in from the hub, and the shell height never changes uninvited. */
.sfx-bar {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  height: 32px; min-height: 32px; padding: 0 12px;
  background: var(--ss-surface2, #161b22);
  border-bottom: 1px solid var(--ss-border, rgba(255,255,255,.09));
  overflow: hidden;
}
.sfx-bar[hidden] { display: none; }
.sfx-bar-track {
  display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0;
  overflow-x: auto; scrollbar-width: none; padding: 2px 0;
}
.sfx-bar-track::-webkit-scrollbar { display: none; }
.sfx-bar-hint {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 10px var(--ss-font, system-ui); color: var(--sfx-muted); white-space: nowrap;
}
.sfx-bar-hint > i { color: var(--sfx-gold); font-size: 10px; }

.sfx-chip {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  max-width: 210px; height: 24px; padding: 0 9px; border-radius: 6px; cursor: pointer;
  background: transparent; border: 1px solid transparent;
  color: #c3d0de; font: 700 10.5px/1 var(--ss-font, system-ui);
  white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
}
.sfx-chip > i { font-size: 10px; color: var(--sfx-chip, var(--sfx-accent)); flex-shrink: 0; }
.sfx-chip-lbl { overflow: hidden; text-overflow: ellipsis; }
.sfx-chip-caret { font-size: 7px !important; opacity: .55; }
.sfx-chip:hover, .sfx-chip:focus-visible {
  background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.10); color: #fff;
}
.sfx-bar.is-icons .sfx-chip-lbl { display: none; }
.sfx-bar.is-icons .sfx-chip { padding: 0 7px; }
html[data-ss-theme="light"] .sfx-bar { background: #f4f7fb; border-bottom-color: #e2e8f0; }
html[data-ss-theme="light"] .sfx-chip { color: #33404f; }
html[data-ss-theme="light"] .sfx-chip:hover { background: #e8eef7; border-color: #d5deea; color: #14202e; }

/* ── SHARED PANEL SHELL (hub · menu · dialog) ────────────────────────────── */
.sfx-panel {
  position: fixed; top: 0; left: 0; z-index: 4300;
  display: none; flex-direction: column;
  background: var(--sfx-surface);
  border: 1px solid var(--sfx-line);
  border-radius: 12px;
  box-shadow: var(--sfx-shadow);
  font-family: var(--ss-font, 'Plus Jakarta Sans', system-ui, sans-serif);
  color: var(--sfx-text);
  overflow: hidden;
  animation: sfx-in .13s ease-out;
}
.sfx-panel.is-open { display: flex; }
@keyframes sfx-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.sfx-panel.is-flipped { animation-name: sfx-in-up; }
@keyframes sfx-in-up { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.sfx-icon-btn {
  width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; color: var(--sfx-muted); font-size: 11px;
  transition: background .12s, color .12s, border-color .12s;
}
.sfx-icon-btn:hover { background: rgba(255,255,255,.07); color: var(--sfx-text); border-color: var(--sfx-line); }
html[data-ss-theme="light"] .sfx-icon-btn:hover { background: #eef2f7; }

/* ── HUB ─────────────────────────────────────────────────────────────────── */
.sfx-hub { width: 340px; max-width: calc(100vw - 16px); }
.sfx-hub-head {
  display: flex; align-items: center; gap: 7px; flex-shrink: 0;
  padding: 10px 10px 10px 13px;
  background: rgba(88,166,255,.06); border-bottom: 1px solid var(--sfx-line2);
}
.sfx-hub-title {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; color: var(--sfx-accent);
}
.sfx-hub-title > i { font-size: 11px; }
.sfx-hub-head .sfx-hub-count { margin-right: auto; }
html[data-ss-theme="light"] .sfx-hub-head { background: #f2f6fd; }

.sfx-hub-search {
  display: flex; align-items: center; gap: 7px; flex-shrink: 0;
  margin: 9px 11px 6px; padding: 0 9px; height: 30px; border-radius: 8px;
  background: var(--sfx-surface2); border: 1px solid var(--sfx-line);
}
.sfx-hub-search:focus-within { border-color: rgba(88,166,255,.45); }
.sfx-hub-search > i { font-size: 10px; color: var(--sfx-muted); flex-shrink: 0; }
.sfx-hub-search input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: none;
  color: var(--sfx-text); font: 600 11.5px var(--ss-font, system-ui);
}
.sfx-hub-search input::placeholder { color: var(--sfx-muted); }
.sfx-q-clear {
  width: 18px; height: 18px; border-radius: 5px; cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; color: var(--sfx-muted); font-size: 9px;
}
.sfx-q-clear:hover { color: var(--sfx-text); }

.sfx-hub-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 3px 7px 8px;
}
.sfx-hub-body::-webkit-scrollbar { width: 4px; }
.sfx-hub-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 99px; }
html[data-ss-theme="light"] .sfx-hub-body::-webkit-scrollbar-thumb { background: #c3cddc; }

.sfx-hub-foot {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 8px 10px; border-top: 1px solid var(--sfx-line2); background: var(--sfx-surface2);
}
.sfx-foot-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 11px; border-radius: 7px; cursor: pointer; min-width: 0;
  background: rgba(255,255,255,.05); border: 1px solid var(--sfx-line);
  color: var(--sfx-text); font: 700 10.5px var(--ss-font, system-ui);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .13s, border-color .13s;
}
.sfx-foot-btn > span { overflow: hidden; text-overflow: ellipsis; }
.sfx-foot-btn:hover { background: rgba(255,255,255,.1); }
.sfx-foot-btn.primary {
  flex: 1; background: rgba(88,166,255,.16); border-color: rgba(88,166,255,.36); color: #a9d2ff;
}
.sfx-foot-btn.primary:hover { background: rgba(88,166,255,.26); }
.sfx-foot-btn.danger { background: rgba(248,81,73,.12); border-color: rgba(248,81,73,.3); color: #ff9d97; }
.sfx-foot-btn.danger:hover { background: rgba(248,81,73,.2); }
html[data-ss-theme="light"] .sfx-foot-btn { background: #fff; border-color: #dbe3ec; color: #1f2733; }
html[data-ss-theme="light"] .sfx-foot-btn:hover { background: #eef2f7; }
html[data-ss-theme="light"] .sfx-foot-btn.primary { background: rgba(42,99,207,.10); border-color: rgba(42,99,207,.30); color: #1f56b8; }
html[data-ss-theme="light"] .sfx-foot-btn.danger { background: rgba(201,58,52,.08); border-color: rgba(201,58,52,.26); color: #a32d28; }

/* ── ROWS (hub tree) ─────────────────────────────────────────────────────── */
.sfx-children { position: relative; }
.sfx-row {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px 6px calc(8px + var(--sfx-indent, 0) * 14px);
  border-radius: 7px; cursor: pointer; user-select: none;
  transition: background .1s;
}
.sfx-row:hover { background: rgba(255,255,255,.055); }
.sfx-row:focus-visible { outline: 2px solid rgba(88,166,255,.5); outline-offset: -2px; }
html[data-ss-theme="light"] .sfx-row:hover { background: #eef3fa; }

.sfx-chev {
  width: 13px; height: 13px; flex-shrink: 0; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: var(--sfx-muted); font-size: 8px; transition: transform .15s;
}
.sfx-chev.open { transform: rotate(90deg); }
.sfx-chev.leaf { visibility: hidden; }
.sfx-chev:hover { color: var(--sfx-text); }

.sfx-ico {
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(88,166,255,.10); border: 1px solid rgba(88,166,255,.18);
  color: var(--sfx-accent); font-size: 10px;
}
.sfx-row.is-folder .sfx-ico { background: rgba(227,179,65,.12); border-color: rgba(227,179,65,.24); color: var(--sfx-gold); }
html[data-ss-theme="light"] .sfx-ico { background: rgba(42,99,207,.08); border-color: rgba(42,99,207,.18); }
html[data-ss-theme="light"] .sfx-row.is-folder .sfx-ico { background: rgba(154,103,0,.10); border-color: rgba(154,103,0,.20); }

.sfx-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.sfx-label {
  font-size: 11.5px; font-weight: 700; color: var(--sfx-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sfx-sub {
  font-size: 9px; font-weight: 600; color: var(--sfx-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sfx-crumb {
  margin: -3px 0 4px calc(38px + var(--sfx-indent, 0) * 14px);
  font-size: 9px; color: var(--sfx-muted);
}
.sfx-crumb > i { font-size: 8px; opacity: .7; margin-right: 3px; }

.sfx-more {
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent;
  color: var(--sfx-muted); font-size: 10px; opacity: 0; transition: opacity .12s, background .12s;
}
.sfx-row:hover .sfx-more, .sfx-more:focus-visible { opacity: 1; }
.sfx-more:hover { background: rgba(255,255,255,.09); color: var(--sfx-text); }

/* drag feedback — a line for "between", a filled ring for "into" */
.sfx-row.is-dragging { opacity: .45; }
.sfx-row.drop-before::before,
.sfx-row.drop-after::after {
  content: ''; position: absolute; left: 6px; right: 6px; height: 2px;
  background: var(--sfx-accent); border-radius: 2px;
}
.sfx-row.drop-before::before { top: -1px; }
.sfx-row.drop-after::after { bottom: -1px; }
.sfx-row.drop-into {
  background: rgba(88,166,255,.14);
  box-shadow: inset 0 0 0 1px rgba(88,166,255,.5);
}

/* ── EMPTY STATE ─────────────────────────────────────────────────────────── */
.sfx-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 7px; padding: 30px 22px 34px;
}
.sfx-empty > i { font-size: 22px; color: var(--sfx-gold); opacity: .6; }
.sfx-empty-t { font-size: 12px; font-weight: 800; color: var(--sfx-text); }
.sfx-empty-s { font-size: 10.5px; line-height: 1.6; color: var(--sfx-muted); max-width: 250px; }

/* ── MENU ────────────────────────────────────────────────────────────────── */
.sfx-menu { min-width: 210px; max-width: 300px; padding: 5px; }
.sfx-mi {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 9px; border-radius: 7px; cursor: pointer; text-align: left;
  background: transparent; border: 0; color: var(--sfx-text);
  font: 600 11.5px var(--ss-font, system-ui);
}
.sfx-mi > i { width: 13px; font-size: 10px; color: var(--sfx-muted); flex-shrink: 0; }
.sfx-mi > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sfx-mi > em { font-style: normal; font-size: 9px; color: var(--sfx-muted); }
.sfx-mi:hover { background: rgba(88,166,255,.14); }
.sfx-mi:hover > i { color: var(--sfx-accent); }
.sfx-mi.danger { color: #ff9d97; }
.sfx-mi.danger:hover { background: rgba(248,81,73,.16); }
.sfx-mi.danger > i { color: var(--sfx-danger); }
.sfx-mi-sep { height: 1px; margin: 4px 6px; background: var(--sfx-line2); }
.sfx-mi-head {
  padding: 6px 9px 5px; font-size: 9px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--sfx-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
html[data-ss-theme="light"] .sfx-mi:hover { background: #e8eef7; }
html[data-ss-theme="light"] .sfx-mi.danger { color: #a32d28; }

/* ── DIALOG ──────────────────────────────────────────────────────────────── */
.sfx-dialog { width: 316px; max-width: calc(100vw - 16px); padding: 0 0 10px; }
.sfx-dlg-head {
  display: flex; align-items: center; gap: 8px; padding: 11px 10px 11px 13px;
  border-bottom: 1px solid var(--sfx-line2); background: rgba(227,179,65,.07);
  font-size: 11.5px; font-weight: 800; color: var(--sfx-text);
}
.sfx-dlg-head > i { color: var(--sfx-gold); font-size: 12px; }
.sfx-dlg-head > span { flex: 1; }
html[data-ss-theme="light"] .sfx-dlg-head { background: #fdf7e9; }

.sfx-dlg-field { display: flex; flex-direction: column; gap: 4px; margin: 10px 13px 0; }
.sfx-dlg-field > span {
  font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--sfx-muted);
}
.sfx-dlg-field input,
.sfx-dlg-field select {
  height: 30px; padding: 0 9px; border-radius: 7px; outline: none;
  background: var(--sfx-surface2); border: 1px solid var(--sfx-line);
  color: var(--sfx-text); font: 600 11.5px var(--ss-font, system-ui);
}
.sfx-dlg-field input:focus, .sfx-dlg-field select:focus { border-color: rgba(88,166,255,.5); }
.sfx-dlg-note {
  display: flex; align-items: center; gap: 6px; margin: 9px 13px 0;
  padding: 6px 9px; border-radius: 6px;
  background: rgba(88,166,255,.07); border: 1px solid rgba(88,166,255,.16);
  font-size: 10px; color: var(--sfx-muted);
}
.sfx-dlg-note > i { font-size: 9px; color: var(--sfx-accent); }
.sfx-dlg-foot { display: flex; align-items: center; gap: 6px; margin: 13px 13px 2px; }
.sfx-dlg-spacer { flex: 1; }

/* ── TOAST ───────────────────────────────────────────────────────────────── */
.sfx-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(8px);
  z-index: 4400; padding: 9px 16px; border-radius: 9px;
  background: var(--sfx-surface); border: 1px solid var(--sfx-line);
  box-shadow: var(--sfx-shadow);
  color: var(--sfx-text); font: 700 11px var(--ss-font, system-ui);
  opacity: 0; pointer-events: none; transition: opacity .16s, transform .16s;
}
.sfx-toast.is-open { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── NARROW ──────────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .sfx-hub { width: calc(100vw - 16px); }
  .sfx-bar { padding: 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .sfx-panel, .sfx-toast { animation: none; transition: none; }
}
