:root {
  --serbia-red: #c6363c;
  --serbia-blue: #0c4076;
  --serbia-white: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  --radius: 10px;
  --kiosk-max: 1300px;
  --gap: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    linear-gradient(
      to bottom,
      var(--serbia-red) 0%,
      var(--serbia-red) 33.333%,
      var(--serbia-blue) 33.333%,
      var(--serbia-blue) 66.666%,
      var(--serbia-white) 66.666%,
      var(--serbia-white) 100%
    );
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.below-header {
  /* Keep the category bar aligned with .kiosk outer width */
  margin: 10px 0 0;
  padding: 0;
}

.category-strip {
  max-width: var(--kiosk-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  padding: 12px var(--gap);
  align-items: stretch;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.category-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(17, 24, 39, 0.08);
  text-decoration: none;
  text-align: center;
  min-height: 74px;
}

.category-item:hover {
  text-decoration: none;
  border-color: rgba(12, 64, 118, 0.25);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.category-item-active {
  border-color: rgba(12, 64, 118, 0.45);
  box-shadow: 0 1px 0 rgba(12, 64, 118, 0.10);
}

.category-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: block;
  max-width: 34px;
  max-height: 34px;
  object-fit: contain;
}

/* Safety: some SVGs have intrinsic width/height that can blow up layout */
.category-strip img.category-icon {
  width: 34px !important;
  height: 34px !important;
  max-width: 34px !important;
  max-height: 34px !important;
}

.category-label {
  font-weight: 650;
  font-size: 13px;
  line-height: 1.05;
  white-space: normal;
  color: var(--text);
  display: block;
  /* Reserve space for 2 lines so 1-word labels don't sit lower than 2-word labels */
  min-height: 2.1em;
}

@media (max-width: 900px) {
  .category-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
  }
}

/* Small mobile: make category tiles more compact */
@media (max-width: 520px) {
  .category-strip {
    gap: 8px;
    padding: 10px;
    border-radius: 12px;
  }
  .category-item {
    min-height: 62px;
    padding: 8px 6px;
    gap: 5px;
    border-radius: 10px;
  }
  .category-icon,
  .category-strip img.category-icon {
    width: 28px !important;
    height: 28px !important;
    max-width: 28px !important;
    max-height: 28px !important;
    flex: 0 0 28px;
  }
  .category-label {
    font-size: 12px;
    min-height: 2.0em;
  }
}

/* Wide desktop: try to fit all 14 categories into a single row */
@media (min-width: 1400px) {
  .category-strip {
    grid-template-columns: repeat(14, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 12px;
  }
  .category-item {
    padding: 8px 6px;
    min-height: 70px;
  }
  .category-label {
    font-size: 12px;
  }
}

.header-inner {
  max-width: var(--kiosk-max);
  margin: 0 auto;
  /* Keep header height stable while making logo slightly larger */
  padding: 8px var(--gap);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--gap);
  align-items: center;
}

.logo {
  font-weight: 800;
  letter-spacing: -0.3px;
  font-size: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.logo-strong { color: var(--serbia-red); }
.logo-light { color: var(--serbia-blue); }

.search {
  display: flex;
  gap: 10px;
  align-items: center;
}
.search input[type="search"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  outline: none;
}
.search button {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(17, 24, 39, 0.16);
  background: #fff;
  cursor: pointer;
}
.search button:hover { background: rgba(17, 24, 39, 0.06); }

.nav {
  display: flex;
  gap: 14px;
  align-items: center;
  white-space: nowrap;
}
.nav-link-with-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  color: #fff;
  background: var(--serbia-red);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(12, 64, 118, 0.16);
}
.nav .btn {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--serbia-blue);
  color: #fff;
}
.nav .btn:hover { background: #0a3562; text-decoration: none; }

.kiosk {
  max-width: var(--kiosk-max);
  margin: 18px auto 28px;
  padding: 18px var(--gap);
  background: rgba(255, 255, 255, 0.98);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: calc(100vh - 140px);
}

.site-footer {
  padding: 18px var(--gap);
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--border);
}
.footer-inner {
  max-width: var(--kiosk-max);
  margin: 0 auto;
  color: rgba(17, 24, 39, 0.75);
}
.footer-hr {
  margin: 0 0 14px;
  display: none;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding: 6px 0 12px;
}
.footer-title {
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-weight: 800;
  color: rgba(17, 24, 39, 0.82);
  margin-bottom: 10px;
}
.footer-links {
  display: grid;
  gap: 8px;
}
.footer-links a {
  color: rgba(17, 24, 39, 0.85);
  text-decoration: none;
}
.footer-links a:hover {
  text-decoration: underline;
  color: var(--serbia-blue);
}
.footer-bottom {
  border-top: 1px solid rgba(17, 24, 39, 0.08);
  padding-top: 12px;
  margin-top: 10px;
}

