/* ==========================================================================
   Price Survey v2 — app-specific styles.
   Extends css/base-theme.css (linked before this file). Uses ONLY the tokens
   defined there — no new colors/radii/shadows are invented here.
   ========================================================================== */

/* ---- App scaffold ---------------------------------------------------- */
.app-nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.nav-link {
  font-size: 13px; font-weight: 600; color: var(--text2);
  text-decoration: none; padding: 7px 12px; border-radius: 8px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--accent-lt); color: var(--accent); }

.brand-logo { height: 30px; width: auto; display: block; }
.header-user { font-size: 13px; color: var(--text2); font-weight: 600; }
.header-user .role-tag {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  background: var(--bg); color: var(--text3); border: 1px solid var(--border);
  border-radius: 12px; padding: 1px 8px; margin-left: 6px; text-transform: uppercase;
}

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 700; }
.page-sub { color: var(--text2); font-size: 13px; margin-top: 2px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text2);
  text-decoration: none; margin-bottom: 12px;
}
.back-link:hover { color: var(--accent); }

/* ---- Login ----------------------------------------------------------- */
.login-logo { display: block; margin: 0 auto 18px; height: 44px; width: auto; }
.gateway-card h1.login-title { text-align: center; margin-bottom: 4px; }
.gateway-card .login-tag { text-align: center; margin-bottom: 24px; }
.login-field { text-align: left; margin-bottom: 14px; }

/* ---- Dashboard: survey grid ----------------------------------------- */
.survey-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .survey-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1080px) { .survey-grid { grid-template-columns: repeat(3, 1fr); } }

.survey-card { display: flex; flex-direction: column; gap: 10px; }
.survey-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.survey-name { font-size: 16px; font-weight: 700; line-height: 1.3; }
.survey-date { font-size: 12px; color: var(--text3); font-family: 'JetBrains Mono', monospace; }
.survey-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text2); }
.survey-stats b { font-family: 'JetBrains Mono', monospace; color: var(--text); font-weight: 600; }
.survey-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }

/* ---- Tabs ------------------------------------------------------------ */
.ps-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.ps-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 16px; font-size: 14px; font-weight: 600; color: var(--text2);
  background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; white-space: nowrap; transition: color .15s, border-color .15s; margin-bottom: -1px;
}
.ps-tab:hover { color: var(--text); }
.ps-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.ps-tab svg { flex-shrink: 0; }

/* ---- Supermarket selector (grid of pills) --------------------------- */
.sm-selector { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.sm-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 15px; border-radius: 20px; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--border2); background: var(--surface); color: var(--text2);
  cursor: pointer; transition: all .15s;
}
.sm-pill:hover { border-color: var(--accent); color: var(--accent); }
.sm-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sm-pill .sm-count { font-family: 'JetBrains Mono', monospace; font-size: 11px; opacity: .8; }

