/* ============================================================= */
/* Витрина товаров — Jyväskylä                                    */
/* ============================================================= */

:root {
  --primary: #2c5f7c;
  --primary-light: #3a8fb7;
  --primary-dark: #1e4259;
  --accent: #e67e22;
  --accent-light: #f0a04b;
  --bg: #ffffff;
  --bg-alt: #f5f7f9;
  --bg-dark: #1e2a35;
  --text: #2c3e50;
  --text-light: #8095a7;
  --text-inv: #ffffff;
  --border: #e3e8ed;
  --success: #27ae60;
  --success-bg: #d4edda;
  --warning: #f39c12;
  --warning-bg: #fff3cd;
  --muted: #95a5a6;
  --muted-bg: #e2e3e5;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --max-w: 1100px;
  --top-bar-h: 52px;
  --filter-bar-h: 48px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: inherit; }

/* Language switching */
body[data-lang="en"] .lang-fi,
body[data-lang="en"] .lang-ru { display: none !important; }
body[data-lang="fi"] .lang-en,
body[data-lang="fi"] .lang-ru { display: none !important; }
body[data-lang="ru"] .lang-en,
body[data-lang="ru"] .lang-fi { display: none !important; }

/* ---- Top bar ---- */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-dark);
  color: var(--text-inv);
  height: var(--top-bar-h);
}

.top-bar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  color: var(--text-inv);
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-title:hover { color: var(--accent-light); }

.site-location {
  font-weight: 400;
  font-size: 0.85rem;
  opacity: 0.7;
}

.lang-buttons { display: flex; gap: 4px; }

.lang-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--text-inv);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.15s;
}

.lang-btn:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.5);
}

.lang-btn.active {
  background: var(--text-inv);
  color: var(--primary-dark);
  border-color: var(--text-inv);
}

/* ---- Filter bar ---- */
.filter-bar {
  position: sticky;
  top: var(--top-bar-h);
  z-index: 90;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.filter-bar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-pill {
  flex-shrink: 0;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.filter-pill:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}

.filter-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-inv);
}

/* Mobile dropdown (hidden on desktop) */
.filter-dropdown {
  display: none;
  position: relative;
  width: 100%;
}

.filter-dropdown-toggle {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.filter-dropdown-toggle[aria-expanded="true"] {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-dropdown-arrow {
  transition: transform 0.2s;
  font-size: 0.9rem;
}

.filter-dropdown-toggle[aria-expanded="true"] .filter-dropdown-arrow {
  transform: rotate(180deg);
}

.filter-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 95;
  max-height: 60vh;
  overflow-y: auto;
}

.filter-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 0.9rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.filter-dropdown-item:last-child { border-bottom: none; }
.filter-dropdown-item:hover { background: var(--bg-alt); }

.filter-dropdown-item.active {
  background: var(--primary);
  color: var(--text-inv);
}

.filter-dropdown-item .pill-count {
  margin-left: auto;
}

.pill-count {
  font-size: 0.72rem;
  opacity: 0.7;
}

.pill-count::before { content: '('; }
.pill-count::after { content: ')'; }
.pill-count:empty { display: none; }

/* ---- Status filter ---- */
.status-filter {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.status-filter-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 6px 16px;
  display: flex;
  align-items: center;
}

.status-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-light);
  cursor: pointer;
}

.status-check input[type="checkbox"] {
  accent-color: var(--primary);
}

/* ---- Loading ---- */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-light);
}

.loading.hidden { display: none; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Main ---- */
#app {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
  min-height: 50vh;
}

/* ---- Catalog: Category sections ---- */
.category-section {
  margin: 24px 0;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.category-icon {
  font-size: 1.2rem;
}

.category-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.category-count {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-left: auto;
}

/* ---- Item cards grid ---- */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* ---- Item card ---- */
.item-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.2s;
  cursor: pointer;
  position: relative;
}

.item-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.item-card.sold {
  opacity: 0.65;
}

.item-card-photo {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg-alt);
  overflow: hidden;
}

.item-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.item-card:hover .item-card-photo img {
  transform: scale(1.05);
}

.item-card-photo .no-photo {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--border);
  background: var(--bg-alt);
}

/* Status badge on card */
.status-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.on-sale {
  background: var(--success);
  color: #fff;
}

.status-badge.reserved {
  background: var(--warning);
  color: #fff;
}

