/* pages.css — şablonlar, taslaklar, ilanlar ve müşteri talepleri sayfaları.
   Sayfa çerçevesi, düğmeler, rozetler, .stats, .filters ve .panel-box style.css'ten gelir.
   Tek liste kalıbı: beyaz kart + çizgiyle ayrılan satırlar (satır başına ayrı kart yok). */

/* ---------- Ortak liste kartı ---------- */
.board-grid, .template-list, .customer-request-list {
  min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card);
}
.board-grid { overflow: visible; }
.template-list, .customer-request-list { overflow: hidden; }

/* ---------- İlanlar: araç çubuğu ---------- */
.board-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.listing-board .filters { flex: 0 1 auto; flex-wrap: wrap; max-width: 100%; }
.list-query {
  flex: 1 1 100%; min-width: 0; display: grid; gap: 8px; align-items: center;
  grid-template-columns: minmax(240px, 1fr) 180px 180px auto auto;
}
.list-query > * { min-width: 0; }
.list-query #listSearch {
  padding-left: 36px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23687a70' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 11px center / 18px;
}
.list-query select { color: var(--ink-2); }

.select-all-row {
  min-height: 36px; padding-left: 13px; display: inline-flex; align-items: center; gap: 10px; align-self: flex-start;
  color: var(--muted); font-size: var(--text-13); font-weight: 500; cursor: pointer;
}
.bulk-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px;
  background: var(--green-soft); border-radius: var(--radius-sm);
}
.bulk-tools strong { margin-right: auto; color: var(--green-text); font-size: var(--text-13); font-weight: 600; font-variant-numeric: tabular-nums; }
.bulk-tools select { width: auto; min-width: 180px; min-height: 36px; padding-block: 6px; font-size: var(--text-13); }

/* ---------- İlan pasaportu: fotoğraflı kart ızgarası ---------- */
#listGrid.board-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 16px; align-items: stretch;
  padding: 0; background: transparent; border: 0; border-radius: 0; box-shadow: none;
}
#listGrid > .empty { grid-column: 1 / -1; margin: 0; }
#listGrid > .lcard {
  position: relative; min-width: 0; display: grid; grid-template-rows: auto 1fr auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card);
  transition: transform var(--dur) var(--ease-out), border-color var(--dur-fast) ease;
}
/* Açık menü komşu kartların üstünde, yapışkan sayfa başlığının (z 5) altında kalsın.
   Kart taşmayı kesmez; fotoğraf köşesi ayrıca yuvarlanır. */
@media (min-width: 761px) {
  #listGrid > .lcard:has(.listing-menu[open]) { z-index: 4; }
}
/* Telefonda kaldırma yok: transform, alt sayfa menüsünün position: fixed konumunu karta hapsederdi. */
@media (hover: hover) and (min-width: 761px) {
  #listGrid > .lcard:hover { transform: translateY(-1px); border-color: var(--line-2); }
}
#listGrid > .lcard > .select-listing {
  position: absolute; z-index: 1; top: 12px; left: 12px; width: 20px; height: 20px; margin: 0;
  border-radius: 4px; box-shadow: 0 0 0 2px var(--surface); cursor: pointer;
}
#listGrid .lthumb {
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover;
  background: var(--surface-2); border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}
