/* ============================================
   ADS — LISTA OGŁOSZEŃ (premium)
============================================ */

.market-list,
.ad-list{
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.market-list-heading{
  text-align: center;
  margin: 30px 0;
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: 0;
}

@media (max-width: 768px){
  .market-list-heading{
    margin: 15px 0 20px;
    font-size: 1.4rem;
  }
}

.market-pager{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.market-pager-link{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-color);
  text-decoration: none;
  font-size: .92rem;
  font-weight: 600;
}

.market-pager-link:hover{
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.market-pager-link.is-current{
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: #fff;
}

.market-pager-ellipsis{
  color: var(--text-muted);
  padding: 0 4px;
}

.market-list-item{
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  box-sizing: border-box;
  overflow: visible;
  align-items: stretch;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.market-list-item:hover{
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(0,0,0,.08);
  border-color: var(--accent-color);
}

/* Widok kart listy ogłoszeń (spójny z kartami zgłoszeń) */
.ads-list-page .market-list.market-list--list{
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ads-list-page .market-list.market-list--cards{
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.ads-list-page .market-list.market-list--cards .market-list-card{
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .06);
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-list-card-cover{
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 0;
  overflow: hidden;
  border: 0;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-list-card-cover-image{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-list-card-body{
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 11px 11px;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-list-card-head{
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-list-card-title{
  width: 100%;
  max-width: 100%;
  font-size: .97rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  overflow: hidden;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-price{
  width: 100%;
  max-width: 100%;
  margin-top: 4px;
  text-align: left;
  white-space: normal;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-price-value{
  font-size: .92rem;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-price-note,
.ads-list-page .market-list.market-list--cards .market-list-card .market-price-na{
  font-size: .76rem;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-dates{
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: .78rem;
  line-height: 1.35;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-list-card-location{
  color: var(--text-muted);
  font-weight: 500;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-divider{
  margin-top: 1px;
  margin-bottom: 1px;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-bottom{
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-kind-status{
  width: 100%;
  flex-wrap: wrap;
  row-gap: 4px;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-kind,
.ads-list-page .market-list.market-list--cards .market-list-card .market-status{
  white-space: normal;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-actions-links{
  width: 100%;
  margin-top: 12px;
  align-self: flex-start;
  row-gap: 4px;
  column-gap: 10px;
  font-size: .84rem;
}

.ads-list-page .market-list.market-list--cards .market-list-card .market-action-link{
  font-size: .84rem;
}

.ads-list-page .market-filter-submit{
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 7px 16px;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.ads-list-page .market-filter-submit.is-active{
  background: var(--text-color);
  color: var(--card-bg);
  border-color: transparent;
}

.ads-list-page .market-filter-submit:hover{
  border-color: var(--text-color);
  color: var(--text-color);
}

.ads-list-page .market-list-view-toggle{
  margin: 8px 0 14px;
}

.ads-list-page .market-list-view-toggle .market-applications-toggle-button{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

@media (max-width: 1100px){
  .ads-list-page .market-list.market-list--cards{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px){
  .ads-list-page .market-list.market-list--cards{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px){
  .ads-list-page .market-list.market-list--cards{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .ads-list-page .market-list.market-list--cards .market-list-card .market-list-card-body{
    padding: 9px 10px 10px;
    gap: 7px;
  }

  .ads-list-page .market-list.market-list--cards .market-list-card .market-list-card-title{
    font-size: .9rem;
  }
}

.market-list-item-expired{ opacity: .75; }
.market-list-item-expired:hover{ opacity: .9; }

/* zabezpieczenie przed wypychaniem */
.market-list-item > *,
.market-main > *,
.ad-main > *{
  min-width: 0;
}

/* THUMB */
.market-thumb,
.ad-thumb{
  width: 200px;
  aspect-ratio: 16 / 9;   /* zawsze poziome */
  height: auto;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0,0,0,.03);
  border: 1px solid var(--border-color);
  display: block;
}

.market-thumb img,
.ad-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.market-thumb-placeholder,
.ad-thumb-placeholder{
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  color: var(--text-muted);
}

/* MAIN */
.market-main,
.ad-main{
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* TOP: title + price */
.market-top,
.ad-top{
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 12px;
}

.market-title,
.ad-title{
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-color);

  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.market-highlight-badge{
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #f1c66a;
  background: #fff3cd;
  color: #8a5b00;
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: middle;
}

html[data-theme="dark"] .market-highlight-badge,
body.dark-mode .market-highlight-badge{
  background: rgba(241, 198, 106, .16);
  border-color: rgba(241, 198, 106, .38);
  color: #f5d58a;
}

/* price = podobna „waga" jak tytuł */
.market-price,
.ad-price{
  text-align: right;
  white-space: nowrap;
}

.market-price-value,
.ad-price-value{
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}

.market-price-note,
.ad-price-note{
  display: block;
  margin-top: 2px;
  font-size: .85rem;
  opacity: .75;
}

.market-price-na,
.ad-price-na{
  font-size: .95rem;
  opacity: .7;
  font-style: italic;
}

/* MID: category + dates */
.market-mid,
.ad-mid{
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.market-category,
.ad-category{
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text-color);
  opacity: .9;

  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.market-dates,
.ad-dates{
  font-size: .92rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

/* divider: linia od „pod zdjęciem do końca" */
.market-divider,
.ad-divider{
  height: 1px;
  background: rgba(0,0,0,.08);
  margin-top: 6px;
  margin-bottom: 6px;
}

/* BOTTOM: kind/status left + actions right */
.market-bottom,
.ad-bottom{
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 12px;
}

.market-kind-status,
.ad-kind-status{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.market-kind,
.ad-kind{
  font-weight: 700;
  font-size: .95rem;
  opacity: .92;
  white-space: nowrap;
}

.market-status,
.ad-status{
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
}

.market-status-active,
.ad-status-active   { color:#16a34a; font-weight:600; }
.market-status-expired,
.ad-status-expired  { color:#f59e0b; font-weight:600; }
.market-status-inactive,
.ad-status-inactive { color:#6b7280; font-weight:600; }

/* =========================
   ADS — LIMIT PLANU / KREDYTY (LIGHT)
========================= */

.card-message.card-muted {
  background: rgba(0,0,0,0.015);              /* prawie neutralne */
  border: 1px solid rgba(220,38,38,0.35);     /* delikatna czerwona ramka */
  border-left: 4px solid #dc2626;              /* akcent */
  padding: 14px 16px;
  border-radius: 12px;

  font-size: 13px;
  color: var(--text-color);
}

/* Tytuł */
.card-message.card-muted h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #dc2626;
}

/* Zwykły tekst */
.card-message.card-muted p {
  margin: 0;
  line-height: 1.4;
  color: var(--text-color);
}

/* LICZBY / KREDYTY — NIE czerwone */
.card-message.card-muted strong {
  color: #111827;        /* mocniejszy czarny */
  font-weight: 700;
}

/* opis pomocniczy */
.card-message.card-muted .text-muted-small {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* =========================
   ADS — LIMIT PLANU / KREDYTY (DARK)
========================= */

html[data-theme="dark"] .card-message.card-muted,
body.dark-mode .card-message.card-muted {
  background: rgba(220,38,38,0.08);
  border-color: rgba(220,38,38,0.45);
  border-left-color: rgba(220,38,38,0.8);
}

/* ZWYKŁY TEKST — normalny kolor tekstu */
html[data-theme="dark"] .card-message.card-muted p,
body.dark-mode .card-message.card-muted p {
  color: var(--text-color);
}

html[data-theme="dark"] .card-message.card-muted strong,
body.dark-mode .card-message.card-muted strong {
  color: #cbd5e1;
  font-weight: 600;
}

/* TYTUŁ */
html[data-theme="dark"] .card-message.card-muted h3,
body.dark-mode .card-message.card-muted h3 {
  color: #f87171;
}


/* ACTION LINKS (zamiast buttonów) */
.market-actions-links,
.ad-actions-links{
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  white-space: normal;
}

.market-action-link,
.ad-action-link{
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;

  color: var(--accent-color);
  text-decoration: none;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;

  opacity: .9;
  transition: opacity .18s ease, color .18s ease, background-color .18s ease;
}

.market-action-link:hover,
.ad-action-link:hover{
  opacity: .82;
  text-decoration: none;
}

.market-action-link--danger,
.ad-action-link--danger{
  color: var(--danger-color);
}

.market-action-link--muted,
.ad-action-link--muted{
  color: var(--text-muted);
}

/* form delete: niewidoczny wrapper */
.ad-delete-form{
  display: none;
}

/* =========================
   TABLET
========================= */
@media (min-width: 769px) and (max-width: 1024px){
  .market-main,
  .ad-main{
    min-width: 0;
  }

  .market-list-item{
    grid-template-columns: 170px minmax(0, 1fr);
  }

  .ads-list-page .market-list.market-list--cards .market-list-card .market-list-card-title{
    font-size: .95rem;
  }

  .market-thumb,
  .ad-thumb{
    width: 100%;
    aspect-ratio: 16 / 9;
  }

  .market-top,
  .ad-top{
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .market-title,
  .ad-title,
  .market-category,
  .ad-category,
  .market-kind,
  .ad-kind,
  .market-price-value,
  .ad-price-value{
    font-size: 1.15rem;
  }

  .market-title,
  .ad-title,
  .market-category,
  .ad-category{
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .market-price,
  .ad-price{
    text-align: left;
    white-space: normal;
  }

  .market-bottom,
  .ad-bottom{
    grid-template-columns: 1fr;
    align-items: start;
  }

  .market-dates,
  .ad-dates{
    gap: 6px 10px;
  }

  .market-actions-links,
  .ad-actions-links{
    flex-wrap: wrap;
    gap: 10px 14px;
    white-space: normal;
  }
}

/* =========================
   MOBILE
========================= */
@media (max-width: 768px){
  .market-list-item{
    display: grid;
    grid-template-columns: 1fr;  /* <-- 1 kolumna */
    gap: 12px;
    padding: 12px 14px;
    align-items: start;
  }

  .ads-list-page .market-list.market-list--cards .market-list-card .market-list-card-cover{
    border-radius: 0;
  }

  .market-thumb,
  .ad-thumb{
    width: 100%;
    height: auto;               /* <-- wraca normalnie */
    aspect-ratio: 4 / 3;
  }

  .market-thumb img,
  .ad-thumb img{
    height: 100%;
    width: 100%;
    object-fit: cover;
  }

  .market-top,
  .ad-top{
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .market-title,
  .ad-title{ white-space: normal; }
  .market-price,
  .ad-price{ text-align: left; }

  .market-divider,
  .ad-divider{ margin-top: 2px; margin-bottom: 2px; }

  .market-bottom,
  .ad-bottom{
    grid-template-columns: 1fr;
    align-items: start;
    gap: 10px;
  }

  .market-actions-links,
  .ad-actions-links{
    flex-wrap: wrap;
    gap: 10px 14px;
    white-space: normal;
  }

  .ads-list-page .market-list.market-list--cards .market-list-card .market-list-card-title{
    font-size: .9rem;
  }
}

.market-filters,
.ad-filters {
  width: 100%;
  margin-bottom: 36px;
}

.market-filters .market-filters-flex,
.market-filters .ad-filters-flex,
.ad-filters .market-filters-flex,
.ad-filters .ad-filters-flex {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  flex-wrap: nowrap; /* desktop: w jednej linii */
}

/* SEARCH: ma rosnąć i brać wolne miejsce */
.market-filters .market-filter-search,
.market-filters .ad-filter-search,
.ad-filters .market-filter-search,
.ad-filters .ad-filter-search {
  flex: 1 1 420px;
  min-width: 220px;
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
}

/* LOCATION: prosty filtr użytkowy, nie SEO */
.market-filters .market-filter-location,
.market-filters .ad-filter-location,
.ad-filters .market-filter-location,
.ad-filters .ad-filter-location {
  flex: 0 1 240px;
  min-width: 180px;
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
}

/* SORT: desktop tylko na szerokość treści */
.market-filters .market-filter-sort,
.market-filters .ad-filter-sort,
.ad-filters .market-filter-sort,
.ad-filters .ad-filter-sort {
  flex: 0 0 auto;
  width: auto;
  min-width: max-content;
  max-width: 320px;
  box-sizing: border-box;
}

/* BUTTON: stały, nie łamie tekstu */
.market-filters .btn-primary-small,
.ad-filters .btn-primary-small {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* zabezpieczenie przed globalnym width:100% */
.market-filters input,
.market-filters select,
.market-filters button,
.ad-filters input,
.ad-filters select,
.ad-filters button {
  max-width: 100%;
}

/* =========================
   TABLET: pozwól złamać
========================= */
@media (max-width: 900px) {
  .market-filters .market-filters-flex,
  .market-filters .ad-filters-flex,
  .ad-filters .market-filters-flex,
  .ad-filters .ad-filters-flex {
    flex-wrap: wrap;
  }
}

/* =========================
   MOBILE: układ 2-rzędowy:
   - rząd 1: search 100%
   - rząd 2: sort (szeroki) + button (na końcu)
========================= */
@media (max-width: 768px) {
  .market-filters .market-filters-flex,
  .market-filters .ad-filters-flex,
  .ad-filters .market-filters-flex,
  .ad-filters .ad-filters-flex {
    display: grid;
    grid-template-columns: 1fr auto; /* sort rośnie, button dopasowany */
    gap: 10px;
    align-items: center;
  }

  /* search pełna szerokość */
  .market-filters .market-filter-search,
  .market-filters .ad-filter-search,
  .ad-filters .market-filter-search,
  .ad-filters .ad-filter-search {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .market-filters .market-filter-location,
  .market-filters .ad-filter-location,
  .ad-filters .market-filter-location,
  .ad-filters .ad-filter-location {
    grid-column: 1 / -1;
    min-width: 0;
    width: 100%;
    max-width: none;
  }

  /* sort ma być SZERSZY na mobile */
  .market-filters .market-filter-sort,
  .market-filters .ad-filter-sort,
  .ad-filters .market-filter-sort,
  .ad-filters .ad-filter-sort {
    grid-column: 1 / 2;
    width: 100% !important;
    max-width: none;
    min-width: 0;
  }

  /* button na końcu */
  .market-filters .btn-primary-small,
  .ad-filters .btn-primary-small {
    grid-column: 2 / 3;
    justify-self: end;
  }
}

/* =========================
   ADS — LOAD MORE
========================= */
.market-load-more-wrap,
.ad-load-more-wrap{
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.market-load-more-note,
.ad-load-more-note{
  font-size: .92rem;
  color: var(--text-muted);
  text-align: center;
}

.market-load-more-btn,
.ad-load-more-btn{
  text-decoration: none;
}

.market-load-more-btn:hover,
.ad-load-more-btn:hover{
  text-decoration: none;
}