.status-badge.sold-badge {
  background: var(--muted);
  color: #fff;
}

/* Price badge on card */
.price-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--accent);
  color: #fff;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 700;
}

.price-badge.free {
  background: var(--success);
}

.item-card-info {
  padding: 12px 14px;
}

.item-card-name {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
  color: var(--text);
}

.item-card-brand {
  font-size: 0.78rem;
  color: var(--text-light);
}

/* ---- Item detail page ---- */
.item-detail {
  padding: 20px 0 40px;
}

.item-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 16px;
  padding: 6px 0;
  transition: color 0.15s;
}

.item-back:hover { color: var(--primary-light); }

.item-hero {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
  background: var(--bg-alt);
}

.item-hero img {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
  cursor: pointer;
  background: var(--bg-alt);
}

.item-hero .price-tag {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: var(--accent);
  color: #fff;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
}

.item-hero .price-tag.free {
  background: var(--success);
}

.item-hero .status-tag {
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.item-hero .status-tag.reserved {
  background: var(--warning);
  color: #fff;
}

.item-hero .status-tag.sold-tag {
  background: var(--muted);
  color: #fff;
}

.item-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.item-brand-model {
  font-size: 0.95rem;
  color: var(--text-light);
  margin-bottom: 16px;
}

.item-section {
  margin-bottom: 20px;
}

.item-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 8px;
}

.item-description {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text);
}

.item-condition {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.item-source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--primary);
  transition: all 0.15s;
}

.item-source-link:hover {
  background: var(--primary);
  color: var(--text-inv);
  border-color: var(--primary);
}

.item-ref {
  font-size: 0.72rem;
  color: var(--text-light);
  margin-top: 20px;
  opacity: 0.6;
}

/* Item gallery thumbnails */
.item-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

.item-gallery-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}

.item-gallery-thumb:hover {
  border-color: var(--primary-light);
}

.item-gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Share button */
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text);
  transition: all 0.15s;
}

.share-btn:hover {
  background: var(--primary);
  color: var(--text-inv);
  border-color: var(--primary);
}

.share-btn.copied {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

/* Item detail actions row */
.item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* ---- Contact card in item detail ---- */
.item-contact {
  background: var(--bg-alt);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 24px;
}

.item-contact h3 {
  font-size: 1rem;
  margin-bottom: 12px;
}

.item-contact .contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---- Footer ---- */
.site-footer {
  background: var(--bg-dark);
  color: var(--text-inv);
  margin-top: 40px;
  padding: 32px 16px;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}

.contact-card h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.contact-name {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.contact-location {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-bottom: 14px;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  transition: all 0.2s;
  color: var(--text-inv);
}

.email-link { background: var(--primary); }
.email-link:hover { background: var(--primary-light); color: #fff; }
.phone-link { background: #27ae60; }
.phone-link:hover { background: #2ecc71; color: #fff; }
.whatsapp-link { background: #25d366; }
.whatsapp-link:hover { background: #2ecc71; color: #fff; }

/* ---- Lightbox ---- */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.lightbox.active {
  display: flex;
}

.lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.92);
}

.lightbox-content {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  z-index: 2;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 1.6rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255,255,255,0.3);
}

.lightbox-close { top: 16px; right: 16px; }
.lightbox-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 16px; top: 50%; transform: translateY(-50%); }

.lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
}

/* ---- No results ---- */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.no-results-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  :root {
    --top-bar-h: 48px;
  }

  .site-title { font-size: 0.9rem; }
  .site-location { display: none; }

  .items-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }

  .item-card-info { padding: 8px 10px; }
  .item-card-name { font-size: 0.82rem; }

  .item-title { font-size: 1.2rem; }
  .item-hero img { max-height: 280px; }

  .item-gallery {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  }

  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
}

@media (min-width: 481px) and (max-width: 768px) {
  .items-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile: show dropdown, hide pills */
@media (max-width: 768px) {
  .filter-bar-inner { display: none; }
  .filter-dropdown { display: block; padding: 8px 16px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .items-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1025px) {
  .items-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---- Print ---- */
@media print {
  .top-bar, .filter-bar, .status-filter, .lightbox, .lang-buttons,
  .share-btn, .item-back { display: none !important; }

  .item-card { break-inside: avoid; }
  body { font-size: 12px; }
}
