/* ==========================================================================
   Vendor Portal — styles on top of the admin design system
   (/admin/css/variables.css, layout.css, components.css, forms.css, utilities.css)
   ========================================================================== */

/* ---------- helpers missing from the admin utilities ---------- */
[hidden] { display: none !important; }
.table-wrap, .card, .form-group { position: relative; }   /* contain .sr-only (absolute) inside scroll areas */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.d-block { display: block; }
.text-left { text-align: left; }
.justify-center { justify-content: center; }
.vp-pre { white-space: pre-line; }
.btn.disabled { opacity: 0.55; pointer-events: none; }
.bar-fill.green { background: var(--success); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.vp-body .table td, .vp-body .table th { vertical-align: top; }

.vp-skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface); color: var(--text); padding: 8px 12px; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.vp-skip:focus { left: 8px; }

/* ---------- signed-out screens ---------- */
.vp-auth { min-height: 100vh; display: flex; flex-direction: column; background:
  radial-gradient(1200px 400px at 10% -10%, var(--primary-soft), transparent 70%),
  radial-gradient(900px 300px at 110% 0%, var(--accent-soft), transparent 70%), var(--bg); }
.vp-auth-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; }
.vp-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); }
.vp-brand:hover { text-decoration: none; }
.vp-brand small { color: var(--text-muted); font-weight: 500; }
.vp-head-actions { display: flex; gap: 6px; }
.vp-auth-main { flex: 1; width: 100%; max-width: 460px; margin: 0 auto; padding: 16px; outline: none; }
.vp-auth-main.wide { max-width: 960px; }
.vp-auth-card { margin-top: 4vh; }
.vp-auth-title { font-size: 22px; margin: 0 0 6px; line-height: 1.3; }
.vp-auth-foot { text-align: center; font-size: var(--fs-sm); color: var(--text-muted); padding: 20px; }
.vp-blocked-icon { font-size: 44px; margin-bottom: 8px; }

/* apply form */
.vp-apply-head { margin: 8px 0 16px; }
.vp-fieldset { margin: 0 0 18px; padding: 0; border: 1px solid var(--border); min-width: 0; }
.vp-legend { float: left; width: 100%; padding: 14px 18px; margin: 0; font-weight: 700; font-size: var(--fs-lg); border-bottom: 1px solid var(--border); }
.vp-legend + * { clear: both; }
.vp-apply-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 6px 0 24px; }
.vp-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.vp-prefix { display: flex; align-items: stretch; }
.vp-prefix > span { display: inline-flex; align-items: center; padding: 0 8px; border: 1px solid var(--border-strong); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--surface-2); color: var(--text-muted); font-size: var(--fs-sm); white-space: nowrap; }
.vp-prefix > .form-control { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; min-width: 0; }
.vp-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.vp-check-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: var(--fs-sm); min-height: 36px; }
.vp-check-chip:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.vp-check-chip:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
/* legal text (long, multi-line): keep the author's line breaks, wrap long lines, scroll inside the box */
.vp-terms { white-space: pre-wrap; overflow-wrap: anywhere; max-height: min(420px, 60vh); overflow: auto; overscroll-behavior: contain; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font-size: var(--fs-sm); line-height: 1.75; }
.vp-terms:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.vp-draft-banner { padding: 10px 14px; margin-bottom: 10px; border-radius: var(--radius-sm); background: var(--warning-soft); color: var(--warning); border: 1px dashed var(--warning); font-weight: 700; }

