/* ============================
   Vinted Monitor – Vinted-inspired UI
   ============================ */

:root {
  --v-bg: #f5f5f5;
  --v-card: #ffffff;
  --v-text: #171717;
  --v-text2: #757575;
  --v-text3: #a0a0a0;
  --v-border: #e5e5e5;
  --v-accent: #09B1BA;
  --v-accent-hover: #078a91;
  --v-accent-light: #e0f7fa;
  --v-green: #43a047;
  --v-red: #e53935;
  --v-radius: 4px;
  --v-radius-lg: 8px;
  --v-shadow: 0 1px 4px rgba(0,0,0,.06);
  --v-shadow-hover: 0 4px 16px rgba(0,0,0,.1);
  --v-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---- Reset Pico conflicts ---- */

[data-theme="light"] {
  --pico-background-color: var(--v-bg);
  --pico-primary: var(--v-accent);
  --pico-primary-hover: var(--v-accent-hover);
}

/* ---- Global ---- */

html { height: 100%; }

body {
  font-family: var(--v-font);
  font-size: 14px;
  color: var(--v-text);
  background: var(--v-bg);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main.container {
  padding-top: 20px;
  padding-bottom: 40px;
  flex: 1;
}

h2 { font-size: 1.3em; font-weight: 700; margin-bottom: .5em; }
h3 { font-size: 1.1em; font-weight: 600; margin-bottom: .5em; }
h2 svg, h3 svg { vertical-align: -3px; margin-right: 4px; opacity: .7; }

/* ---- Header – full-width white bar ---- */

.site-header {
  background: var(--v-card);
  box-shadow: 0 1px 0 var(--v-border);
  position: sticky;
  top: 0;
  z-index: 200;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1em;
  font-weight: 700;
  color: var(--v-accent);
  text-decoration: none;
  letter-spacing: -.3px;
}
.brand:hover { color: var(--v-accent-hover); }

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.header-nav a {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--v-text2);
  font-size: .85em;
  font-weight: 500;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--v-radius);
  transition: background .15s, color .15s;
}
.header-nav a:hover {
  color: var(--v-accent);
  background: var(--v-accent-light);
}
.header-nav a svg { opacity: .6; }
.header-nav a:hover svg { opacity: 1; }

/* ---- Buttons (custom, override Pico) ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px;
  font-size: .88em;
  font-weight: 600;
  border-radius: var(--v-radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
  line-height: 1.4;
  white-space: nowrap;
  /* Reset Pico */
  --pico-font-weight: 600;
  margin-bottom: 0;
}

.btn-primary {
  background: var(--v-accent);
  color: #fff;
  border-color: var(--v-accent);
}
.btn-primary:hover {
  background: var(--v-accent-hover);
  border-color: var(--v-accent-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--v-card);
  color: var(--v-text2);
  border-color: var(--v-border);
}
.btn-secondary:hover {
  background: #f0f0f0;
  border-color: var(--v-text3);
  color: var(--v-text);
}

.btn-icon svg { flex-shrink: 0; }

.btn-icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  margin: 0;
  border-radius: var(--v-radius);
  border: 1px solid var(--v-border);
  background: var(--v-card);
  color: var(--v-text2);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-icon-only:hover {
  background: var(--v-accent-light);
  color: var(--v-accent);
  border-color: var(--v-accent);
}
.btn-icon-danger:hover {
  background: #ffebee;
  color: var(--v-red);
  border-color: var(--v-red);
}

.btn-sm { padding: 4px 12px; font-size: .82em; }
.btn-danger { color: var(--v-red); border-color: var(--v-red); }
.btn-danger:hover { background: var(--v-red); color: #fff; border-color: var(--v-red); }

/* ---- Page header (title + CTA) ---- */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.page-header h2 { margin: 0; }

/* ---- Toast ---- */

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  margin-bottom: 12px;
  border-radius: var(--v-radius);
  background: #e8f5e9;
  border: 1px solid var(--v-green);
  color: #2e7d32;
  font-size: .88em;
  animation: fadeIn .3s ease;
}
.toast svg { flex-shrink: 0; color: var(--v-green); }

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