#listGrid .lthumb.ph { display: grid; place-items: center; color: var(--green-text); background: var(--green-tint); }
#listGrid .lthumb.ph svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
/* .lbody yalnız gruplayıcı: bilgi alanı ve işlem satırı kartın ızgara satırlarına yerleşir. */
#listGrid .lbody { display: contents; }
#listGrid .linfo { min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 16px; }
.ltitle { color: var(--ink); font-size: var(--text-15); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
#listGrid .ltitle { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
/* Başlık metni tam satır; rozetler bir alt satırda yan yana. */
#listGrid .ltitle::after { content: ""; order: 1; flex: 0 0 100%; height: 0; }
#listGrid .ltitle .sbadge, #listGrid .ltitle .quality-badge { order: 2; display: inline-flex; font-variant-numeric: tabular-nums; }
.lmeta { color: var(--muted); font-size: var(--text-13); line-height: 1.55; overflow-wrap: anywhere; }
.lmeta > span { display: inline-block; max-width: 100%; }
.lmeta > span:not(.lprice):not(:last-child)::after { content: "·"; margin: 0 7px; color: var(--muted); font-size: var(--text-13); font-weight: 400; }
.lmeta .lprice {
  display: block; margin-bottom: 2px; color: var(--ink); font-family: var(--font-display); font-size: 24px; font-weight: 400;
  line-height: 1.15; font-variant-numeric: tabular-nums;
}
.lmeta .lprice:empty { display: none; }
.quality-hints { color: var(--muted); font-size: var(--text-13); line-height: 1.5; overflow-wrap: anywhere; }
#listGrid .quality-hints { margin-top: auto; padding-top: 2px; }
.quality-hints > span:first-child { margin-right: 4px; color: var(--amber); font-weight: 500; }
.quality-hints em { font-style: normal; }
.quality-hints em + em::before { content: ", "; }
.quality-hints.ready > span:first-child { margin: 0; color: var(--green-text); }
.lactions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#listGrid .lactions { min-width: 0; padding: 10px 12px; border-top: 1px solid var(--line); }
#listGrid .lactions > .mini, #listGrid .listing-menu > summary { min-height: 36px; }
#listGrid .lactions > .mini.primary-mini { flex: 1 1 auto; }
/* Dar kartta üç düğme tek satıra sığmaz: ana işlem tam satır, "Gör" ve menü alt satırı paylaşır.
   Kapsayıcı sorgusu yalnız telefon dışında: düzen kapsaması telefondaki sabit alt menüyü karta hapsederdi. */
@media (min-width: 761px) { #listGrid .lactions { container: listing-actions / inline-size; } }
@container listing-actions (max-width: 329px) {
  #listGrid .lactions > .mini.primary-mini { flex: 1 1 100%; }
  #listGrid .lactions > .mini:not(.primary-mini), #listGrid .lactions > .listing-menu { flex: 1 1 auto; min-width: 0; }
  #listGrid .listing-menu > summary { width: 100%; justify-content: center; }
}

/* "Diğer işlemler" açılır menüsü */
.listing-menu { position: relative; }
.listing-menu > summary {
  min-height: 32px; display: inline-flex; align-items: center; padding: 0 28px 0 10px; color: var(--ink);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2344554c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center / 16px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); font-size: var(--text-13); font-weight: 500;
  white-space: nowrap; cursor: pointer; user-select: none; transition: background-color var(--dur-fast) ease;
}
.listing-menu > summary:hover, .listing-menu[open] > summary { background-color: var(--surface-2); }
.listing-menu > div {
  position: absolute; z-index: 5; right: 0; top: calc(100% + 6px); width: 220px; display: grid; gap: 6px; padding: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop);
}
/* İlan kartında menü kartın alt satırında durur: yukarı açılır, böylece hep kartın kendi alanında ve ekranda kalır. */
@media (min-width: 761px) { #listGrid .listing-menu > div { top: auto; bottom: calc(100% + 6px); } }
.listing-menu > div > .mini { width: 100%; justify-content: flex-start; }
.listing-menu > div > button.mini { background: transparent; border-color: transparent; }
.listing-menu > div > button.mini:hover { background: var(--surface-2); }
.listing-menu > div > button.mini.del:hover { background: var(--red-bg); }
.listing-menu > div > select.mini { justify-content: initial; }

/* ---------- Taslaklar ---------- */
.draft-toolbar { gap: 12px; }
#draftCount { font-variant-numeric: tabular-nums; }
.lcard.draft-card {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; column-gap: 14px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); transition: background var(--dur-fast) ease;
}
.lcard.draft-card:first-child { border-top-left-radius: calc(var(--radius) - 1px); border-top-right-radius: calc(var(--radius) - 1px); }
.lcard.draft-card:last-child { border-bottom: 0; border-bottom-left-radius: calc(var(--radius) - 1px); border-bottom-right-radius: calc(var(--radius) - 1px); }
.lcard.draft-card:hover { background: var(--surface-2); }
.draft-card .lbody { min-width: 0; }
.draft-icon {
  width: 40px; height: 40px; display: grid; place-items: center; color: var(--green-text); background: var(--green-soft);
  border-radius: var(--radius-sm); font-size: var(--text-18); line-height: 1;
}
.draft-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.draft-title { color: var(--ink); font-size: var(--text-15); font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.draft-details { margin-top: 2px; color: var(--muted); font-size: var(--text-13); line-height: 1.55; overflow-wrap: anywhere; }
.draft-details > span { display: inline-block; max-width: 100%; }
.draft-details > span:not(:last-child)::after { content: "·"; margin: 0 7px; color: var(--muted); font-size: var(--text-13); font-weight: 400; }
.draft-details .money { color: var(--ink); font-family: var(--font-display); font-size: 20px; font-weight: 400; line-height: 1.2; font-variant-numeric: tabular-nums; }
.draft-card .lactions { margin-top: 0; flex-wrap: nowrap; }
.draft-card .resume-draft { color: var(--green-text); background: var(--green-soft); border-color: transparent; }
.draft-card .resume-draft:hover { background: #d6e7dd; }

/* ---------- Şablonlar ---------- */
.template-board > .draft-lead { margin-top: -8px; }
.template-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); transition: background var(--dur-fast) ease;
}
.template-item:last-child { border-bottom: 0; }
.template-item:hover { background: var(--surface-2); }
.template-item > div:first-child { min-width: 0; display: grid; gap: 2px; }
.template-item b { color: var(--ink); font-size: var(--text-15); font-weight: 600; line-height: 1.45; }
.template-item small { overflow: hidden; color: var(--muted); font-size: var(--text-13); text-overflow: ellipsis; white-space: nowrap; }
.template-item > div:last-child { display: flex; gap: 8px; }
.template-board > .panel-box { gap: 10px; }
.template-board > .panel-box > .btn { align-self: flex-start; }