/* ---- Photo card grid (price entry) ---------------------------------- */
.pc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.pc {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: visible;
  display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s;
}
.pc.saved { border-color: var(--success); }
.pc.noprice { border-color: var(--warning-text); }
.pc-photo-wrap { position: relative; height: 180px; background: var(--bg); border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; cursor: zoom-in; }
.pc-photo-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pc-photo-flag {
  position: absolute; top: 8px; right: 8px; display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700;
}
.pc-photo-flag.saved { background: var(--success); color: #fff; }
.pc-photo-flag.noprice { background: var(--warning-text); color: #fff; }
.pc-body { padding: 12px; display: flex; flex-direction: column; gap: 9px; }

/* searchable product combobox (inline) */
.pc-combo { position: relative; }
.pc-selected {
  font-size: 12.5px; font-weight: 600; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 9px; min-height: 32px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.pc-selected .muted { color: var(--text3); font-weight: 500; }
.pc-selected .clear-x { color: var(--text3); cursor: pointer; font-size: 14px; line-height: 1; }
.pc-selected .clear-x:hover { color: var(--danger); }
.pc-search { padding: 8px 11px; font-size: 13px; }
.pc-options {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0,0,0,.14); max-height: 240px; overflow-y: auto; display: none;
}
.pc-options.open { display: block; }
.pc-option { padding: 8px 11px; font-size: 12.5px; cursor: pointer; border-bottom: 1px solid var(--border); }
.pc-option:last-child { border-bottom: none; }
.pc-option:hover { background: var(--accent-lt); }
.pc-option .po-brand { font-weight: 700; }
.pc-option .po-meta { color: var(--text3); font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.pc-option-new { color: var(--accent); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.pc-options-note { padding: 7px 11px; font-size: 11px; color: var(--text3); }

.pc-price-row { display: flex; gap: 7px; align-items: stretch; }
.pc-price-input { flex: 1; padding: 8px 11px; font-family: 'JetBrains Mono', monospace; text-align: center; font-weight: 600; }
.pc-actions { display: flex; gap: 7px; }
.pc-actions .btn { flex: 1; padding: 9px 10px; font-size: 13px; }

/* ---- Price table ----------------------------------------------------- */
.pt-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.pt-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: auto; max-height: 74vh;
}
.pt { width: 100%; border-collapse: separate; border-spacing: 0; }
.pt th, .pt td { padding: 9px 12px; font-size: 13px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.pt thead th {
  background: #f8f9fb; position: sticky; top: 0; z-index: 3;
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text2);
}
.pt thead th.pt-sm { text-align: center; }
.pt thead th.pt-stat { text-align: right; color: var(--accent); }
/* sticky identity columns */
.pt .pt-sticky-1 { position: sticky; left: 0; z-index: 2; background: var(--surface); min-width: 120px; }
.pt .pt-sticky-2 { position: sticky; left: 120px; z-index: 2; background: var(--surface); min-width: 150px; }
.pt thead .pt-sticky-1, .pt thead .pt-sticky-2 { z-index: 4; background: #f8f9fb; }
.pt tbody tr:hover td { background: #fafbff; }
.pt tbody tr:hover .pt-sticky-1, .pt tbody tr:hover .pt-sticky-2 { background: #fafbff; }
.pt-brand { font-weight: 700; }
.pt-cat .chip { font-weight: 600; }
.pt-size { color: var(--text2); font-family: 'JetBrains Mono', monospace; }
.pt-cell { text-align: center; font-family: 'JetBrains Mono', monospace; font-weight: 600; }
.pt-cell.empty { color: var(--text3); font-weight: 400; }
.pt-cell.lo { background: var(--success-lt); color: #007a48; }
.pt-cell.hi { background: var(--danger-lt); color: var(--danger); }
.pt-price-link { color: inherit; text-decoration: none; cursor: pointer; border-bottom: 1px dotted currentColor; }
.pt-present { display: inline-block; font-size: 11px; font-weight: 700; color: var(--accent); font-family: 'Inter', sans-serif; }
.pt-stat-cell { text-align: right; font-family: 'JetBrains Mono', monospace; font-weight: 600; }
.pt-pres-pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.pres-high { background: var(--success-lt); color: #007a48; }
.pres-mid  { background: var(--warning-lt); color: var(--warning-text); }
.pres-low  { background: var(--danger-lt); color: var(--danger); }

/* ---- Data / export tab ---------------------------------------------- */
.export-grid { display: grid; grid-template-columns: 1fr; gap: 10px; max-width: 520px; }
@media (min-width: 560px) { .export-grid { grid-template-columns: 1fr 1fr; } }
.export-btn {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 14px 16px; background: var(--surface); border: 1.5px solid var(--border2);
  border-radius: var(--radius); cursor: pointer; text-decoration: none; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.export-btn:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.export-btn .eb-ico { color: var(--accent); flex-shrink: 0; }
.export-btn .eb-title { font-weight: 700; font-size: 14px; }
.export-btn .eb-desc { font-size: 12px; color: var(--text2); }

/* ---- Admin: dedup + tables ------------------------------------------ */
.admin-sub { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.sim-badge { font-family: 'JetBrains Mono', monospace; font-weight: 700; padding: 2px 9px; border-radius: 12px; font-size: 12px; }
.sim-high { background: var(--success-lt); color: #007a48; }
.sim-mid  { background: var(--warning-lt); color: var(--warning-text); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.merge-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--accent-lt); border: 1px solid rgba(0,115,234,.2);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; font-size: 13px;
}

/* ---- Lightbox -------------------------------------------------------- */
#lightbox {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.88);
  z-index: 2000; align-items: center; justify-content: center;
  cursor: zoom-out; backdrop-filter: blur(4px);
}
#lightbox.open { display: flex; }
#lightbox img { max-width: 92vw; max-height: 90vh; border-radius: 10px; box-shadow: 0 24px 64px rgba(0,0,0,.5); object-fit: contain; }
#lightbox-caption {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.8); font-size: 13px; background: rgba(0,0,0,.55);
  padding: 6px 18px; border-radius: 20px; white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}
#lightbox-close { position: fixed; top: 20px; right: 24px; color: #fff; font-size: 26px; cursor: pointer; opacity: .75; line-height: 1; }
#lightbox-close:hover { opacity: 1; }

/* ---- Toasts ---------------------------------------------------------- */
#toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 9px; padding: 11px 18px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 600; color: #fff; box-shadow: 0 8px 28px rgba(0,0,0,.22);
  animation: anim-fade-up var(--duration-base) var(--ease-out) both;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--text); }

/* ---- Misc ------------------------------------------------------------ */
.inline-error {
  background: var(--danger-lt); border: 1px solid rgba(226,68,92,.25);
  border-radius: var(--radius); padding: 14px 16px; color: var(--danger); font-size: 13px;
}
.field-error { color: var(--danger); font-size: 12px; margin-top: 6px; display: none; }
.field-error.show { display: block; }
.spin-inline { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; display: inline-block; animation: spin .65s linear infinite; }
.dz {
  border: 2px dashed var(--border2); border-radius: var(--radius); padding: 28px 20px;
  text-align: center; color: var(--text2); font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s;
}
.dz:hover, .dz.over { border-color: var(--accent); background: var(--accent-lt); }
.dz strong { color: var(--text); }
.mb-16 { margin-bottom: 16px; }


/* ======================================================================
   Compare view (cross-survey)
   ====================================================================== */
.cmp-toggle {
  display: inline-flex; align-items: center; gap: 7px; font-size: 13px;
  color: var(--text2); cursor: pointer; user-select: none; white-space: nowrap;
}
.cmp-toggle input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.cmp-picker { display: flex; flex-direction: column; gap: 8px; }
.cmp-prod {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; cursor: pointer; font: inherit; color: inherit;
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.cmp-prod:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.cmp-prod-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.cmp-prod-name { font-size: 14px; }
.cmp-prod-name .po-brand { font-weight: 700; }

/* Catalog thumbnails. The -empty variants keep the row height stable when a
   product has no image, so a list of mixed products does not jump around. */
.cmp-thumb, .cmp-head-thumb {
  border-radius: 8px; background: var(--bg); object-fit: contain; flex: none;
  border: 1px solid var(--border);
}
.cmp-thumb { width: 40px; height: 40px; }
.cmp-head-thumb { width: 56px; height: 56px; }
.cmp-thumb-empty, .cmp-head-thumb-empty, .po-thumb-empty {
  display: inline-flex; align-items: center; justify-content: center; color: var(--text3);
}
.cmp-head-left { display: flex; align-items: center; gap: 14px; }

.cmp-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.cmp-card { display: flex; flex-direction: column; gap: 4px; }
.cmp-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.cmp-card-name { font-weight: 700; font-size: 14px; }
.cmp-avg {
  font-family: 'JetBrains Mono', monospace; font-size: 22px; font-weight: 700;
  margin-top: 4px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.cmp-card-stats {
  display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text2); margin-top: 2px;
}
.cmp-card-stats b { font-family: 'JetBrains Mono', monospace; color: var(--text); }

.cmp-delta {
  display: inline-block; padding: 1px 7px; border-radius: 20px; font-size: 11px; font-weight: 700;
  font-family: 'JetBrains Mono', monospace; white-space: nowrap;
}
.cmp-delta.up   { background: var(--danger-lt);  color: var(--danger); }   /* price went up = bad for us */
.cmp-delta.down { background: var(--success-lt); color: #007a48; }
.cmp-delta.flat { background: var(--bg); color: var(--text3); font-family: 'Inter', sans-serif; font-weight: 600; }

.cmp-table .pt-cell { white-space: nowrap; }
.cmp-table .pt-cell .cmp-delta { margin-left: 6px; }
.cmp-table thead th.pt-sm { text-align: center; min-width: 130px; }

/* Ghost button that means "destructive" — same weight as the other card
   actions until hovered, so it does not shout on every survey card. */
.btn-danger-ghost { color: var(--text3); padding-left: 9px; padding-right: 9px; }
.btn-danger-ghost:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-lt); }

/* Product thumbnail inside the price-entry combobox and the price table. */
.po-thumb {
  width: 26px; height: 26px; border-radius: 5px; object-fit: contain;
  background: var(--bg); border: 1px solid var(--border); flex: none; vertical-align: middle;
}
.pc-option { display: flex; align-items: center; gap: 8px; }
.pc-option .po-text { flex: 1; min-width: 0; }
.pt-prod-cell { display: flex; align-items: center; gap: 8px; }

/* ---- Fixes over base-theme (do not edit base-theme.css) -------------- */
/* base-theme sets `padding: 10px 14px` on input[type="text"] (specificity 0,1,1),
   which outranks its own `.search-input { padding-left: 38px }` (0,1,0) — so the
   magnifier icon sat on top of the placeholder in every search box. */
input[type="text"].search-input { padding-left: 38px; }
/* base-theme uppercases every <label>; the compare toggle is a sentence, not a field label. */
.cmp-toggle { text-transform: none; letter-spacing: normal; font-weight: 500; font-size: 13px; }
/* Destructive confirm in a modal: the default confirm button is green (success),
   which reads as "go ahead" on an irreversible delete. */
.btn-modal-confirm.btn-modal-danger { background: var(--danger); }
