/* Store Persona beta v1.0 — dashboard styles
   Vanilla CSS, no framework. Wireframe-driven layout. */

:root {
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface-2: #fafafb;
  --border: #e3e3e8;
  --border-strong: #d4d4dc;
  --text: #15151a;
  --muted: #6b6b76;
  --muted-2: #94949c;

  --pink-cta: #d90073;      /* Viori CTA pink */
  --pink-link: #c5003e;     /* Text link */
  --pink-deco: #e5067e;     /* Decorative on dark */
  --pink-frame: #fae3ef;    /* Filter-frame border */

  --ok: #117a37;
  --warn: #8b5a00;
  --err-bg: #fbebee;
  --err-fg: #8b1c2b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-card: 0 1px 2px rgba(20,20,30,0.04), 0 1px 3px rgba(20,20,30,0.06);
  --shadow-pop: 0 12px 36px rgba(20,20,30,0.12);

  --nav-w: 220px;
  --maxw: 1200px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
a { color: var(--pink-link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f0f0f4; padding: 0 .3rem; border-radius: 3px; font-size: .85em; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ============================ Top header ============================ */
.sp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .7rem 1.4rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.sp-header__brand { display: flex; align-items: center; gap: .7rem; }
.sp-header__logo {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  background: var(--pink-cta); color: #fff;
  font-weight: 700; font-size: .85rem; letter-spacing: 0.04em;
  border-radius: 8px;
}
.sp-header__title { font-size: 1rem; font-weight: 600; }
.sp-header__title-tag { color: var(--muted); font-weight: 400; font-size: .85rem; margin-left: .25rem; }
.sp-header__meta { display: flex; align-items: center; gap: .9rem; }
.sp-header__user { color: var(--muted); font-size: .88rem; }
.sp-btn-link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--pink-link); font: inherit;
}
.sp-btn-link:hover { text-decoration: underline; }

/* ============================ Shell ============================ */
.sp-shell {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  min-height: calc(100vh - 49px);
}

.sp-nav {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem .6rem;
  display: flex; flex-direction: column; gap: .15rem;
  position: sticky; top: 49px; align-self: start;
  height: calc(100vh - 49px);
}
.sp-nav__item {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .7rem;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.sp-nav__item:hover { background: var(--surface-2); }
.sp-nav__item--active {
  background: var(--pink-frame);
  color: var(--pink-link);
  font-weight: 600;
}
.sp-nav__icon {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  font-size: .7rem; font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
}
.sp-nav__item--active .sp-nav__icon {
  background: var(--pink-cta); color: #fff; border-color: var(--pink-cta);
}

.sp-main {
  padding: 1.4rem 1.6rem 4rem;
  max-width: var(--maxw);
  width: 100%;
}
.sp-view { width: 100%; }

/* ============================ Sub-tabs ============================ */
.sp-subtabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.2rem;
}
.sp-subtab {
  background: transparent;
  border: 0;
  padding: .7rem 1rem;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.sp-subtab:hover { color: var(--text); }
.sp-subtab--active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--pink-cta);
}

/* ============================ Headings ============================ */
.sp-h2 { font-size: 1.05rem; font-weight: 600; margin: 0; }
.sp-h2--inline { display: inline-block; }