@media (max-width: 820px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

.flash {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: grid;
  gap: 10px;
}
.flash-item {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}

.h1 {
  font-size: 24px;
  line-height: 1.2;
}
.muted { color: var(--muted); }
.hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--gap);
}

.cats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}
.pill {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  text-decoration: none;
}
.pill-active {
  border-color: rgba(12, 64, 118, 0.45);
  background: rgba(12, 64, 118, 0.06);
}

.filters {
  display: grid;
  /* Default filters: keep everything in one row on desktop when possible (7 fields + button). */
  grid-template-columns:
    minmax(0, 1.4fr)  /* Pretraga / Tip nekretnine */
    minmax(0, 1fr)    /* Grad */
    minmax(0, 0.8fr)  /* Min cena */
    minmax(0, 0.8fr)  /* Max cena */
    minmax(0, 0.75fr) /* Valuta */
    minmax(0, 0.75fr) /* Sort */
    auto;             /* Primeni */
  gap: 10px;
  margin: 10px 0 16px;
}
.filters > * { min-width: 0; }
.filters.filters-vehicle {
  /* Vehicle filters have more fields; keep them uniform and let them wrap naturally. */
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.filters.filters-vehicle button {
  width: 100%;
  justify-self: stretch;
}
.filters input,
.filters select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  min-width: 0;
}
.filters button {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(17, 24, 39, 0.16);
  background: #fff;
  cursor: pointer;
}
.filters button:hover { background: rgba(17, 24, 39, 0.06); }

.listing-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 900px) {
  .listing-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  /* Grid cards: image on top, square, less whitespace */
  .listing-card {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .listing-thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    /* In "image on top" layout, keep bottom corners square so it blends into the body */
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .listing-thumb-placeholder {
    min-height: 0;
  }
  .listing-body {
    padding: 8px 12px 12px;
  }
  .listing-title {
    margin-bottom: 2px;
  }
}

@media (min-width: 1200px) {
  .listing-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.listing-card {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
  text-decoration: none;
  position: relative;
  isolation: isolate;
  transition: transform 160ms ease, border-color 160ms ease;
  will-change: transform;
  backface-visibility: hidden;
  transform-origin: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

/* Dark "trobojka" hover overlay (behind content) */
.listing-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
  z-index: 0;
  background: linear-gradient(
    to bottom,
    rgba(198, 54, 60, 0.16) 0%,
    rgba(198, 54, 60, 0.16) 33.33%,
    rgba(12, 64, 118, 0.16) 33.33%,
    rgba(12, 64, 118, 0.16) 66.66%,
    rgba(0, 0, 0, 0.07) 66.66%,
    rgba(0, 0, 0, 0.07) 100%
  );
}
.listing-card {
  /* Keep a stable transform layer to reduce text rasterization blur on hover (Windows/Chrome). */
  transform: translate3d(0, 0, 0);
  will-change: transform;
  backface-visibility: hidden;
}
.listing-card:hover {
  border-color: rgba(198, 54, 60, 0.32);
  transform: translate3d(0, -2px, 0);
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.12);
  z-index: 2;
}
.listing-card:hover::before { opacity: 1; }

/* Ensure main content stays above the overlay */
.listing-thumb,
.listing-body {
  position: relative;
  z-index: 1;
}

/* NOTE:
   Avoid forcing text-stroke during transform hover; it can leave text slightly soft after hover on some browsers. */

@media (prefers-reduced-motion: reduce) {
  .listing-card { transition: none; }
  .listing-card:hover { transform: none; }
}

/* Save (trobojka) button */
.listing-save {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  background: linear-gradient(
    to bottom,
    #c6363c 0%,
    #c6363c 33.33%,
    #0c4076 33.33%,
    #0c4076 66.66%,
    #ffffff 66.66%,
    #ffffff 100%
  );
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  z-index: 5;
  user-select: none;
  touch-action: manipulation;
  /* Default: subtle/bled while NOT saved */
  opacity: 0.45;
  filter: saturate(0.7) contrast(0.95);
  transition:
    opacity 160ms ease,
    filter 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}
.listing-save:hover { transform: translateY(-1px); }
.listing-save:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(12, 64, 118, 0.24), 0 2px 8px rgba(0, 0, 0, 0.12);
}
.listing-save.is-saved {
  opacity: 1;
  filter: none;
  border-color: rgba(12, 64, 118, 0.55);
  box-shadow: 0 0 0 3px rgba(198, 54, 60, 0.18), 0 2px 8px rgba(0, 0, 0, 0.12);
}
.listing-save.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

