/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f4f6f8;
  --surface:     #ffffff;
  --card:        #ffffff;
  --border:      #dde3ea;
  --primary:     #e87722;
  --primary-dk:  #c45f0a;
  --text:        #1a2030;
  --text-dim:    #6b7a92;
  --link:        #e87722;
  --red:         #d32f2f;
  --green:       #2e7d32;
  --green-bg:    #e8f5e9;
  --radius:      10px;
  --shadow:      0 2px 8px rgba(0,0,0,.08);
}

html { font-size: 15px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
header {
  background: linear-gradient(135deg, #e87722 0%, #c45f0a 100%);
  padding: 1.5rem 1rem;
  text-align: center;
}
.header-inner { max-width: 780px; margin: 0 auto; }
header h1 {
  font-size: 2rem;
  color: #fff;
  letter-spacing: .02em;
  font-weight: 800;
}
.subtitle { color: rgba(255,255,255,.85); font-size: .9rem; margin-top: .35rem; }

/* ── Main layout ── */
main {
  flex: 1;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* ── Search ── */
.search-wrap {
  display: flex;
  gap: .5rem;
}
#url-input {
  flex: 1;
  padding: .8rem 1rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color .2s;
  min-width: 0;
}
#url-input:focus { border-color: var(--primary); }

button[type="submit"] {
  padding: .8rem 1.6rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s;
}
button[type="submit"]:hover { background: var(--primary-dk); }

/* ── Status ── */
#status {
  margin-top: 1.5rem;
  padding: .9rem 1.2rem;
  border-radius: var(--radius);
  font-size: .95rem;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}
#status.loading { color: var(--text-dim); }
#status.error   { border-color: var(--red); color: var(--red); background: #fff5f5; }

/* ── Results ── */
#results { margin-top: 1.75rem; display: flex; flex-direction: column; gap: 1.25rem; }

/* ── Card ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .65rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .07em;
}
.card-body { padding: 1rem; }

/* ── Product card ── */
.product-overview {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}
.product-overview img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: #fafafa;
}
.product-placeholder {
  width: 100px; height: 100px;
  display: flex; align-items: center; justify-content: center;
  background: #f0f0f0;
  border-radius: 6px;
  font-size: 2.5rem;
  flex-shrink: 0;
}
.product-info { flex: 1; min-width: 0; }
.product-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: .4rem;
  color: var(--text);
}
.product-meta {
  font-size: .85rem;
  color: var(--text-dim);
  margin-bottom: .5rem;
}
.product-price {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: .6rem;
}
.btn-visit {
  display: inline-block;
  padding: .45rem 1rem;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .2s;
}
.btn-visit:hover { background: var(--primary-dk); text-decoration: none; }

/* ── Coupon table ── */
.coupon-empty { color: var(--text-dim); font-size: .9rem; font-style: italic; }
.coupon-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.coupon-table th {
  background: var(--bg);
  color: var(--text-dim);
  text-align: left;
  padding: .45rem .7rem;
  border-bottom: 2px solid var(--border);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.coupon-table td {
  padding: .5rem .7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.coupon-table tr:last-child td { border-bottom: none; }
.coupon-code {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  background: #fff3e0;
  border: 1px dashed var(--primary);
  border-radius: 4px;
  padding: .2rem .5rem;
  font-size: .9rem;
  white-space: nowrap;
}
.coupon-no-code { color: var(--text-dim); font-style: italic; font-size: .85rem; }
.btn-copy {
  padding: .3rem .75rem;
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary);
  border-radius: 5px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.btn-copy:hover { background: var(--primary); color: #fff; }
.btn-copy.copied { background: var(--green); border-color: var(--green); color: #fff; }

/* ── Price comparison table ── */
.price-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.price-table th {
  background: var(--bg);
  color: var(--text-dim);
  text-align: left;
  padding: .45rem .7rem;
  border-bottom: 2px solid var(--border);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.price-table td {
  padding: .5rem .7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.price-table tr:last-child td { border-bottom: none; }
.price-table tr.cheapest { background: var(--green-bg); }
.price-cell {
  font-weight: 700;
  white-space: nowrap;
}
.price-cell.best { color: var(--green); }
.badge-best {
  display: inline-block;
  background: var(--green);
  color: #fff;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 700;
  padding: .15rem .45rem;
  margin-left: .4rem;
  vertical-align: middle;
}
.btn-shop {
  display: inline-block;
  padding: .35rem .9rem;
  background: var(--primary);
  color: #fff;
  border-radius: 5px;
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s;
}
.btn-shop:hover { background: var(--primary-dk); text-decoration: none; }

/* ── Banner: already cheapest ── */
.banner-cheapest {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1rem;
  background: var(--green-bg);
  border: 1px solid #c8e6c9;
  border-radius: 6px;
  margin-bottom: .75rem;
  font-size: .9rem;
  color: var(--green);
  font-weight: 600;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 1.25rem;
  color: var(--text-dim);
  font-size: .8rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ── Responsive ── */
@media (max-width: 520px) {
  .product-overview { flex-direction: column; }
  .search-wrap { flex-direction: column; }
  button[type="submit"] { width: 100%; }
  header h1 { font-size: 1.5rem; }
  .coupon-table td:nth-child(4),
  .coupon-table th:nth-child(4) { display: none; }
}