/* ============================ Buttons ============================ */
.sp-btn-primary, .sp-btn-secondary {
  border-radius: var(--radius-sm);
  padding: .55rem 1rem;
  font: inherit; cursor: pointer;
  border: 1px solid transparent;
}
.sp-btn-primary {
  background: var(--pink-cta);
  color: #fff;
  border-color: var(--pink-cta);
}
.sp-btn-primary:hover { background: #b8005f; border-color: #b8005f; }
.sp-btn-primary--ghost {
  background: transparent;
  color: var(--pink-cta);
}
.sp-btn-primary--ghost:hover { background: var(--pink-frame); color: var(--pink-link); }
.sp-btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.sp-btn-secondary:hover { background: var(--surface-2); }
.sp-btn-primary:disabled, .sp-btn-secondary:disabled { opacity: .5; cursor: not-allowed; }

/* ============================ List view ============================ */
.sp-list-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .9rem;
}
.sp-list-toolbar__right { display: flex; gap: .5rem; }
.sp-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: auto;
  box-shadow: var(--shadow-card);
}
.sp-table {
  width: 100%;
  border-collapse: collapse;
}
.sp-table th, .sp-table td {
  text-align: left;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sp-table th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
}
.sp-table tbody tr:last-child td { border-bottom: 0; }
.sp-table tbody tr:hover td { background: var(--surface-2); }
.sp-table__loading, .sp-table__empty {
  text-align: center;
  color: var(--muted);
  padding: 1.6rem;
}
.sp-archived { margin-top: 1.6rem; }
.sp-archived summary { cursor: pointer; user-select: none; padding: .4rem 0; }
.sp-archived summary::-webkit-details-marker { display: none; }
.sp-archived summary::before {
  content: "▸";
  display: inline-block;
  width: 1rem;
  color: var(--muted);
  transition: transform .15s;
}
.sp-archived[open] summary::before { transform: rotate(90deg); }

