/* This file controls how the dashboard LOOKS: colours, sizes, spacing and layout. */
/* Each block is "which elements { how they should look }". */

/* The colour palette. Change a colour here and it changes everywhere it's used. */
:root {
  --bg: #0d1117;
  --panel: #151b23;
  --panel-2: #1c2430;
  --line: #263040;
  --text: #e6edf3;
  --muted: #8b98a8;
  /* --accent is the Vinted-style teal used for buttons and highlights. */
  --accent: #09b1ba;
  --accent-ink: #032326;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 12px;
  color-scheme: dark;
}
/* Make widths include padding and borders (makes sizing predictable). */
* { box-sizing: border-box; }
/* Anything marked "hidden" in the HTML really stays hidden, even if a style says display: flex. */
[hidden] { display: none !important; }
/* The whole page: dark background, light text, the system font. */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}
/* Buttons and form fields use the same font and colour as the rest of the page. */
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }

/* Top bar */
/* The bar at the top stays stuck to the top while you scroll, with a blurred see-through background. */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 20px;
  background: rgba(13, 17, 23, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
/* "Vinted Sniper" name and the round logo (a white dot inside a teal circle). */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.logo { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle, #fff 0 28%, var(--accent) 30%); }
/* The "Live" indicator: grey dot when disconnected, pulsing green dot when connected. */
.live { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live.on .dot { background: var(--good); box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.6); animation: pulse 1.8s infinite; }
.live.on { color: var(--text); }
/* The pulse animation: a green ring that grows and fades out. */
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(63, 185, 80, 0); } 100% { box-shadow: 0 0 0 0 rgba(63, 185, 80, 0); } }
/* The numbers on the right of the top bar (alerts / new today / spent today). */
.stats { display: flex; gap: 22px; margin-left: auto; }
.stats div { display: flex; flex-direction: column; align-items: flex-end; }
.stats b { font-size: 16px; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.top-actions { display: flex; gap: 8px; }

/* Buttons & inputs */
/* Normal button: rounded, dark, with a thin border. */
button { cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); padding: 7px 12px; }
button:hover { border-color: #3a4658; }
/* "primary" = the main teal buttons (Start monitoring, Buy, Save). */
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
/* "ghost" = see-through buttons; "danger" = red text (Delete). */
button.ghost { background: transparent; }
button.danger { color: var(--bad); }
/* Greyed-out look for buttons that can't be clicked right now. */
button:disabled { opacity: .5; cursor: default; }
/* Text boxes and dropdowns: full width, dark, rounded. */
input, select {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--line); outline: none;
}
/* Teal border on the field you're typing in. */
input:focus, select:focus { border-color: var(--accent); }
/* Field labels sit above their field, in small grey text. */
label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 12px; }
/* Checkbox labels sit next to their checkbox instead. */
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
label.check input { width: auto; accent-color: var(--accent); }
label.small { font-size: 12px; }
/* Helper layouts: "stack" = things under each other, "row" = things side by side. */
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
/* Small grey help texts; orange for warnings. */
.hint { margin: -4px 0 0; color: var(--muted); font-size: 12px; }
.hint.warn { color: var(--warn); }
.muted { color: var(--muted); }
/* Red error text under the New alert form. */
.error { color: var(--bad); margin: 0; font-size: 12px; min-height: 1em; }
/* "No alerts yet." / "Nothing bought yet." / empty-feed messages. */
.empty { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.empty.big { text-align: center; padding: 80px 20px; }

/* Layout */
/* Two columns: a 340px sidebar on the left, the feed taking the rest of the width. */
.layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; padding: 20px; max-width: 1700px; margin: 0 auto; }
/* Let the main column shrink on small screens (otherwise a wide table pushes the page sideways). */
main { min-width: 0; }
/* The sidebar stays in place while the feed scrolls, and scrolls by itself if it's too tall. */
.sidebar { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 96px); overflow-y: auto; }
/* The boxes in the sidebar (New alert, Alerts, Purchases) and their headings. */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* Alerts */
/* Lists without bullet points. */
.alerts, .purchases { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
/* One alert box; paused alerts are faded. */
.alert { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.alert.off { opacity: .55; }
.alert-top { display: flex; align-items: center; gap: 8px; }
/* Long alert names are cut off with "…" instead of wrapping. */
.alert-name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-meta { color: var(--muted); font-size: 12px; margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }
.alert-meta .err { color: var(--bad); }
.alert-actions { display: flex; gap: 6px; margin-top: 8px; }
.alert-actions button { padding: 4px 9px; font-size: 12px; }
/* Small rounded label, e.g. the orange "auto-buy" tag. */
.pill { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--line); color: var(--muted); }
.pill.buy { background: rgba(210, 153, 34, .18); color: var(--warn); }
/* The on/off switch: a hidden checkbox drawn as a sliding pill with a white knob. */
.switch { position: relative; width: 34px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .15s; }
/* When switched on: teal background and the knob slides to the right. */
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }

