/**
 * input: _shared/tokens.css, _shared/components.css
 * output: 筛选面板密度压缩原型样式 — 外壳复刻 qlai_v4 + 紧凑 5 行 chip 化设计
 * pos: 本原型私有样式
 *
 * 对照源：
 *   docs/prototypes/filter-first-home/prototype.css（外壳骨架）
 *   src/renderer/components/filter/FilterPanel.vue
 *   api/services/filtering/filter_schema.py（字段权威）
 */

:root {
  --xt-pack-color: var(--ql-xt-accent);
  --ours-pack-color: var(--ql-ours-accent);
}

body {
  margin: 0;
  font-family: var(--ql-font-family);
  font-variant-numeric: tabular-nums;
  background: var(--ql-app-bg);
  color: var(--ql-text);
  overflow: hidden;
}

/* ============ 外壳：左 ctrl + 右真实应用 ============ */
.proto-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
}

/* ============ 左侧控制面板 ============ */
.ctrl {
  background: var(--ql-surface);
  border-right: 1px solid var(--ql-border-light);
  padding: var(--ql-space-lg);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--ql-space-lg);
  height: 100vh;
}
.ctrl__header { display: flex; flex-direction: column; gap: 4px; padding-bottom: var(--ql-space-md); border-bottom: 1px solid var(--ql-border-light); }
.ctrl__title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.ctrl__sub { font-size: 12px; color: var(--ql-text-muted); }
.ctrl__group-title { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--ql-text-muted); margin-bottom: var(--ql-space-sm); }
.ctrl__guide { padding: 14px; background: var(--ql-surface-alt); border-radius: var(--ql-radius-sm); border: 1px solid var(--ql-border-light); }
.ctrl__guide--pale { background: transparent; border-style: dashed; }
.guide-rule, .guide-list { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.65; color: var(--ql-text-secondary); }
.guide-rule li, .guide-list li { margin-bottom: 4px; }
.guide-rule li::marker, .guide-list li::marker { color: var(--ql-action); }
.ctrl__options { display: flex; flex-direction: column; gap: 8px; }
.ctrl__radio { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: var(--ql-radius-sm); border: 1.5px solid var(--ql-border-light); background: var(--ql-surface); cursor: pointer; transition: var(--ql-transition-fast); }
.ctrl__radio:hover { border-color: var(--ql-action); background: var(--ql-surface-hover); }
.ctrl__radio[data-active="true"] { border-color: var(--ql-action); background: var(--ql-ours-bg-subtle); box-shadow: var(--ql-pill-shadow-subtle); }
.ctrl__radio input { position: absolute; opacity: 0; pointer-events: none; }
.ctrl__dot { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--ql-border); flex-shrink: 0; margin-top: 2px; position: relative; }
.ctrl__radio[data-active="true"] .ctrl__dot { border-color: var(--ql-action); background: var(--ql-action); }
.ctrl__radio[data-active="true"] .ctrl__dot::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--ql-surface); }
.ctrl__radio-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.ctrl__radio-title { font-size: 13px; font-weight: 600; color: var(--ql-text); }
.ctrl__radio-desc { font-size: 11.5px; color: var(--ql-text-muted); line-height: 1.5; }
.ctrl__foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: var(--ql-space-md); border-top: 1px solid var(--ql-border-light); font-size: 11px; color: var(--ql-text-muted); }
.ctrl__foot-item { display: flex; justify-content: space-between; }