/* Mini tooltip (no JS): uses existing aria-label text */
.listing-save::after {
  content: attr(aria-label);
  position: absolute;
  top: 50%;
  right: calc(100% + 8px);
  transform: translateY(-50%);
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  padding: 6px 8px;
  border-radius: 10px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

/* Tooltip visibility is controlled by JS so it doesn't "stick" on hover */
.listing-save.is-tip-visible::after { opacity: 1; }

@media (hover: none) {
  .listing-save::after { display: none; }
}
.listing-thumb {
  background: rgba(17, 24, 39, 0.04);
  position: relative;
  overflow: hidden;
  /* In horizontal cards (image left), also round the inner/right edge of the image */
  border-radius: var(--radius);
  display: block;
  height: 100%;
}
.listing-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.listing-fuel-badge{
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: #0b1b33;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(17, 24, 39, 0.16);
  backdrop-filter: blur(6px);
  line-height: 1;
  white-space: nowrap;
}
.listing-fuel-badge-text{
  display: inline-block;
  transform: scale(1.1);
  transform-origin: center;
}
.listing-thumb-placeholder {
  height: 100%;
  min-height: 100px;
  display: grid;
  place-items: center;
  color: rgba(17, 24, 39, 0.55);
  font-size: 14px;
}
.listing-body { padding: 6px 12px 10px 0; }
.listing-title { font-weight: 750; font-size: 23px; line-height: 1.15; margin-bottom: 1px; color: var(--text); }
.listing-date {
  font-size: 13px;
  line-height: 1.1;
  font-weight: 550;
  color: var(--muted);
  margin: 0 0 6px;
}
.listing-info {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto;
  column-gap: 12px;
  row-gap: 3px;
  align-items: start;
  margin-top: 0;
}
.listing-lines { display: contents; }
.listing-line { color: rgba(17, 24, 39, 0.78); font-size: 20px; line-height: 1.15; font-weight: 600; }
.listing-line.listing-category {
  color: rgba(17, 24, 39, 0.78);
  font-weight: 600;
  grid-column: 1 / -1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.listing-line.listing-city { grid-column: 1; }
.listing-line.listing-condition { grid-column: 1; }
.listing-price {
  font-weight: 800;
  font-size: 20px;
  color: var(--serbia-blue);
  margin: 0;
  white-space: nowrap;
  grid-column: 2;
  grid-row: 3;
  align-self: end;
}

.vehicle-fields[hidden] { display: none !important; }
/* Ensure HTML `hidden` always wins, even against layout classes like .form-grid */
[hidden] { display: none !important; }
.vehicle-fields { margin-top: 6px; }
.realestate-fields[hidden] { display: none !important; }
.realestate-fields { margin-top: 6px; }

/* Nested grids inside the 2-col vehicle grid should span the full width */
#vehicle-extra-fields,
#vehicle-auto-only-fields {
  grid-column: 1 / -1;
}

.listing-delete { margin-top: 10px; }
.listing-delete .btn-secondary { padding: 8px 12px; }

.pagination {
  margin-top: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
}
.pagination-pages { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.pagination-page {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: rgba(17, 24, 39, 0.92);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  min-width: 34px;
  text-align: center;
}
.pagination-page:hover { text-decoration: none; border-color: rgba(17, 24, 39, 0.24); }
.pagination-page.is-active {
  background: var(--serbia-blue);
  color: #fff;
  border-color: var(--serbia-blue);
}
.pagination-ellipsis { color: rgba(17, 24, 39, 0.6); padding: 0 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--serbia-blue);
  color: #fff;
  text-decoration: none;
  border: 1px solid transparent; /* keep same height as .btn-secondary (which has 1px border) */
  cursor: pointer;
  line-height: 1;
  font: inherit;
  box-sizing: border-box;
  white-space: nowrap;
}
.btn:hover { background: #0a3562; text-decoration: none; }
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  text-decoration: none;
  color: rgba(17, 24, 39, 0.92);
  cursor: pointer;
  line-height: 1;
  font: inherit;
  box-sizing: border-box;
  white-space: nowrap;
}
.btn-secondary:hover { background: rgba(17, 24, 39, 0.06); text-decoration: none; }

/* Auth pages */
.auth-panel {
  max-width: 520px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 18px 18px 20px;
}
.auth-form { margin-top: 10px; }
.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.auth-actions .btn,
.auth-actions .btn-secondary {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
/* Keep primary/secondary auth buttons pixel-perfect equal width (secondary has 1px border) */
.auth-actions .btn { border: 1px solid transparent; }
@media (max-width: 520px) {
  .auth-actions { grid-template-columns: 1fr; }
}

/* Profile dashboard */
.profile-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  align-items: start;
}
.profile-nav {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 8px;
}
.profile-nav-item {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: rgba(17, 24, 39, 0.86);
  font-weight: 650;
  border: 1px solid transparent;
  background: rgba(17, 24, 39, 0.03);
}
.profile-nav-item:hover {
  background: rgba(17, 24, 39, 0.06);
  text-decoration: none;
}
.profile-nav-item.is-active {
  background: rgba(12, 64, 118, 0.08);
  border-color: rgba(12, 64, 118, 0.24);
  color: var(--serbia-blue);
}
.profile-nav-logout { margin: 0; }
.profile-nav-btn {
  width: 100%;
  text-align: left;
  cursor: pointer;
  border: 1px solid rgba(198, 54, 60, 0.2);
  background: rgba(198, 54, 60, 0.06);
  color: var(--serbia-red);
}
.profile-nav-btn:hover { background: rgba(198, 54, 60, 0.09); }

.profile-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 18px 18px 20px;
}