/* ---- Badges ---- */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: .75em;
  font-weight: 600;
}
.badge-active { background: var(--v-green); color: #fff; }
.badge-paused { background: #bdbdbd; color: #fff; }

/* ==================================================
   ALERT LIST (dashboard cards)
   ================================================== */

.alert-list { display: flex; flex-direction: column; gap: 8px; }

.alert-card {
  display: flex;
  align-items: center;
  background: var(--v-card);
  border: 1px solid var(--v-border);
  border-radius: var(--v-radius-lg);
  box-shadow: var(--v-shadow);
  overflow: hidden;
  transition: box-shadow .15s;
}
.alert-card:hover { box-shadow: var(--v-shadow-hover); }

.alert-card-main {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
}

.alert-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.alert-card-icon.active { background: #e8f5e9; color: var(--v-green); }
.alert-card-icon.paused { background: #f5f5f5; color: var(--v-text3); }

.alert-card-info { flex: 1; min-width: 0; }
.alert-card-name {
  font-weight: 600;
  font-size: .95em;
  color: var(--v-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.alert-card-details {
  display: flex;
  gap: 8px;
  font-size: .8em;
  color: var(--v-text2);
  margin-top: 2px;
}
.alert-card-details span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alert-card-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.alert-card-matches { font-size: .78em; color: var(--v-text2); }

.alert-card-actions {
  display: flex;
  gap: 6px;
  padding: 14px 16px 14px 0;
  flex-shrink: 0;
}
.alert-card-actions form { margin: 0; }

/* ---- Empty state ---- */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--v-text2);
}
.empty-state svg { color: var(--v-border); margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; font-size: .95em; }

/* ==================================================
   FORM LAYOUT
   ================================================== */

.form-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.form-compact {
  background: var(--v-card);
  border: 1px solid var(--v-border);
  border-radius: var(--v-radius-lg);
  padding: 20px;
  box-shadow: var(--v-shadow);
}
.form-compact h3 { margin-bottom: 12px; }

.field { margin-bottom: 10px; }
.field > label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .78em;
  font-weight: 600;
  margin-bottom: 3px;
  color: var(--v-text2);
  text-transform: uppercase;
  letter-spacing: .3px;
}
.field > label svg { opacity: .5; }

.form-compact input[type="text"],
.form-compact input[type="number"] {
  padding: 8px 12px;
  font-size: .9em;
  margin-bottom: 0;
  border-radius: var(--v-radius);
  border: 1px solid var(--v-border);
  background: var(--v-card);
  transition: border-color .15s;
}
.form-compact input[type="text"]:focus,
.form-compact input[type="number"]:focus {
  border-color: var(--v-accent);
  outline: none;
  box-shadow: 0 0 0 2px var(--v-accent-light);
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  align-items: center;
}
.form-actions .btn { flex: 0 0 auto; }
.form-actions .btn-primary { flex: 1; }

/* ==================================================
   TREE PICKER
   ================================================== */

.tree-picker {
  border: 1px solid var(--v-border);
  border-radius: var(--v-radius);
  overflow: hidden;
  font-size: .88em;
  background: var(--v-card);
}

.tree-selected {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 0;
}
.tree-selected:not(:empty) {
  padding: 6px 8px;
  border-bottom: 1px solid var(--v-border);
  background: var(--v-accent-light);
}

.tree-tag {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--v-accent); color: #fff;
  padding: 2px 8px; border-radius: 12px;
  font-size: .8em; font-weight: 500;
}
.tree-tag button {
  background: none; border: none; color: #fff;
  cursor: pointer; font-size: 1em; padding: 0 2px;
  margin: 0; line-height: 1; opacity: .8; width: auto;
}
.tree-tag button:hover { opacity: 1; background: none; }

.tree-breadcrumb {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px; background: #fafafa;
  border-bottom: 1px solid var(--v-border);
  font-size: .82em; flex-wrap: wrap;
}
.tree-crumb { cursor: pointer; color: var(--v-accent); font-weight: 500; }
.tree-crumb:hover { text-decoration: underline; }
.tree-sep { color: var(--v-text3); font-size: .8em; }

.tree-list { max-height: 200px; overflow-y: auto; }

.tree-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px; border-bottom: 1px solid #f0f0f0;
  transition: background .1s;
}
.tree-item:last-child { border-bottom: none; }
.tree-item:hover { background: #f9f9f9; }
.tree-item.sel { background: var(--v-accent-light); }

.tree-check {
  display: flex; align-items: center; gap: 6px;
  flex: 1; cursor: pointer; padding: 7px 0;
  font-size: .88em; margin-bottom: 0;
}
.tree-check input[type="checkbox"] {
  width: 16px; height: 16px; margin: 0;
  cursor: pointer; accent-color: var(--v-accent);
}

.tree-drill {
  background: none; border: none;
  font-size: 1.3em; color: var(--v-text3);
  cursor: pointer; padding: 4px 6px;
  margin: 0; width: auto; line-height: 1;
}
.tree-drill:hover { color: var(--v-accent); background: none; }

.tree-loading, .tree-empty {
  padding: 14px; text-align: center;
  color: var(--v-text2); font-size: .85em;
}

/* ==================================================
   AUTOCOMPLETE
   ================================================== */

.autocomplete-field { position: relative; margin-bottom: 4px; }
.autocomplete-field .ac-input { margin-bottom: 4px; }

.ac-dropdown {
  display: none;
  position: absolute; z-index: 100;
  top: 100%; left: 0; right: 0;
  max-height: 280px; overflow-y: auto;
  background: var(--v-card);
  border: 1px solid var(--v-border);
  border-radius: var(--v-radius);
  box-shadow: var(--v-shadow-hover);
  margin-top: -2px;
}
.ac-dropdown.open { display: block; }

.ac-group {
  padding: 6px 12px 4px;
  font-size: .72em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--v-accent);
  background: #fafafa;
  border-top: 1px solid var(--v-border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.ac-group:first-child { border-top: none; }

.ac-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; cursor: pointer;
  font-size: .88em; transition: background .1s;
}
.ac-opt:hover { background: var(--v-accent-light); }
.ac-opt.ac-sel { background: var(--v-accent-light); font-weight: 600; }
.ac-ck { margin-left: auto; color: var(--v-accent); font-weight: 700; }
.ac-empty { padding: 10px 12px; color: var(--v-text2); font-style: italic; font-size: .85em; }

.ac-dot {
  display: inline-block; width: 16px; height: 16px;
  border-radius: 50%; border: 1px solid rgba(0,0,0,.12); flex-shrink: 0;
}

.ac-tags { display: flex; flex-wrap: wrap; gap: 4px; min-height: 2px; }

.ac-tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 12px;
  background: var(--v-accent); color: #fff;
  font-size: .8em; font-weight: 500;
}
.ac-tag button {
  background: none; border: none; color: #fff;
  cursor: pointer; font-size: 1em; padding: 0 2px;
  margin: 0; line-height: 1; opacity: .8; width: auto;
}
.ac-tag button:hover { opacity: 1; background: none; }

/* ==================================================
   PREVIEW PANEL – Vinted-style product grid
   ================================================== */

.preview-panel {
  background: var(--v-card);
  border: 1px solid var(--v-border);
  border-radius: var(--v-radius-lg);
  padding: 16px;
  box-shadow: var(--v-shadow);
}
.preview-panel h3 { margin-bottom: 10px; }
.preview-panel h3 span { font-weight: 400; color: var(--v-text2); font-size: .85em; }

.preview-loader { text-align: center; padding: 20px; font-size: .88em; }
.preview-empty  { text-align: center; padding: 30px 20px; color: var(--v-text2); font-size: .88em; }
.preview-none   { text-align: center; color: var(--v-text2); font-size: .88em; padding: 20px 0; }

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

/* Product card */
.pcard {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform .1s;
  background: transparent;
}
.pcard:hover { transform: translateY(-2px); }

.pcard-img {
  width: 100%;
  aspect-ratio: 4/5;
  overflow: hidden;
  background: #ebebeb;
  border-radius: var(--v-radius-lg);
  display: flex; align-items: center; justify-content: center;
  color: #ccc; font-size: .8em;
  position: relative;
}
.pcard-img img { width: 100%; height: 100%; object-fit: cover; }

.pcard-body { padding: 6px 2px; }

.pcard-price {
  font-size: .9em;
  font-weight: 700;
  color: var(--v-text);
  margin-bottom: 1px;
}

.pcard-meta {
  font-size: .72em;
  color: var(--v-text3);
  display: flex; gap: 4px;
}

.pcard-time {
  font-size: .72em;
  color: var(--v-accent);
  margin-top: 2px;
  font-weight: 500;
}

/* ==================================================
   DASHBOARD & DETAIL TABLES
   ================================================== */

figure { margin: 0; }

table {
  font-size: .88em;
  background: var(--v-card);
  border-radius: var(--v-radius-lg);
  overflow: hidden;
  box-shadow: var(--v-shadow);
}
table th {
  font-size: .78em; font-weight: 600;
  text-transform: uppercase; letter-spacing: .3px;
  color: var(--v-text2); background: #fafafa;
}
table td, table th { padding: 8px 12px; }

table.matches td img {
  width: 52px; height: 52px;
  object-fit: cover;
  border-radius: var(--v-radius);
}

/* ---- Actions ---- */

.actions-bar { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.actions-bar form { margin: 0; }

/* ---- Match cards (mobile) ---- */

.match-grid { display: none; }

.match-card {
  display: flex; gap: 10px; padding: 10px;
  border: 1px solid var(--v-border);
  border-radius: var(--v-radius-lg);
  margin-bottom: 8px;
  background: var(--v-card);
  text-decoration: none; color: inherit;
}
.match-card img {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: var(--v-radius);
  flex-shrink: 0;
}
.match-card-info { flex: 1; min-width: 0; }
.match-card-title { font-weight: 500; font-size: .88em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-card-price { font-weight: 700; color: var(--v-text); font-size: .92em; }
.match-card-meta  { font-size: .78em; color: var(--v-text2); }

/* ---- Detail page ---- */

.detail-card {
  background: var(--v-card);
  border: 1px solid var(--v-border);
  border-radius: var(--v-radius-lg);
  padding: 16px;
  box-shadow: var(--v-shadow);
  margin-bottom: 16px;
}

/* ==================================================
   SETTINGS PAGE
   ================================================== */

.form-compact select,
form select {
  padding: 8px 12px;
  font-size: .9em;
  border-radius: var(--v-radius);
  border: 1px solid var(--v-border);
}

/* ==================================================
   RESPONSIVE
   ================================================== */

@media (max-width: 768px) {
  .header-inner { padding: 0 12px; }
  .header-nav a span { display: none; }
  .form-layout { grid-template-columns: 1fr; }
  .preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
  }
  table.matches { display: none; }
  .match-grid { display: block; }
  figure { overflow-x: auto; }
  main.container { padding-left: 12px; padding-right: 12px; }
  .alert-card-main { padding: 12px; gap: 10px; }
  .alert-card-actions { padding-right: 12px; }
}

@media (max-width: 480px) {
  .row-2 { grid-template-columns: 1fr; }
  .form-compact { padding: 14px; }
  .preview-panel { padding: 14px; }
  .preview-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .btn { text-align: center; }
  .alert-card-details { display: none; }
}