/* ============ 右侧真实应用壳 ============ */
.app-stage {
  background: var(--ql-app-bg);
  position: relative;
  overflow: hidden;
  height: 100vh;
}
.main-view {
  position: absolute;
  inset: 20px;
  background: var(--ql-app-bg);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

/* ==== WindowChrome ==== */
.window-chrome { position: absolute; inset: 0 0 auto 0; height: 40px; z-index: var(--z-bar); background: transparent; }
.window-chrome__pinned { position: absolute; top: 0; left: 0; height: 100%; display: flex; align-items: center; gap: 12px; padding: 0 12px; z-index: var(--z-chrome-pinned); }
.mac-traffic { display: flex; gap: 8px; align-items: center; }
.mac-traffic__light { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.15); }
.mac-traffic__light--close { background: #FF5F57; }
.mac-traffic__light--min { background: #FEBC2E; }
.mac-traffic__light--max { background: #28C840; }
.mac-back { width: 24px; height: 24px; border: 0; background: transparent; border-radius: var(--ql-radius-xs); color: var(--ql-text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.mac-back:hover { background: var(--ql-surface-hover); color: var(--ql-text); }
.mac-back svg { width: 16px; height: 16px; }

.window-chrome__tab-region { position: absolute; top: 0; left: 268px; right: 0; height: 100%; display: flex; align-items: center; padding: 0 16px; }
.window-chrome__tab-shell { display: flex; align-items: stretch; min-width: 0; height: 100%; width: 100%; max-width: min(100%, 980px); }
.ws-tab-bar--chrome { display: flex; align-items: center; flex: 1; min-width: 0; height: 100%; background: transparent; padding: 0; }
.ws-tab-bar--chrome .ws-tabs-scroll { display: flex; align-items: center; flex: 1; min-width: 0; gap: 4px; padding: 7px 4px; overflow: hidden; }
.ws-tab { display: flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px; flex: 1 1 0; min-width: 60px; max-width: 180px; border-radius: 12px; color: var(--ql-text-muted); background: transparent; font-size: 12.5px; overflow: hidden; white-space: nowrap; cursor: pointer; transition: all 0.2s cubic-bezier(0.2, 0, 0, 1); }
.ws-tab.active { color: var(--ql-text); font-weight: 500; background: color-mix(in srgb, var(--ql-surface) 88%, transparent); box-shadow: 0 1px 2px rgba(15,23,42,0.06), inset 0 0 0 1px rgba(255,255,255,0.46); }
.ws-tab-icon { flex-shrink: 0; width: 14px; height: 14px; }
.ws-tab-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ==== Sidebar ==== */
.sidebar { position: absolute; top: 6px; left: 6px; bottom: 6px; z-index: var(--z-sticky); display: flex; flex-direction: column; width: 256px; background: var(--ql-glass-bg); backdrop-filter: var(--ql-glass-blur); -webkit-backdrop-filter: var(--ql-glass-blur); border: 1px solid rgba(0,0,0,0.06); border-radius: var(--ql-radius-surface); overflow: hidden; }
.sidebar-drag-spacer { height: 34px; flex-shrink: 0; }
.sidebar-logo { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 14px 20px 20px; flex-shrink: 0; }
.logo-brand { font-size: 20px; font-weight: 800; color: var(--ql-primary); letter-spacing: -0.5px; }
.sidebar-tools { margin: 0 14px; padding-bottom: 20px; display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.search-bar { height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border-radius: var(--ql-radius-pill); background: transparent; box-shadow: 0 0 0 1px var(--ql-border-light) inset; font-size: 12.5px; color: var(--ql-text-muted); }
.new-task-entry { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--ql-surface); color: var(--ql-text); border: 1px solid var(--ql-border-light); border-radius: var(--ql-radius-control); cursor: pointer; font-weight: 600; font-size: 13.5px; }
.section-header { display: flex; align-items: center; gap: 8px; padding: 0 20px 10px; flex-shrink: 0; }
.section-label { font-size: 12px; font-weight: 600; color: var(--ql-text-secondary); letter-spacing: 0.02em; }
.section-count { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; padding: 0 5px; border-radius: var(--ql-radius-pill); font-size: 10px; font-weight: 700; background: var(--ql-primary); color: var(--ql-text-inverse); }
.task-section { flex: 1; overflow-y: auto; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.task-card { padding: 10px 12px; border-radius: var(--ql-radius-sm); background: var(--ql-surface); border: 1px solid var(--ql-border-light); margin-bottom: 4px; }
.task-card--active { border-left: 3px solid var(--ql-primary); padding-left: 10px; box-shadow: var(--ql-shadow-xs); }
.task-card__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-card__name { font-size: 13px; font-weight: 600; color: var(--ql-text); }
.task-card__close { width: 20px; height: 20px; border: 0; background: transparent; color: var(--ql-text-tertiary); border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.task-card__sub { font-size: 11px; color: var(--ql-text-muted); margin-top: 2px; }
.task-item { display: flex; align-items: center; gap: 4px; padding: 7px 10px; border-radius: var(--ql-radius-xs); font-size: 12.5px; color: var(--ql-text-secondary); cursor: pointer; }
.task-item:hover { background: var(--ql-surface-hover); color: var(--ql-text); }
.task-item__chev { color: var(--ql-text-tertiary); font-size: 14px; line-height: 1; width: 12px; flex-shrink: 0; }
.task-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sidebar-footer { padding: 10px 14px; flex-shrink: 0; margin-top: auto; border-top: 1px solid var(--ql-border-light); }
.left-footer { display: flex; align-items: center; gap: 8px; }
.footer-user { display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: var(--ql-radius-xs); cursor: pointer; flex: 1; min-width: 0; border: none; background: transparent; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.user-avatar-default { background: linear-gradient(135deg, var(--ql-avatar-pink-from) 0%, var(--ql-avatar-pink-to) 100%); color: var(--ql-text-inverse); font-size: 12px; font-weight: 700; }
.user-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name { font-size: 13px; font-weight: 500; color: var(--ql-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==== ContentArea ==== */
.content-area {
  position: absolute;
  top: 40px;
  left: 268px;
  right: 6px;
  bottom: 6px;
  overflow-y: auto;
  background: var(--ql-surface);
  border-radius: var(--ql-radius-sm);
  padding: 16px 24px 24px;
}

/* ============ Hero ============ */
.home-hero {
  padding: 8px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.home-hero__tagline {
  font-size: 12px;
  font-weight: 600;
  color: var(--ql-action);
  letter-spacing: 0.04em;
}
.home-hero__title {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  line-height: 1.3;
}
.home-hero__title-q {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ql-text);
}
.home-hero__title-brief {
  font-size: 13px;
  color: var(--ql-text-secondary);
  font-weight: 400;
}
.home-hero__title-brief strong {
  color: var(--ql-action);
  font-weight: 700;
}

/* ============ Brief 行（双胶囊紧凑版） ============ */
.brief-row { display: flex; gap: 10px; margin-bottom: 8px; }
.brief-project,
.brief-need {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 16px;
  background: #fff;
  border: 1px solid var(--ql-border-light);
  border-radius: var(--ql-radius-pill);
  box-sizing: border-box;
}
.brief-project { flex: 1; min-width: 0; }
.brief-need { margin-bottom: 12px; }
.brief-project__icon,
.brief-need__icon {
  width: 14px;
  height: 14px;
  color: var(--ql-text-muted);
  flex-shrink: 0;
}
.brief-project__label,
.brief-need__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ql-text);
  white-space: nowrap;
  flex-shrink: 0;
}
.brief-project__input,
.brief-need__input {
  flex: 1;
  min-width: 0;
  border: none;
  padding: 0;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  color: var(--ql-text);
  outline: none;
}
.brief-project__input::placeholder,
.brief-need__input::placeholder { color: var(--ql-text-placeholder); }
.brief-project__chevron {
  width: 12px;
  height: 12px;
  color: var(--ql-text-muted);
  flex-shrink: 0;
}

/* ============ 紧凑筛选面板（星图风：左 group-label + 右 row 横排） ============ */
.fp {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 0;
}

/* fg：星图原生筛选组（白底 + 左 3px 色条 + 极简 group-title） */
.fg {
  display: flex;
  position: relative;
  background: var(--ql-surface);
  border: 1px solid var(--ql-border-light);
  border-left: 3px solid var(--ql-xt-accent);
  border-radius: var(--ql-radius-sm);
  overflow: hidden;
}
.fg--ours { border-left-color: var(--ql-action); }

/* 左侧 group label（白底，紧凑垂直，类似星图左侧） */
.fg-title {
  width: 96px;
  flex-shrink: 0;
  padding: 18px 14px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  align-items: flex-start;
  background: var(--ql-surface);
  border-right: 1px solid var(--ql-border-light);
}
.fg-num {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--ql-text-tertiary);
  font-family: var(--ql-font-mono);
}
.fg-title__name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ql-text);
  letter-spacing: 0.02em;
}
.fg--ours .fg-title__name { color: var(--ql-action); }

.fg-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: var(--ql-radius-xs);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.fg-badge--xt { background: var(--ql-xt-bg-subtle); color: var(--ql-xt-accent); border-color: var(--ql-xt-border); }
.fg-badge--ours { background: var(--ql-action); color: var(--ql-text-inverse); }

/* 折叠组：title 改 button-toggle */
.fg-title--toggle { padding: 12px; gap: 4px; }
.fg-title__btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  width: 100%;
  position: relative;
}
.fg-title__chev {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 11px;
  color: var(--ql-text-muted);
  transition: transform var(--ql-motion-fast);
}
.fg[data-open="true"] .fg-title__chev { transform: rotate(180deg); }
.fg-title__hint { font-size: 10px; color: var(--ql-text-muted); line-height: 1.3; margin-top: 2px; }

/* 右侧内容区：多 row 纵列 */
.fg-content {
  flex: 1;
  min-width: 0;
  padding: 6px 22px 10px;
  display: flex;
  flex-direction: column;
}

/* fg-content--collapsed：默认折叠 */
.fg-content--collapsed { display: none; }
.fg[data-open="true"] .fg-content--collapsed { display: flex; }

/* fr：单 row（左 row-title + 右内容横排，纯留白分隔） */
.fr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 22px;
  min-height: 44px;
  padding: 10px 0;
  position: relative;
}
.fr + .fr::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--ql-border-light);
  opacity: 0.6;
}

.fr-title {
  flex-shrink: 0;
  width: 78px;
  margin-right: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ql-text-secondary);
  position: relative;
  padding-left: 9px;
  letter-spacing: 0.02em;
  text-decoration: underline dashed rgba(0, 0, 0, 0.18);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  cursor: help;
}
.fr-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 11px;
  border-radius: 1px;
  background: var(--ql-primary);
}