/* password */
.vp-pw-wrap { position: relative; }
.vp-pw-wrap .form-control { padding-right: 44px; }
.vp-pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-width: 36px; min-height: 32px; }
.vp-pw-meter { margin-top: 6px; }
.vp-pw-bar { height: 6px; border-radius: 999px; background: var(--surface-hover); overflow: hidden; }
.vp-pw-bar span { display: block; height: 100%; width: 0; border-radius: 999px; transition: width var(--transition); }
.vp-pw-bar[data-level="weak"] span { width: 33%; background: var(--danger); }
.vp-pw-bar[data-level="ok"] span { width: 66%; background: var(--warning); }
.vp-pw-bar[data-level="strong"] span { width: 100%; background: var(--success); }
.vp-pw-level { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; min-height: 1em; }
.vp-pw-rules { list-style: none; padding: 0; margin: 4px 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.vp-pw-rules li.ok { color: var(--success); }

/* ---------- app shell ---------- */
.vp-shop-chip { padding: 10px 16px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); display: grid; gap: 6px; }
.vp-shop-name { color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app.sidebar-collapsed .vp-shop-chip { display: none; }
.vp-side-link { color: var(--sidebar-text); }
.vp-bell { position: relative; text-decoration: none; }
.vp-bell:hover { text-decoration: none; }
.vp-bell-dot { position: absolute; top: -2px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.vp-global-alert { margin: 12px var(--sp-6) 0; }
.main { outline: none; }
.vp-body .topbar-actions { margin-left: auto; }
.vp-body .topbar-title { flex: 0 1 auto; }

/* banners */
.vp-banner { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 18px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.vp-banner-ic { font-size: 26px; }
.vp-banner-pending { border-color: var(--warning); background: var(--warning-soft); }
.vp-banner-active { border-color: var(--success); background: var(--success-soft); }
.vp-banner-blocked { border-color: var(--danger); background: var(--danger-soft); }
/* vendor identity (entity type + Thai tax ID) */
.vp-identity { display: flex; gap: 14px; padding: 14px 16px; margin-bottom: 18px; border-radius: var(--radius); border: 1px solid var(--warning); background: var(--warning-soft); }
.vp-identity-ic { font-size: 26px; line-height: 1; }
.vp-identity-title { font-size: var(--fs-md); font-weight: 700; margin: 0 0 4px; }
.vp-identity-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: var(--fs-sm); }
.vp-identity-list li { display: flex; gap: 8px; align-items: baseline; }
.vp-identity-list li > span:first-child { width: 16px; flex: none; text-align: center; font-weight: 700; }
.vp-identity-list li.ok > span:first-child { color: var(--success); }
.vp-identity-list li.bad > span:first-child { color: var(--danger); }
.vp-entity { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.vp-entity-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.vp-entity-opt input { margin-top: 4px; }
.vp-entity-opt small { font-size: var(--fs-xs); line-height: 1.4; margin-top: 2px; }
.vp-entity-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.vp-entity-opt:has(input:disabled) { cursor: not-allowed; opacity: 0.75; }
.vp-taxmask { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 38px; padding: 6px 10px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.vp-taxmask .mono { letter-spacing: 0.04em; }
.vp-rev-banner { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 16px; border-radius: var(--radius); border: 1px solid var(--warning); background: var(--warning-soft); }

/* dashboard */
.vp-dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.vp-span2 { grid-column: 1 / -1; }
.vp-chart { position: relative; }
.vp-chart svg { display: block; width: 100%; height: auto; }
.vp-chart .vp-grid { stroke: var(--border); stroke-width: 1; }
.vp-chart .vp-axis { fill: var(--text-muted); font-size: 11px; font-family: var(--font); }
.vp-chart .vp-bar path { fill: var(--primary); }
.vp-chart .vp-bar.on path { fill: var(--primary-hover); }
.vp-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 6px 10px; font-size: var(--fs-sm); white-space: nowrap; z-index: 2; }
.vp-scroll-y { max-height: 260px; overflow: auto; }
.vp-quota { margin-bottom: 12px; }
.vp-statlist, .vp-mini-list, .vp-notif-list, .vp-history, .vp-notes, .vp-checklist { list-style: none; margin: 0; padding: 0; }
.vp-statlist li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.vp-statlist li:last-child { border-bottom: 0; }
.vp-mini-list li a { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.vp-mini-list li a:hover { background: var(--surface-hover); text-decoration: none; }
.vp-notif { border-bottom: 1px solid var(--border); }
.vp-notif-btn { display: flex; gap: 10px; width: 100%; text-align: left; padding: 10px 16px; background: none; border: 0; color: var(--text); cursor: pointer; font: inherit; }
.vp-notif-btn:hover { background: var(--surface-hover); }
.vp-notif.unread { background: var(--primary-soft); }
.vp-notif.unread .vp-notif-t { font-weight: 700; }
.vp-notif-ic { font-size: 18px; }
.vp-notif-t, .vp-notif-b { display: block; }
.vp-notif-b { font-size: var(--fs-sm); color: var(--text-2); }

/* two-column editor layout */
.vp-two-col { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.vp-two-col-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.vp-side { min-width: 0; }
.vp-sticky { position: sticky; top: calc(var(--topbar-height) + 12px); }
.vp-side-actions { display: grid; gap: 8px; border-top: 1px solid var(--border); }
.vp-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: var(--fs-sm); }
.vp-dl dt { color: var(--text-muted); }
.vp-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.vp-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vp-h4 { margin: 16px 0 8px; font-size: var(--fs-md); }
.vp-h4:first-child { margin-top: 0; }
.vp-locked { color: var(--text-muted); }
.form-control[readonly], .form-textarea[readonly] { background: var(--surface-2); color: var(--text-muted); }
.vp-color { max-width: 90px; height: 38px; padding: 2px; }

/* rich editor */
.vp-rich { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.vp-rich-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.vp-rich-bar .btn { min-width: 34px; min-height: 32px; font-weight: 700; }
.vp-rich-area { min-height: 120px; max-height: 420px; overflow: auto; padding: 10px 12px; outline: none; line-height: 1.6; }
.vp-rich-area:focus { box-shadow: inset 0 0 0 2px var(--primary-soft); }
.vp-rich-area[contenteditable="false"] { background: var(--surface-2); color: var(--text-muted); }
.vp-rich-area h2, .vp-richtext h2 { font-size: 18px; margin: 10px 0 6px; }
.vp-rich-area h3, .vp-richtext h3 { font-size: 15px; margin: 8px 0 4px; }
.vp-rich-area p, .vp-richtext p { margin: 0 0 8px; }
.vp-rich-area blockquote, .vp-richtext blockquote, .vp-quote { margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--primary); background: var(--surface-2); }

/* images */
.vp-img { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.vp-img-prev { width: 96px; height: 96px; border: 1px dashed var(--border-strong); border-radius: var(--radius); display: grid; place-items: center; overflow: hidden; background: var(--surface-2); flex: none; }
.vp-img.wide .vp-img-prev { width: 240px; height: 60px; }
.vp-img-prev img { width: 100%; height: 100%; object-fit: cover; }
.vp-img-act { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.vp-img-act .field-hint { flex-basis: 100%; }
.vp-img-act label.btn { cursor: pointer; }
.vp-img-act:focus-within label.btn { outline: 2px solid var(--primary); outline-offset: 2px; }
.vp-shots { display: flex; flex-wrap: wrap; gap: 10px; }
.vp-shot { position: relative; width: 140px; height: 88px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.vp-shot img { width: 100%; height: 100%; object-fit: cover; }
.vp-shot .btn { position: absolute; top: 2px; right: 2px; background: var(--surface); }
.vp-shot-add { display: grid; place-items: center; align-content: center; gap: 2px; border-style: dashed; cursor: pointer; color: var(--text-muted); font-size: 22px; }
.vp-shots:focus-within .vp-shot-add { outline: 2px solid var(--primary); outline-offset: 2px; }

/* listing list */
.vp-ic { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--ic, var(--primary)); color: #fff; font-size: 18px; overflow: hidden; flex: none; vertical-align: middle; }
.vp-ic img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.page-header h1 .vp-ic { width: 40px; height: 40px; }
.vp-row-link { display: inline-flex; gap: 10px; align-items: center; color: var(--text); }
.vp-row-link:hover { text-decoration: none; }
.vp-row-link:hover b { text-decoration: underline; }
.vp-empty { text-align: center; padding: 40px 16px; color: var(--text-muted); }
.vp-empty > div { font-size: 40px; }

/* plans */
.vp-plan { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 12px; position: relative; min-width: 0; }
.vp-plan-head { padding: 0 6px; font-size: var(--fs-sm); }
.vp-plan-tools { display: flex; justify-content: flex-end; gap: 2px; margin: -6px 0 4px; }
.vp-plan-tools .btn { min-width: 32px; min-height: 32px; }
.vp-plan-flags { display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.vp-count { display: block; text-align: right; font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
.vp-count.bad { color: var(--danger); font-weight: 600; }

/* readiness */
.vp-checklist li { display: flex; gap: 8px; padding: 4px 0; font-size: var(--fs-sm); }
.vp-checklist li > span:first-child { width: 18px; flex: none; text-align: center; font-weight: 700; }
.vp-checklist li.ok > span:first-child { color: var(--success); }
.vp-checklist li.bad > span:first-child { color: var(--danger); }
.vp-checklist li.warn > span:first-child { color: var(--text-muted); }

/* diff */
.vp-diff th[scope="row"] { white-space: nowrap; font-weight: 600; color: var(--text-2); }
.vp-diff-before { background: var(--danger-soft); }
.vp-diff-after { background: var(--success-soft); }
.vp-diff td { overflow-wrap: anywhere; min-width: 140px; }
.vp-diff-img { max-width: 80px; max-height: 60px; border-radius: 4px; margin: 2px; }
.vp-diff-list { margin: 0; padding-left: 18px; }

/* history, notes */
.vp-history li, .vp-notes li { padding: 8px 16px; border-bottom: 1px solid var(--border); }
.vp-notes li { padding: 8px 0; }

/* shop preview */
.vp-shop-prev { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.vp-shop-cover { height: 70px; background: linear-gradient(120deg, var(--primary), var(--accent)); }
.vp-shop-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vp-shop-prev-body { padding: 0 14px 14px; }
.vp-shop-logo { width: 56px; height: 56px; margin-top: -28px; border-radius: 12px; border: 3px solid var(--surface); background: var(--surface-2); display: grid; place-items: center; overflow: hidden; font-size: 26px; }
.vp-shop-logo img { width: 100%; height: 100%; object-fit: cover; }
.vp-shop-prev-name { font-weight: 700; font-size: var(--fs-lg); margin-top: 6px; }
.vp-richtext { font-size: var(--fs-sm); }
.vp-link-like { color: var(--primary); }

/* team secret */
.vp-secret { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.vp-secret code { flex: 1; font-size: 17px; font-family: var(--font-mono); letter-spacing: 0.5px; user-select: all; overflow-wrap: anywhere; }
.vp-danger { border-color: var(--danger); }
.vp-danger .card-header h3 { color: var(--danger); }

/* leads */
.vp-filters { flex-wrap: wrap; gap: 8px; }
.vp-filters .form-select { width: auto; min-width: 150px; }
.vp-lead-pipe { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.vp-pipe-step { flex: 1; min-width: 70px; text-align: center; padding: 6px 8px; font-size: var(--fs-xs); border-radius: 999px; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.vp-pipe-step.on { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }
.vp-linkbtn { background: none; border: 0; padding: 0; color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.vp-linkbtn:hover b { text-decoration: underline; color: var(--primary); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .vp-two-col { grid-template-columns: minmax(0, 1fr); }
  .vp-sticky { position: static; }
}
@media (max-width: 900px) {
  .vp-global-alert { margin: 12px var(--sp-4) 0; }
}
@media (max-width: 700px) {
  .vp-dash-grid, .vp-two-col-even, .vp-two { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .form-grid .form-group { grid-column: auto !important; }
  .hide-sm { display: none; }
  .vp-plan .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .vp-plan .form-grid .span-full { grid-column: 1 / -1 !important; }
  .page-header h1 { font-size: 21px; }
  .vp-auth-main { padding: 12px; }
  .vp-legend { padding: 12px 14px; }
  .vp-filters .form-select, .vp-filters .search-input { width: 100%; min-width: 0; flex: 1 1 100%; }
  .vp-img.wide .vp-img-prev { width: 100%; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vp-diff th[scope="row"] { white-space: normal; }
  .table-wrap { overflow-x: auto; }
  .vp-body .card-header { flex-wrap: wrap; gap: 8px; }
  .vp-body .btn-group { flex-wrap: wrap; }
  .vp-body .page-actions { width: 100%; }
  .vp-rev-banner .flex { width: 100%; }
  .vp-body .main { overflow-x: hidden; }
}
@media (max-width: 380px) {
  .vp-plan .form-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .kpi .kpi-value { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* billing & package (js/vendor-billing.js) */
.vp-tier-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.vp-tier-card .card-body { display: flex; flex-direction: column; gap: 6px; height: 100%; }
.vp-tier-current { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.vp-tier-price { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.vp-tier-price small { font-size: .85rem; font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.vp-tier-feats { list-style: none; padding: 0; margin: 6px 0 10px; font-size: .9rem; flex: 1; }
.vp-tier-feats li { padding: 2px 0; }

/* AI rating card (ai_ratings.py) — listing editor side panel + list column */
.vp-ai-cell { white-space: nowrap; } .vp-ai-cell span { color: #d97706; }
.vp-ai-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.vp-ai-num { font-size: 30px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.vp-ai-stars { --pct: 0%; display: inline-block; font-size: 17px; letter-spacing: 2px; color: transparent; background: linear-gradient(90deg, #f59e0b var(--pct), var(--border) var(--pct)); -webkit-background-clip: text; background-clip: text; }
.vp-ai-crit { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.vp-ai-row { display: flex; justify-content: space-between; gap: 10px; font-size: var(--fs-sm); }
.vp-ai-crit .bar-track { margin: 3px 0 2px; } .vp-ai-crit .bar-fill { background: #f59e0b; }
.vp-ai-disc { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px dashed var(--border); color: var(--text-2); }