/* ============================ Status badges ============================ */
.sp-badge {
  display: inline-block;
  padding: .15rem .55rem;
  font-size: .72rem;
  font-weight: 600;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sp-badge--draft { background: #f0f0f4; color: var(--muted); }
.sp-badge--active { background: #e1f5e9; color: var(--ok); }
.sp-badge--disabled { background: #f5e6e9; color: var(--err-fg); }

/* ============================ Form ============================ */
.sp-form { display: flex; flex-direction: column; gap: 1.2rem; max-width: 920px; }
.sp-fieldset {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.3rem 1.3rem;
  margin: 0;
  box-shadow: var(--shadow-card);
}
.sp-fieldset legend {
  font-weight: 600;
  font-size: .95rem;
  padding: 0 .4rem;
  color: var(--text);
}
.sp-form label {
  display: block;
  font-weight: 500;
  margin-top: .9rem;
  margin-bottom: .25rem;
}
.sp-form input[type="text"],
.sp-form input[type="number"],
.sp-form input[type="file"],
.sp-form textarea,
.sp-form select {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--surface);
  margin-top: .25rem;
}
.sp-form input:focus,
.sp-form textarea:focus,
.sp-form select:focus {
  outline: 2px solid var(--pink-cta);
  outline-offset: -1px;
  border-color: var(--pink-cta);
}
.sp-form textarea { resize: vertical; min-height: 70px; }
.sp-help { display: block; color: var(--muted); font-size: .78rem; margin-top: .3rem; }
.sp-note { color: var(--muted); font-size: .85rem; margin: 0 0 .6rem; }
.sp-req { color: var(--pink-cta); }
.sp-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.sp-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.sp-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
.sp-upload-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.sp-upload-status { font-size: .75rem; color: var(--muted); }
.sp-upload-status.ok { color: var(--ok); }
.sp-upload-status.err { color: var(--err-fg); }
.sp-form__actions { display: flex; gap: .6rem; justify-content: flex-end; padding-top: .4rem; }
.sp-error { color: var(--err-fg); background: var(--err-bg); padding: .6rem .9rem; border-radius: var(--radius-sm); }

/* ============================ Chip pickers ============================ */
.sp-chip-group + .sp-chip-group { margin-top: 1rem; }
.sp-chip-group h4 {
  margin: 0 0 .4rem;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
}
.sp-chip-group h4 code {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  margin-left: .4rem;
  font-size: .72rem;
}
.sp-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.sp-chip {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: .35rem .8rem;
  border-radius: 999px;
  font-size: .82rem;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.sp-chip:hover { border-color: var(--muted-2); }
.sp-chip.is-active {
  background: var(--pink-cta);
  color: #fff;
  border-color: var(--pink-cta);
}
.sp-chip.is-active:hover { background: #b8005f; border-color: #b8005f; }
.sp-chip:focus-visible { outline: 2px solid var(--pink-cta); outline-offset: 2px; }

/* ============================ Urgency tool accordion ============================ */
.sp-urg {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: .55rem;
  background: var(--surface-2);
}
.sp-urg summary {
  cursor: pointer;
  padding: .65rem .9rem;
  font-weight: 600;
  user-select: none;
  list-style: none;
}
.sp-urg summary::-webkit-details-marker { display: none; }
.sp-urg summary::before {
  content: "▸";
  display: inline-block;
  margin-right: .5rem;
  color: var(--muted);
  transition: transform .15s;
}
.sp-urg[open] summary::before { transform: rotate(90deg); }
.sp-urg[open] { background: var(--surface); }
.sp-urg__body { padding: .2rem 1rem 1rem; }

/* ============================ Persona Profile (view 3) ============================ */
.sp-profile-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.sp-profile-meta {
  margin: .25rem 0 0;
  color: var(--muted);
  font-size: .82rem;
  word-break: break-all;
}
.sp-profile-actions {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
  flex-shrink: 0;
}

.sp-sections {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.sp-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.sp-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .7rem 1rem;
  cursor: pointer;
  user-select: none;
}
.sp-section__head:hover { background: var(--surface-2); }
.sp-section__title {
  display: flex; align-items: center; gap: .55rem;
  font-weight: 600;
}
.sp-section__title::before {
  content: "▸";
  color: var(--muted);
  transition: transform .15s;
}
.sp-section.is-open .sp-section__title::before { transform: rotate(90deg); }
.sp-section__num {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  font-size: .72rem; font-weight: 700;
  background: var(--pink-frame); color: var(--pink-link);
  border-radius: 5px;
}
.sp-section__body {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border);
  display: none;
}
.sp-section.is-open .sp-section__body { display: block; }
.sp-section__body p { color: var(--muted); margin: 1rem 0 0; }

/* ON/OFF toggle */
.sp-toggle {
  position: relative;
  display: inline-block;
  width: 38px; height: 22px;
  flex-shrink: 0;
}
.sp-toggle input { opacity: 0; width: 0; height: 0; }
.sp-toggle__track {
  position: absolute; inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  transition: background .15s;
}
.sp-toggle__track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 999px;
  transition: transform .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.sp-toggle input:checked + .sp-toggle__track { background: var(--pink-cta); }
.sp-toggle input:checked + .sp-toggle__track::after { transform: translateX(16px); }

/* ============================ Stubs (other nav tabs) ============================ */
.sp-stub {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  box-shadow: var(--shadow-card);
}
.sp-stub h2 { color: var(--text); margin-bottom: .5rem; }

.sp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.3rem;
  max-width: 480px;
  margin: 0 auto;
  box-shadow: var(--shadow-card);
  text-align: left;
}
.sp-card label { display: block; font-weight: 500; margin-top: .8rem; margin-bottom: .25rem; }
.sp-card input {
  width: 100%; padding: .55rem .7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
}
.sp-card button { margin-top: 1rem; }

/* ============================ Toasts ============================ */
.sp-toast {
  position: fixed;
  bottom: 1.5rem; left: 50%;
  transform: translateX(-50%);
  background: #15151a;
  color: #fff;
  padding: .6rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  z-index: 999;
  box-shadow: var(--shadow-pop);
}

/* ============================ Responsive ============================ */
@media (max-width: 820px) {
  :root { --nav-w: 64px; }
  .sp-nav__item span:last-child { display: none; }
  .sp-grid-2, .sp-grid-3, .sp-upload-row { grid-template-columns: 1fr; }
  .sp-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .sp-profile-head { flex-direction: column; }
  .sp-profile-actions { flex-direction: row; }
}