.fr-divider {
  display: inline-block;
  width: 1px;
  height: 12px;
  background: var(--ql-border);
  margin: 0;
  opacity: 0.5;
  align-self: center;
}

/* ============ search-duo（内容找人 row） ============ */
.fr--search { align-items: stretch; gap: 8px 12px; }
.search-duo-row {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 10px;
}
.search-duo-item {
  flex: 1;
  display: flex;
  align-items: center;
  height: 34px;
  background: var(--ql-surface);
  border: 1px solid var(--ql-border);
  border-radius: var(--ql-radius-control);
  overflow: hidden;
  transition: var(--ql-transition-fast);
}
.search-duo-item:focus-within {
  border-color: var(--ql-primary);
  box-shadow: 0 0 0 3px var(--ql-primary-glow);
}
.sd-label {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 12px;
  background: var(--ql-surface-alt);
  border-right: 1px solid var(--ql-border-light);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ql-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.sd-icon { color: currentColor; }
.sd-icon.icon-ban { color: var(--ql-error); opacity: 0.7; }
.sd-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  padding: 0 12px;
  font-size: 13px;
  color: var(--ql-text);
  outline: none;
  font-family: inherit;
}
.sd-input::placeholder { color: var(--ql-text-placeholder); }

/* ============ fi-tag（标签项）：星图风默认无 box ============ */
.fi-tag, .fi-all {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--ql-radius-xs);
  background: transparent;
  color: var(--ql-text-secondary);
  font-size: 13px;
  font-weight: 450;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: var(--ql-transition-fast);
  border: 1px solid transparent;
}
.fi-tag:hover, .fi-all:hover {
  background: var(--ql-selected-bg);
  color: var(--ql-primary);
}
.fi-tag.active {
  background: var(--ql-selected-bg);
  color: var(--ql-primary);
  font-weight: 500;
  border-color: var(--ql-primary-glow);
}
/* "不限" active 是粉底白字（星图原生） */
.fi-all.active {
  background: var(--ql-primary);
  color: var(--ql-text-inverse);
  font-weight: 500;
  box-shadow: 0 1px 3px var(--ql-primary-glow);
  border-color: var(--ql-primary);
}