/* ---------- Müşteri talepleri ---------- */
.customer-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr); gap: 20px; align-items: start; }
.customer-list-pane { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.customer-list-pane > .section-title { margin: 0; }
.customer-request {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); transition: background var(--dur-fast) ease;
}
.customer-request:last-child { border-bottom: 0; }
.customer-request:hover { background: var(--surface-2); }
.customer-request > div:first-child, .customer-match > div { min-width: 0; display: grid; justify-items: start; gap: 2px; }
.customer-request b, .customer-match b { max-width: 100%; color: var(--ink); font-size: var(--text-15); font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.customer-request small, .customer-match small { max-width: 100%; color: var(--muted); font-size: var(--text-13); line-height: 1.5; overflow-wrap: anywhere; }
.customer-request em {
  display: inline; margin-top: 2px; color: var(--ink); font-family: var(--font-display); font-size: var(--text-18);
  font-style: normal; font-weight: 400; line-height: 1.25; font-variant-numeric: tabular-nums;
}
.customer-request > div:last-child { display: flex; gap: 8px; }
.customer-form { gap: 10px; }
.customer-form > .section-title { margin: 0 0 2px; }
.customer-form > .btn { margin-top: 4px; }

/* Eşleşme çekmecesi */
.workspace-overlay .customer-matches {
  position: fixed; z-index: 60; inset: 0 0 0 auto; width: min(560px, 100%); margin: 0; padding: 20px var(--gutter);
  overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-modal);
}
.customer-matches > .row-between { min-height: 44px; margin-bottom: 8px; }
.customer-matches > .row-between .section-title { margin: 0; font-size: var(--text-16); }
.customer-match {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.customer-match:last-child { border-bottom: 0; }
.customer-match > strong {
  width: 40px; height: 40px; display: grid; place-items: center; color: var(--green-text); background: var(--green-soft);
  border-radius: var(--radius-sm); font-size: var(--text-13); font-weight: 700; font-variant-numeric: tabular-nums;
}
.customer-match em { color: var(--ink); font-size: var(--text-14); font-style: normal; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: no-preference) {
  .workspace-overlay .customer-matches:not([hidden]) { animation: matchesIn var(--dur) var(--ease-out); }
  @keyframes matchesIn { from { opacity: 0; transform: translateX(16px); } }
}

/* ---------- Tablet ve dar masaüstü ---------- */
@media (max-width: 1100px) {
  .list-query { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto; }
  .list-query #listSearch { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .customer-layout { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Telefon: ≤760 px ---------- */
@media (max-width: 760px) {
  /* Telefonda liste erken başlasın: sayaçlar listenin altına iner (etkileşimsiz özet). */
  .listing-board > .stats { order: 1; }
  .listing-board .filters { flex: 1 1 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .listing-board .fbtn { min-width: 0; min-height: 40px; padding: 0 4px; white-space: normal; line-height: 1.2; }
  .list-query { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .list-query #listSearch { grid-column: 1 / -1; }
  .list-query .btn.compact { padding-inline: 8px; }
  .select-all-row { min-height: 44px; padding-left: 15px; }
  .bulk-tools strong { flex: 1 1 100%; }
  .bulk-tools select { flex: 1 1 0; min-width: 0; min-height: 40px; }

  #listGrid.board-grid { gap: 12px; }
  #listGrid .lactions > .mini, #listGrid .listing-menu > summary { min-height: 40px; }

  .listing-menu > div {
    position: fixed; inset: auto 12px calc(var(--mobile-nav-height) + 12px); width: auto; gap: 8px; padding: 12px;
    border-radius: var(--radius-lg); box-shadow: var(--shadow-modal);
  }
  .listing-menu > div > .mini { min-height: 44px; font-size: var(--text-14); }
  .listing-menu > div > select.mini { font-size: var(--text-16); }

  .lcard.draft-card { grid-template-columns: 40px minmax(0, 1fr); align-items: start; padding: 14px; }
  .draft-card .lactions { grid-column: 1 / -1; margin-top: 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .draft-card .lactions > .mini { min-height: 40px; }
  .draft-details > .money { display: block; }
  .draft-details > .money:not(:last-child)::after { content: none; }

  .template-item { padding: 12px 14px; gap: 12px; }
  .template-board > .draft-lead { display: none; }

  .customer-form { order: -1; }
  .customer-request { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 14px; }
  .customer-request > div:last-child > .mini { flex: 1 1 0; }
  .workspace-overlay .customer-matches { inset: 0 0 var(--mobile-nav-height) 0; width: 100%; padding: 12px 16px 20px; }
  .customer-matches > .row-between { padding-left: 52px; }
  .customer-match { grid-template-columns: 40px minmax(0, 1fr); }
  .customer-match > .mini { grid-column: 2; justify-self: start; }
}

/* Dar telefon: ilan kartı işlemleri iki satır (kapsayıcı sorgusunun telefondaki karşılığı). */
@media (max-width: 387px) {
  #listGrid .lactions > .mini.primary-mini { flex: 1 1 100%; }
  #listGrid .lactions > .mini:not(.primary-mini), #listGrid .lactions > .listing-menu { flex: 1 1 auto; min-width: 0; }
  #listGrid .listing-menu > summary { width: 100%; justify-content: center; }
}