/* Profile: keep ads list readable (not squeezed into half-width grid, not stretched edge-to-edge) */
.profile-panel .listing-grid {
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .profile-panel .listing-grid {
    grid-template-columns: repeat(2, minmax(0, 420px));
    justify-content: start;
  }
}
.profile-header { margin: 0 0 14px; }
.profile-h1 { margin: 0; font-size: 28px; line-height: 1.15; }
.profile-sub { margin-top: 6px; }
.profile-h2 { margin: 14px 0 10px; font-size: 18px; }

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.profile-stat {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.02);
  text-decoration: none;
}
.profile-stat:hover { border-color: rgba(17, 24, 39, 0.18); text-decoration: none; }
.profile-stat-label { color: var(--muted); font-weight: 650; font-size: 13px; }
.profile-stat-value { font-size: 24px; font-weight: 850; color: rgba(17, 24, 39, 0.9); letter-spacing: -0.01em; }

@media (max-width: 900px) {
  .profile-layout { grid-template-columns: 1fr; }
  .profile-nav {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px;
    scroll-snap-type: x mandatory;
  }
  .profile-nav-item { flex: 0 0 auto; scroll-snap-align: start; white-space: nowrap; }
  .profile-nav-btn { text-align: center; }
  .profile-stats { grid-template-columns: 1fr; }
}

.form {
  display: grid;
  gap: 12px;
  max-width: 820px;
}
.form-row { display: grid; gap: 6px; }
.form-label { font-weight: 600; }
.form-ad .form-label { font-size: 13.5px; letter-spacing: 0.1px; }
.form input[type="text"],
.form input[type="number"],
.form input[type="email"],
.form input[type="password"],
.form input[type="tel"],
.form input[type="search"],
.form textarea,
.form select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  box-sizing: border-box;
  line-height: 1.2;
}
.form-ad input[type="text"],
.form-ad input[type="number"],
.form-ad input[type="email"],
.form-ad input[type="password"],
.form-ad input[type="tel"],
.form-ad input[type="search"],
.form-ad textarea,
.form-ad select {
  font-size: 15px;
}
.form-ad textarea { line-height: 1.55; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.images-preview {
  margin-top: 10px;
  display: none;
  /* Keep thumbnails small even when only 1-2 images are selected */
  grid-auto-flow: column;
  grid-auto-columns: 92px;
  grid-template-columns: none;
  gap: 10px;
  padding: 10px;
  border: 1px dashed rgba(0, 0, 0, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: start;
}

.images-preview-item {
  position: relative;
  display: grid;
  grid-template-rows: 72px auto auto;
  gap: 6px;
  align-items: start;
  width: 92px;
}

.images-preview-thumb {
  width: 100%;
  height: 72px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  overflow: hidden;
  display: grid;
  place-items: center;
  position: relative;
}

.images-preview-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 3px 6px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  font-weight: 700;
  color: #0c4076;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(12, 64, 118, 0.22);
}

.images-preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.images-preview-move {
  height: 26px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.96);
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
}
.images-preview-move:hover {
  border-color: rgba(12, 64, 118, 0.35);
}
.images-preview-move:disabled {
  opacity: 0.45;
  cursor: default;
}

