/* ============================================================
   ClearPick — style.css
   ============================================================ */

:root {
  --navy:        #0f172a;
  --green:       #059669;
  --green-mid:   #047857;
  --green-light: #d1fae5;
  --green-glow:  rgba(5, 150, 105, 0.18);
  --blue:        #2563eb;
  --blue-light:  #dbeafe;
  --coral:       #dc2626;
  --coral-light: #fee2e2;
  --bg:          #f6f5f1;
  --surface:     #ffffff;
  --border:      rgba(15, 23, 42, 0.11);
  --border-md:   rgba(15, 23, 42, 0.20);
  --text:        #1e293b;
  --text-muted:  #64748b;
  --text-hint:   #94a3b8;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────── */

.app-header {
  background: var(--navy);
  padding-top: env(safe-area-inset-top, 0px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  padding: 14px 16px 10px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 3px;
}

.logo-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.logo-name {
  font-size: 22px;
  font-weight: 300;
  color: white;
  letter-spacing: -0.02em;
  line-height: 1;
}

.logo-name em {
  font-style: normal;
  font-weight: 700;
  color: #34d399;
}

.tagline {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  padding-left: 44px;
}

/* ── Category nav ───────────────────────────────────────── */

.category-tabs {
  display: flex;
  gap: 0;
  padding: 0 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  padding: 9px 14px 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: rgba(255, 255, 255, 0.45);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.cat-tab.active {
  color: #34d399;
  border-bottom-color: #34d399;
}

.cat-tab:not(.active):hover {
  color: rgba(255, 255, 255, 0.75);
}

/* ── Main ───────────────────────────────────────────────── */

.app-main {
  flex: 1;
  padding: 14px 12px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

/* ── Compare grid ───────────────────────────────────────── */

.compare-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

/* ── Product card ───────────────────────────────────────── */

.product-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 14px;
}

/* Two fields side by side within a card */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.field-row .field {
  margin-bottom: 0;
}

.product-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.product-head-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.pdot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pdot-a { background: var(--blue); }
.pdot-b { background: var(--coral); }

.product-head-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── Form fields ────────────────────────────────────────── */

.field {
  margin-bottom: 8px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  font-size: 11px;
  color: var(--text-hint);
  font-weight: 500;
  margin-bottom: 3px;
  display: block;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  height: 35px;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="number"] { font-variant-numeric: tabular-nums; }

input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
  background: white;
}

input::placeholder { color: var(--text-hint); }

/* Remove number spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; }

.size-row {
  display: grid;
  grid-template-columns: 1fr 14px 1fr;
  align-items: center;
  gap: 2px;
}

.size-sep {
  text-align: center;
  font-size: 11px;
  color: var(--text-hint);
}

/* ── Results section ────────────────────────────────────── */

.results-section {
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Results table */
.results-table {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 10px;
}

.results-head {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: #f1f5f9;
  border-bottom: 1px solid var(--border-md);
}

.rh-cell {
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 5px;
}

.rh-cell + .rh-cell {
  border-left: 1px solid var(--border);
  justify-content: flex-end;
}

.result-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border-top: 1px solid var(--border);
}

.r-metric {
  padding: 11px 10px;
  font-size: 12px;
  color: var(--text-muted);
  align-self: center;
  line-height: 1.3;
}

.r-val {
  padding: 11px 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-align: right;
  border-left: 1px solid var(--border);
  align-self: center;
  font-variant-numeric: tabular-nums;
}

.r-val.winner { color: var(--green-mid); }
.r-val.loser  { color: var(--text-hint); font-weight: 400; }

/* Winner banner */
.winner-banner {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  min-height: 0;
}

.winner-banner:empty { display: none; }
.winner-banner.a    { background: var(--blue-light);   color: #1d4ed8; }
.winner-banner.b    { background: var(--coral-light);  color: #b91c1c; }
.winner-banner.tie  { background: #f1f5f9;             color: var(--text-muted); }

/* ── Footer ─────────────────────────────────────────────── */

.app-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-hint);
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
}

/* ── Utilities ──────────────────────────────────────────── */

[hidden] { display: none !important; }

/* ── Winner bar (top position) ──────────────────────────────── */

/* Override: banner now lives above the grid, needs bottom margin */
#winner-banner {
  margin-bottom: 12px;
}

#winner-banner:empty {
  display: none;
  margin: 0;
}

/* Savings badge inside banner */
.pct-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: 4px;
  vertical-align: middle;
}

.winner-banner.a .pct-badge {
  background: rgba(37, 99, 235, 0.15);
  color: #1d4ed8;
}

.winner-banner.b .pct-badge {
  background: rgba(220, 38, 38, 0.15);
  color: #b91c1c;
}

/* ── Select fields ──────────────────────────────────────────── */

select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  padding: 0 28px 0 9px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
}

/* ── Sheet size toggle ──────────────────────────────────────── */

.size-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--green-mid);
  background: none;
  border: 1px solid var(--green-mid);
  border-radius: 20px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-top: 2px;
}

.size-toggle-btn:hover,
.size-toggle-btn.active {
  background: var(--green-light);
}

/* ── Winner bar in sticky header ────────────────────────────── */

.app-header .winner-banner {
  margin: 0 12px 10px;
  font-size: 13px;
}

.app-header .winner-banner:empty {
  display: none;
  margin: 0;
}

/* Remove the old top-of-main margin rule since banner moved to header */
#winner-banner {
  margin-bottom: 0;
}

/* ── Category dropdown in header ────────────────────────────── */

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.category-select {
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.80);
  font-size: 12px;
  font-family: inherit;
  padding: 5px 22px 5px 8px;
  cursor: pointer;
  margin-top: 4px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(255,255,255,0.6)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  min-width: 110px;
}

.category-select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.4);
}

/* Override: size toggle btn in product head — smaller, more subtle */
.product-head .size-toggle-btn {
  font-size: 11px;
  padding: 3px 8px;
  color: var(--text-hint);
  border-color: var(--border-md);
  margin-top: 0;
}

.product-head .size-toggle-btn:hover,
.product-head .size-toggle-btn.active {
  color: var(--green-mid);
  border-color: var(--green-mid);
  background: var(--green-light);
}