/* Purchases */
/* One purchase entry, with its status coloured: green = bought, red = failed, teal = checkout opened. */
.purchase { font-size: 12px; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; background: var(--panel-2); border-radius: 8px; }
.purchase a { font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.purchase .bought { color: var(--good); }
.purchase .failed { color: var(--bad); }
.purchase .checkout_opened { color: var(--accent); }

/* Feed */
/* "Live feed" heading row with the filters on the right. */
.feed-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.feed-head h1 { font-size: 20px; margin: 0; }
.filters { display: flex; gap: 12px; align-items: center; }
.filters select { width: 200px; }
/* The grid of cards: as many columns as fit, each at least 200px wide. */
.feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
/* One listing card; it slides in from slightly above when it appears. */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  animation: drop .35s ease-out;
}
/* New listings get a teal glowing border. */
.card.fresh { border-color: rgba(9, 177, 186, .55); box-shadow: 0 0 0 1px rgba(9, 177, 186, .25); }
/* The "drop in" animation used by cards and pop-up messages. */
@keyframes drop { from { transform: translateY(-8px); opacity: 0; } }
/* The photo area keeps a 3:4 shape (like Vinted) and the photo fills it. */
.card .img { position: relative; aspect-ratio: 3 / 4; background: var(--panel-2); display: block; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* "NEW" badge top-left and "12s" age label bottom-right, on top of the photo. */
.badge { position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); }
.age { position: absolute; bottom: 8px; right: 8px; font-size: 11px; padding: 2px 7px; border-radius: 99px; background: rgba(0, 0, 0, .65); }
/* The text part of the card below the photo. */
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.price { font-size: 17px; font-weight: 700; }
.price small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { color: var(--accent); font-size: 11px; }
/* Buy and Open buttons side by side at the bottom of the card, equal width. */
.card .actions { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }
.card .actions button, .card .actions a { flex: 1; text-align: center; font-size: 13px; padding: 7px 0; border-radius: 8px; }
.card .actions a { border: 1px solid var(--line); text-decoration: none; }

/* Tabs (Live feed / Trends) */
/* A row of pill-shaped buttons; the active tab is teal. */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab { border-radius: 99px; padding: 7px 16px; font-weight: 600; }
.tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Trends */
/* Space between the trend boxes. */
.trend-panel { margin-bottom: 16px; }
/* Wide tables scroll sideways on small phones instead of breaking the page. */
.table-wrap { overflow-x: auto; }
.trend-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.trend-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; }
.trend-table td { padding: 8px; border-top: 1px solid var(--line); white-space: nowrap; }
/* Numbers line up neatly in columns. */
.trend-table td.num { font-variant-numeric: tabular-nums; }
.trend-table button { padding: 4px 9px; font-size: 12px; }
/* The "heat" bar behind the sold-percentage. */
.heatbar { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); margin-right: 6px; vertical-align: middle; }
/* Clickable keyword pills. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border-radius: 99px; padding: 5px 12px; font-size: 13px; }
.chip small { color: var(--muted); margin-left: 4px; }
/* The "Recently went fast" cards are links: no underline, and each text line on its own row. */
#trendExamples .card { text-decoration: none; }
#trendExamples .body > span { display: block; }

/* Dialog */
/* The Settings window, with a dark see-through layer behind it. */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin: 0; }
/* The bordered groups inside Settings (Monitoring / Notifications / Buying) and their titles. */
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; margin: 0; }
legend { color: var(--muted); padding: 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }

/* Toasts */
/* Pop-up messages, stacked in the bottom-right corner, with a coloured stripe on the left. */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 8px; max-width: 340px; animation: drop .25s; }
.toast.bad { border-left-color: var(--bad); }
.toast.good { border-left-color: var(--good); }

/* Phone and small-screen layout: everything in one column, smaller cards, compact top bar. */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .sidebar { position: static; max-height: none; }
  .stats { display: none; }
  /* On iPhone the top bar starts below the notch/status bar (env(...) is that height). */
  .topbar { gap: 8px; padding: max(10px, env(safe-area-inset-top)) 16px 10px; }
  /* Keep pop-up messages above the iPhone home bar. */
  .toasts { bottom: max(20px, env(safe-area-inset-bottom)); right: 16px; left: 16px; }
  .top-actions { margin-left: auto; gap: 6px; }
  .top-actions button { white-space: nowrap; padding: 6px 9px; }
  .brand { white-space: nowrap; }
  .live #liveText { display: none; }
  .feed { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .feed-head { flex-direction: column; align-items: flex-start; }
}

/* Advanced filters */
/* The fold-out "Advanced filters" section in the New alert form. */
details.adv, details.adv-countries { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
details summary { cursor: pointer; color: var(--text); font-size: 13px; }
details[open] > summary { margin-bottom: 10px; }
/* Big text box for keyword groups. */
textarea { width: 100%; padding: 8px 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); color: inherit; font: inherit; resize: vertical; }
textarea:focus { border-color: var(--accent); outline: none; }
/* Two fields side by side (stars + reviews). */
.row.two > label { flex: 1; min-width: 120px; }
/* The country checkboxes in a neat grid. */
.countries { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.country { font-size: 12px; }
/* The one-line summary of an alert's filters. */
.alert-filters { color: var(--accent); font-size: 12px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The Edit window can get tall: let it scroll. */
#alertDialog { max-height: calc(100vh - 32px); overflow-y: auto; }