.images-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.images-preview-meta {
  font-size: 12px;
  line-height: 1.1;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.images-preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  background: rgba(255, 255, 255, 0.98);
  cursor: pointer;
  font-size: 18px;
  line-height: 22px;
  padding: 0;
  display: grid;
  place-items: center;
}

.images-preview-remove:hover {
  border-color: rgba(12, 64, 118, 0.35);
}

.listing-detail {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
}
.listing-gallery {
  display: grid;
  gap: 12px;
}
.listing-side {
  align-self: start;
  position: sticky;
  top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  padding: 14px;
}

/* When the user starts scrolling, push the sticky sidebar below the sticky header
   (JS will set --listing-side-top/--listing-side-maxh based on the real header height). */
body.has-scrolled .listing-side {
  top: var(--listing-side-top, 14px);
  max-height: var(--listing-side-maxh, none);
  overflow: auto;
}
.listing-side-head {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(17, 24, 39, 0.08);
  margin-bottom: 12px;
}
.listing-side-section { margin: 12px 0; }
.listing-side-section:last-child { margin-bottom: 0; }
.listing-desc-below-gallery {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px 14px;
}
.listing-desc-below-gallery:empty { display: none; }

.listing-contact {
  border: 1px solid rgba(17, 24, 39, 0.10);
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.02);
  padding: 12px 14px;
}
.listing-contact-title {
  font-weight: 800;
  font-size: 15px;
  margin: 0 0 10px;
}
.listing-contact-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  align-items: start;
  padding: 6px 0;
  border-top: 1px solid rgba(17, 24, 39, 0.08);
}
.listing-contact-row:first-of-type { border-top: 0; padding-top: 0; }
.listing-contact-label { color: rgba(17, 24, 39, 0.72); font-weight: 650; font-size: 14px; }
.listing-contact-value { font-weight: 700; color: rgba(17, 24, 39, 0.92); font-size: 15.5px; }
.listing-contact-phone { color: var(--serbia-blue); text-decoration: none; font-weight: 850; font-size: 17.5px; }
.listing-contact-phone:hover { text-decoration: underline; }
.listing-contact-actions { margin-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; }

.listing-basic {
  border: 1px solid rgba(17, 24, 39, 0.10);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  padding: 12px 14px;
}
.listing-basic-title {
  font-weight: 800;
  font-size: 14px;
  margin: 0 0 10px;
}
.listing-basic-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}
.listing-basic-label {
  font-size: 12px;
  font-weight: 650;
  color: rgba(17, 24, 39, 0.62);
  margin-bottom: 3px;
}
.listing-basic-value {
  font-weight: 750;
  color: rgba(17, 24, 39, 0.92);
}
.listing-carousel { display: grid; gap: 10px; }
.listing-carousel-stage {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.04);
  overflow: hidden;
  outline: none;
  aspect-ratio: 4 / 3;
  max-height: 72vh;
  cursor: default;
}
.listing-carousel-stage:focus {
  box-shadow: 0 0 0 3px rgba(12, 64, 118, 0.22);
}
.listing-carousel-slide {
  width: 100%;
  height: 100%;
  max-height: none;
  display: none;
  object-fit: contain;
  background: #fff;
  grid-area: 1 / 1;
}
.listing-carousel-slide.is-active { display: block; }

/* Kad je samo 1 slika: nema "praznog" letterbox prostora */
.listing-carousel[data-count="1"] .listing-carousel-stage{
  aspect-ratio: auto;
  max-height: none;
}

.listing-carousel[data-count="1"] .listing-carousel-slide{
  height: auto;
  max-height: 72vh;
}

.listing-carousel[data-count="1"] .listing-carousel-btn,
.listing-carousel[data-count="1"] .listing-carousel-counter{
  display: none !important;
}

