/*
 * popover.css — shared filter popover + chip pattern (v3.1.0).
 *
 * Replaces the duplicated implementation that was copy-pasted between
 * styles.css (.proj-filter-pop) and survey-admin.html (.filter-pop) with
 * minor selector renames.
 *
 * Anatomy:
 *   <div class="popover-wrap">
 *     <button class="popover-trigger" aria-haspopup="true" aria-expanded="false">…</button>
 *     <div class="popover" role="dialog" hidden>
 *       <div class="popover__head">…</div>
 *       <div class="popover__body">…</div>
 *       <div class="popover__foot">…</div>
 *     </div>
 *   </div>
 *
 *   <span class="popover-chip">Filter A <button aria-label="Xoá">×</button></span>
 */

.popover-wrap {
  position: relative;
  display: inline-block;
}

.popover-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  min-height: 40px;
  border-radius: var(--radius-md, 8px);
  background: var(--surface-raised, #fff);
  border: 1.5px solid var(--border);
  color: var(--text);
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 14px;
  font-weight: var(--font-weight-medium, 500);
  cursor: pointer;
  transition: border-color var(--duration-fast, 0.12s),
              background var(--duration-fast, 0.12s);
  white-space: nowrap;
}
.popover-trigger:hover { border-color: var(--indigo); }
.popover-trigger.is-active,
.popover-trigger[aria-expanded="true"] {
  border-color: var(--indigo);
  background: rgba(19, 20, 124, 0.04);
  color: var(--indigo);
}
.popover-trigger svg { width: 16px; height: 16px; }

.popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 280px;
  max-width: min(90vw, 360px);
  background: var(--surface-raised, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(15, 23, 42, 0.08));
  padding: var(--space-4, 16px);
  z-index: var(--z-dropdown, 200);
  display: none;  /* default hidden — toggle via [hidden]=false or .is-open */
}
.popover[hidden] { display: none; }
.popover.is-open,
.popover:not([hidden]) { display: flex; flex-direction: column; }

.popover__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3, 12px);
}
.popover__title {
  font-family: var(--font-display, 'Be Vietnam Pro', sans-serif);
  font-size: var(--font-size-sm, 13px);
  font-weight: var(--font-weight-bold, 700);
  color: var(--text-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.popover__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3, 12px);
}

.popover__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2, 8px);
  margin-top: var(--space-4, 16px);
  padding-top: var(--space-3, 12px);
  border-top: 1px solid var(--border);
}

/* ── Chip — for displaying active filters ──────────────────── */
.popover-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 10px;
  border-radius: var(--radius-pill, 9999px);
  background: rgba(19, 20, 124, 0.06);
  color: var(--indigo);
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 12px;
  font-weight: var(--font-weight-semibold, 600);
}
.popover-chip__remove {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}
.popover-chip__remove:hover {
  background: rgba(19, 20, 124, 0.12);
}

@media (min-width: 640px) {
  .popover {
    min-width: 320px;
  }
}