.fi-more {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 8px;
  font-size: 12.5px;
  color: var(--ql-xt-accent);
  cursor: pointer;
  font-weight: 500;
  margin-left: auto;
}
.fi-more:hover { opacity: 0.75; }

/* ============ fi-drop（下拉单选）：纯文字 + ▾ 无 box ============ */
.fi-drop {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 28px;
  padding: 0 8px;
  font-size: 13px;
  color: var(--ql-text-secondary);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  border-radius: var(--ql-radius-xs);
  transition: var(--ql-transition-fast);
}
.fi-drop:hover { color: var(--ql-primary); background: var(--ql-selected-bg); }
.fi-drop.has-value {
  color: var(--ql-primary);
  background: var(--ql-selected-bg);
  font-weight: 500;
  padding: 0 8px;
}
.fi-drop .arrow {
  font-size: 9px;
  margin-left: 2px;
  opacity: 0.5;
}
.fi-drop:hover .arrow,
.fi-drop.has-value .arrow { opacity: 0.85; }

/* fi-drop-bordered：性价比效果 row 用 dashed 下划线 */
.fi-drop.fi-drop-bordered { padding: 0 4px; }
.fi-drop.fi-drop-bordered .fi-drop-label {
  border-bottom: 1px dashed rgba(0, 0, 0, 0.2);
  padding-bottom: 1px;
}
.fi-drop.fi-drop-bordered:hover .fi-drop-label,
.fi-drop.fi-drop-bordered.has-value .fi-drop-label {
  border-bottom-color: var(--ql-primary);
}

/* ============ 状态切换：showcase ============ */
/* ① 空白态：清掉 active/has-value 高亮，sticky bar 隐藏 */
.main-view[data-state="empty"] .fi-tag.active:not(.fi-all) { background: transparent; color: var(--ql-text-secondary); border-color: transparent; box-shadow: none; font-weight: 450; }
.main-view[data-state="empty"] .fi-drop.has-value { color: var(--ql-text-secondary); background: transparent; padding: 0 4px; font-weight: 450; }
.main-view[data-state="empty"] .fi-drop.has-value .fi-drop-label { font-size: 13px; }
.main-view[data-state="empty"] .filter-action-bar { display: none; }

/* ② 已选态：默认即此态（has-value/active 高亮 + sticky bar 显示） */

/* ③ 精准展开态：fg--ours data-row="advanced" 展开 */
.main-view[data-state="expanded"] .fg[data-row="advanced"] .fg-content--collapsed { display: flex; }
.main-view[data-state="expanded"] .fg[data-row="advanced"] .fg-title__chev { transform: rotate(180deg); }