/* Fullscreen lightbox for ad images */
.listing-lightbox{
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(17, 24, 39, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.listing-lightbox.is-open{ display: flex; }
.listing-lightbox-inner{
  width: min(1200px, 96vw);
  height: min(92vh, 820px);
  display: grid;
  /* Important: allow the stage row to actually shrink within the fixed-height dialog */
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 10px;
}
.listing-lightbox-stage{
  position: relative;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  place-items: center;
  cursor: default;
  /* Allow the stage to shrink in a CSS grid container (prevents overflow clipping quirks) */
  min-height: 0;
}

.listing-lightbox-img{
  /* Lightbox main image: background-image (no cropping, always full image visible) */
  width: 100%;
  height: 100%;
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.35);

  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;

  user-select: none;
}

.listing-lightbox-nav{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(0,0,0,0.18);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 30px;
  line-height: 1;
  z-index: 2;
}
.listing-lightbox-nav:hover{ background: rgba(0,0,0,0.28); }
.listing-lightbox-prev{ left: 12px; }
.listing-lightbox-next{ right: 12px; }

.listing-lightbox-sep{
  height: 1px;
  background: rgba(255,255,255,0.18);
}

.listing-lightbox-thumbs{
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 84px;
  gap: 8px;
  overflow-x: auto;
  padding: 0 2px 2px;
}
.listing-lightbox-thumb{
  height: 64px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  padding: 0;
  cursor: pointer;
}
.listing-lightbox-thumb.is-active{ border-color: rgba(255,255,255,0.52); }
.listing-lightbox-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.listing-lightbox-close{
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 10001;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.listing-lightbox-close:hover{ background: rgba(255,255,255,0.18); }


.listing-carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 26px;
  line-height: 1;
  z-index: 2;
}
.listing-carousel-btn:hover { border-color: rgba(12, 64, 118, 0.35); }
.listing-carousel-prev { left: 10px; }
.listing-carousel-next { right: 10px; }

.listing-carousel-counter {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(17, 24, 39, 0.72);
  color: #fff;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 999px;
  z-index: 2;
}

.listing-carousel-thumbs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 76px;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.listing-carousel-thumb {
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 10px;
  background: #fff;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  height: 56px;
}
.listing-carousel-thumb.is-active { border-color: rgba(12, 64, 118, 0.55); }
.listing-carousel-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.listing-gallery-empty {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.04);
  min-height: 260px;
  display: grid;
  place-items: center;
  color: rgba(17, 24, 39, 0.55);
}
.listing-price-big {
  font-weight: 800;
  font-size: 22px;
  color: var(--serbia-blue);
}
.listing-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.listing-specs { margin: 2px 0; }
.listing-specs-title {
  font-weight: 800;
  font-size: 14px;
  margin: 0 0 8px;
}
.spec-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.9);
}
.spec-table th,
.spec-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.2;
  text-align: left;
  vertical-align: top;
}
.spec-table th {
  width: 46%;
  color: rgba(17, 24, 39, 0.72);
  font-weight: 650;
  background: rgba(17, 24, 39, 0.02);
}
.spec-table tr:last-child th,
.spec-table tr:last-child td { border-bottom: 0; }

.msg-list {
  display: grid;
  gap: 10px;
}
.msg-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  text-decoration: none;
}
.msg-item:hover { border-color: rgba(17, 24, 39, 0.18); }
.msg-title { font-weight: 700; margin-bottom: 6px; }
.msg-preview { font-size: 13px; }

.msg-threlisting-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}
.msg-bubble-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}
.msg-bubble {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fff;
  max-width: 760px;
}
.msg-me {
  justify-self: end;
  background: rgba(12, 64, 118, 0.04);
  border-color: rgba(12, 64, 118, 0.18);
}
.msg-them { justify-self: start; }
.msg-bubble-meta { font-size: 12px; margin-bottom: 6px; }
.msg-form textarea { width: 100%; }

@media (max-width: 900px) {
  .header-inner { grid-template-columns: 1fr; }
  .nav { justify-content: space-between; flex-wrap: wrap; }
  .filters { grid-template-columns: 1fr 1fr; }
  .listing-card { grid-template-columns: 120px 1fr; }
  .listing-body { padding: 12px; }
  .listing-detail { grid-template-columns: 1fr; }
  .listing-side {
    position: static;
    box-shadow: var(--shadow);
  }
  .form-grid { grid-template-columns: 1fr; }
}


