/* ============================================================================
 * components.css — styles for history-dropdown.js + privacy-filter.js
 * Brand: purple #7C5CFF / #6B4AF0, calm slate text, Space Grotesk headings.
 * Scope these under your own wrapper if class names collide.
 * ============================================================================ */

/* ---- History dropdown ---- */
.hd-panel {
  position: fixed; z-index: 82; width: 344px; max-width: calc(100vw - 24px);
  background: #fff; border: 1px solid rgba(33,26,55,.1); border-radius: 16px;
  box-shadow: 0 24px 60px -20px rgba(33,26,55,.35);
  overflow: hidden; display: flex; flex-direction: column;
  animation: hdPop .18s ease;
}
@keyframes hdPop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.hd-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid rgba(33,26,55,.08); }
.hd-title { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 16px; letter-spacing: -.01em; color: #211A37; }
.hd-new { display: inline-flex; align-items: center; gap: 6px; font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 12.5px; color: #6B4AF0; background: #F2EFFA; padding: 7px 11px; border: 0; border-radius: 8px; cursor: pointer; }
.hd-new:hover { background: #E7DEFB; }
.hd-list { max-height: 330px; overflow-y: auto; padding: 8px; }
.hd-empty { text-align: center; padding: 34px 24px; color: #A8A2BC; font-size: 14px; }
/* .hd-item layout (container + __main + __actions) is defined in the History rows block below. */
.hd-avatar { flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #9B86E8, #F4B8A0); color: #fff; font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: center; }
.hd-meta { flex: 1; min-width: 0; }
.hd-name { display: block; font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 14.5px; color: #211A37; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-sub { display: block; font-size: 12px; color: #8C86A0; }
.hd-foot { padding: 11px 16px; border-top: 1px solid rgba(33,26,55,.08); display: flex; align-items: flex-start; gap: 8px; }
.hd-foot p { font-size: 11.5px; color: #8C86A0; line-height: 1.5; margin: 0; }
.hd-foot svg { margin-top: 1px; flex-shrink: 0; }

/* The trigger button (style to taste; this matches the prototype's icon button) */
.hd-btn { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #211A37; border: 1px solid rgba(33,26,55,.1); background: #fff; cursor: pointer; }
.hd-btn:hover { background: #F2EFFA; border-color: #7C5CFF; color: #6B4AF0; }

/* ---- Privacy filter ---- */
.pf-wrap { font-family: system-ui, sans-serif; }
.pf-idle { font-size: 12.5px; color: #A8A2BC; display: flex; align-items: center; gap: 7px; margin: 0; }
.pf-scan { background: #FBFAFF; border: 1px solid rgba(124,92,255,.2); border-radius: 13px; padding: 15px 16px; }
.pf-scan-head { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; }
.pf-spin { width: 15px; height: 15px; border: 2px solid rgba(124,92,255,.3); border-top-color: #7C5CFF; border-radius: 50%; animation: pfSpin .7s linear infinite; display: inline-block; }
@keyframes pfSpin { to { transform: rotate(360deg); } }
.pf-scan-label { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 13.5px; color: #211A37; }
.pf-track { height: 7px; border-radius: 999px; background: rgba(33,26,55,.08); overflow: hidden; }
.pf-bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #7C5CFF, #F4B8A0); transition: width .12s linear; width: 0; }
.pf-note { font-size: 11.5px; color: #8C86A0; margin: 9px 0 0; }
.pf-ready { display: flex; align-items: center; gap: 11px; background: rgba(127,184,158,.12); border: 1px solid rgba(127,184,158,.4); border-radius: 12px; padding: 12px 14px; }
.pf-check { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; background: #7FB89E; display: flex; align-items: center; justify-content: center; }
.pf-ready-title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 13.5px; color: #2E4F3E; }
.pf-ready-sub { font-size: 11.5px; color: #5E7A6C; }
.pf-link { font-size: 12.5px; font-weight: 600; color: #5E7A6C; white-space: nowrap; background: none; border: 0; cursor: pointer; }
.pf-link:hover { color: #2E4F3E; }
.pf-preview { margin-top: 10px; border: 1px solid rgba(124,92,255,.22); border-radius: 13px; overflow: hidden; }
.pf-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 14px; background: #F7F3FF; border-bottom: 1px solid rgba(124,92,255,.16); }
.pf-preview-title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 13px; color: #211A37; }
.pf-count { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: #6B4AF0; background: rgba(124,92,255,.12); padding: 4px 9px; border-radius: 999px; }
.pf-body { max-height: 172px; overflow-y: auto; padding: 13px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; line-height: 1.7; color: #544C6B; white-space: pre-wrap; word-break: break-word; background: #fff; }
.pf-mask { background: rgba(124,92,255,.16); color: #5B3FD6; font-family: 'Space Grotesk', sans-serif; font-weight: 600; padding: 1px 5px; border-radius: 5px; }
.pf-preview-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 10px 14px; border-top: 1px solid rgba(124,92,255,.16); background: #FBFAFF; }

/* ---- Post-purchase processing (optional, used in demo) ---- */
.ppf-card { text-align: center; padding: 22px 6px 10px; }
.ppf-ring { width: 48px; height: 48px; border-radius: 50%; background: rgba(124,92,255,.12); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.ppf-ring .pf-spin { width: 22px; height: 22px; border-width: 3px; }
.ppf-title { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 19px; letter-spacing: -.01em; margin: 0; }
.ppf-phase { font-size: 13px; color: #6B6480; margin: 5px 0 0; }
.ppf-track { height: 8px; border-radius: 999px; background: rgba(33,26,55,.08); overflow: hidden; margin: 18px 0 4px; }
.ppf-email { margin-top: 20px; background: #FBFAFF; border: 1px solid rgba(33,26,55,.08); border-radius: 12px; padding: 13px 15px; display: flex; gap: 10px; align-items: flex-start; text-align: left; }
.ppf-email p { font-size: 12px; color: #6B6480; line-height: 1.55; margin: 0; }

/* ── Step 4: Privacy filter (left column) ──────────────────────────────────
   Pending by default; .pf-step--done reveals the green "filtered" status. */
.pf-step { margin: 18px 0 4px; }
.pf-step__label {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600; font-size: 16px; color: #211A37;
}
.pf-step__desc {
  margin: 6px 0 0 36px;
  font-size: 13px; color: #8C86A0; line-height: 1.5;
}
.pf-step__status {
  display: none;
  align-items: center; gap: 6px;
  margin: 8px 0 0 36px;
  font-size: 12.5px; font-weight: 600; color: #2E9E6B;
}
.pf-step__status::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  background: #2E9E6B center / 11px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M5 13l4 4L19 7' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  flex: 0 0 auto;
}
.pf-step--done .pf-step__status { display: inline-flex; }
.pf-step--done .pf-step__label { color: #2E9E6B; }

/* ── Privacy filter: curated green "done" box (step 4) ─────────────────────── */
.pf-greenbox {
  display: flex; align-items: center; gap: 13px;
  margin: 12px 0 2px;
  padding: 13px 14px;
  background: #EAF6EF;
  border: 1px solid rgba(46,158,107,.22);
  border-radius: 14px;
}
.pf-greenbox__check {
  flex: 0 0 auto;
  width: 26px; height: 26px; border-radius: 50%;
  background: #2E9E6B;
  display: inline-flex; align-items: center; justify-content: center;
}
.pf-greenbox__text { flex: 1 1 auto; min-width: 0; }
.pf-greenbox__title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 13.5px; color: #20543C; line-height: 1.3;
}
.pf-greenbox__sub { font-size: 12px; color: #5E7A6C; margin-top: 2px; }
.pf-greenbox__btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 7px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600; font-size: 12.5px; color: #fff;
  background: #2E7D54; border: 0; border-radius: 999px;
  padding: 9px 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s ease;
}
.pf-greenbox__btn:hover { background: #256544; }
.pf-greenbox__btn svg { flex: 0 0 auto; }

/* ── Token chip — one hue per entity type so the preview reads at a glance ──── */
.pf-chip {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600; font-size: 11px; letter-spacing: .02em;
  color: #6B4AF0; background: #ECE9FB;      /* fallback = person lavender */
  padding: 1px 6px; border-radius: 6px;
  white-space: nowrap; vertical-align: baseline;
}
.pf-chip--person  { color: #6B4AF0; background: #ECE9FB; }  /* lavender */
.pf-chip--email   { color: #1E6FCC; background: #E4F0FD; }  /* blue */
.pf-chip--phone   { color: #0E8A67; background: #DDF2EA; }  /* green */
.pf-chip--address { color: #B26A00; background: #FAEBD3; }  /* amber */
.pf-chip--url     { color: #B83280; background: #FBE4F1; }  /* pink */
.pf-chip--secret  { color: #C33B2E; background: #FBE5E2; }  /* red */
.pf-chip--account { color: #8A6A16; background: #F3EAD2; }  /* gold */

/* Colour dot next to each legend group header — ties the hue to its category. */
.pf-legend__dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 7px; vertical-align: middle; background: #6B4AF0;
}
.pf-legend__dot--person  { background: #6B4AF0; }
.pf-legend__dot--email   { background: #1E6FCC; }
.pf-legend__dot--phone   { background: #0E8A67; }
.pf-legend__dot--address { background: #B26A00; }
.pf-legend__dot--url     { background: #B83280; }
.pf-legend__dot--secret  { background: #C33B2E; }
.pf-legend__dot--account { background: #8A6A16; }

/* ── Privacy preview modal ─────────────────────────────────────────────────── */
.pf-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(24,18,46,.55);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.pf-modal__card {
  width: 100%; max-width: 880px; max-height: 85vh;
  display: flex; flex-direction: column;
  background: #fff; border-radius: 18px; overflow: hidden;
  box-shadow: 0 24px 64px rgba(24,18,46,.32);
}
.pf-modal__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid rgba(33,26,55,.08);
}
.pf-modal__title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 18px; color: #211A37; margin: 0; letter-spacing: -.01em;
}
.pf-modal__subtitle { font-size: 12.5px; color: #8C86A0; margin: 4px 0 0; }
.pf-modal__close {
  flex: 0 0 auto;
  width: 30px; height: 30px; border-radius: 8px;
  border: 0; background: transparent; cursor: pointer;
  font-size: 22px; line-height: 1; color: #8C86A0;
}
.pf-modal__close:hover { background: #F2EFFA; color: #211A37; }
.pf-modal__cols {
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 0;
  flex: 1 1 auto; min-height: 0;
}
.pf-modal__col {
  display: flex; flex-direction: column; min-height: 0;
  padding: 16px 20px;
}
.pf-modal__col + .pf-modal__col { border-left: 1px solid rgba(33,26,55,.08); }
.pf-modal__collabel {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 10.5px; letter-spacing: .08em;
  color: #A8A2BC; margin-bottom: 10px;
}
.pf-modal__transcript {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px; line-height: 1.85; color: #544C6B;
  white-space: pre-wrap; word-break: break-word;
}
.pf-modal__legend { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.pf-legend__group { margin-bottom: 14px; }
.pf-legend__grouphead {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600; font-size: 12px; color: #211A37; margin-bottom: 7px;
}
.pf-legend__row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 4px 0; font-size: 12.5px;
}
.pf-legend__row > .pf-chip { flex: 0 0 auto; }
.pf-legend__arrow { color: #C4BEDA; flex: 0 0 auto; }
.pf-legend__value {
  /* A long entity (multi-word name, URL, address…) wraps onto new lines and stays
     fully readable instead of truncating or breaking the row. */
  color: #544C6B; flex: 0 1 auto; min-width: 0;
  white-space: normal; overflow-wrap: anywhere; word-break: break-word;
}
.pf-legend__count { color: #A8A2BC; font-size: 11px; font-weight: 600; flex: 0 0 auto; }
.pf-legend__you {
  flex: 0 0 auto;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 9.5px; letter-spacing: .05em;
  color: #2E7D54; background: #E1F1E8;
  padding: 2px 6px; border-radius: 5px;
}
.pf-modal__foot {
  padding: 13px 22px;
  border-top: 1px solid rgba(33,26,55,.08);
  font-size: 12px; color: #8C86A0;
  background: #FBFAFF;
}
/* Stack the two columns before they get cramped (long entities need the width). */
@media (max-width: 760px) {
  .pf-modal { padding: 12px; }
  .pf-modal__card { max-height: 92vh; }
  .pf-modal__cols { grid-template-columns: 1fr; overflow-y: auto; }
  .pf-modal__col { padding: 14px 16px; }
  .pf-modal__col + .pf-modal__col { border-left: 0; border-top: 1px solid rgba(33,26,55,.08); }
  .pf-greenbox { flex-wrap: wrap; }
}

/* ── History rows: container + clickable main + action buttons (v2 parity) ── */
.hd-item { display: flex; align-items: center; gap: 4px; width: 100%; padding: 2px 4px; border-radius: 12px; background: transparent; cursor: default; }
.hd-item:hover { background: transparent; }
.hd-item__main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 10px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; }
.hd-item__main:hover { background: #F7F3FF; }
.hd-item__actions { flex-shrink: 0; display: flex; align-items: center; gap: 4px; }
.hd-act { border: 0; background: transparent; cursor: pointer; font-family: 'Space Grotesk', sans-serif; font-size: 12px; font-weight: 600; border-radius: 8px; padding: 6px 9px; line-height: 1; }
.hd-act--delete { color: #B6AFC9; padding: 7px; display: inline-flex; align-items: center; }
.hd-act--delete:hover { color: #D14343; background: #FBEAEA; }
.hd-act:disabled { color: #D2CDE0; cursor: not-allowed; background: transparent; }
.hd-act:disabled:hover { color: #D2CDE0; background: transparent; }
/* Locked rows: while a portrait is generating, every other conversation is
   dimmed and non-interactive (v2 parity). */
.hd-item--locked { opacity: .5; }
.hd-item--locked .hd-item__main { cursor: not-allowed; }
.hd-item--locked .hd-item__main:hover { background: transparent; }
.hd-item--processing .hd-sub { color: #7C5CFF; display: flex; align-items: center; gap: 6px; }
.hd-dot { width: 7px; height: 7px; border-radius: 50%; background: #7C5CFF; display: inline-block; flex: 0 0 auto; animation: hdPulse 1.1s ease-in-out infinite; }
@keyframes hdPulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
