/* ==========================================================================
   OtoRadar — arayüz stilleri
   Tema: yol ve trafik levhası dili. Asfalt grisi zemin, levha sarısı vurgu,
   plaka mavisi ikincil renk. Başlıklar ve fiyatlar Barlow Semi Condensed
   (otoyol levhası harflerinden esinlenen bir yazı tipi).
   ========================================================================== */

:root {
  --asphalt: #1d2733;
  --asphalt-2: #2a3644;
  --concrete: #eef1f4;
  --surface: #ffffff;
  --line: #d5dbe1;
  --steel: #5e6b78;
  --signal: #f5b700;
  --signal-dark: #c99500;
  --plate-blue: #1f4fa3;
  --ok: #127a4b;
  --ok-bg: #e5f4ec;
  --alert: #b42318;
  --alert-bg: #fdecea;

  --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;

  --radius-s: 4px;
  --radius-m: 8px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--asphalt);
  background: var(--concrete);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--plate-blue); }
a:hover { color: var(--asphalt); }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 .5rem;
  letter-spacing: -.01em;
}
h1 { font-size: clamp(1.75rem, 3vw, 2.4rem); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1rem; }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--steel); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 2px;
}

/* ---------- Üst bar ---------- */

.topbar {
  background: var(--asphalt);
  color: #fff;
  border-bottom: 4px solid var(--signal);
}
.topbar__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  color: #fff;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: -.01em;
}
.brand:hover { color: #fff; }
.brand svg { width: 30px; height: 30px; flex: none; }

.nav {
  display: flex;
  gap: .25rem;
  margin-left: auto;
  align-items: center;
  flex-wrap: wrap;
}
.nav a {
  color: #d9e0e7;
  text-decoration: none;
  padding: .45rem .8rem;
  border-radius: var(--radius-s);
  font-weight: 500;
}
.nav a:hover { color: #fff; background: var(--asphalt-2); }
.nav a[aria-current="page"] { color: #fff; box-shadow: inset 0 -2px 0 var(--signal); border-radius: 0; }

/* ---------- Düzen ---------- */

.page {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.page-head p { margin: 0; color: var(--steel); }

.footer {
  border-top: 1px solid var(--line);
  color: var(--steel);
  font-size: .875rem;
}
.footer__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ---------- Butonlar ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  font: inherit;
  font-weight: 600;
  line-height: 1;
  padding: .7rem 1.1rem;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn--signal { background: var(--signal); color: var(--asphalt); }
.btn--signal:hover { background: var(--signal-dark); color: var(--asphalt); }
.btn--dark { background: var(--asphalt); color: #fff; }
.btn--dark:hover { background: var(--asphalt-2); color: #fff; }
.btn--ghost { background: transparent; color: var(--asphalt); border-color: var(--line); }
.btn--ghost:hover { background: var(--surface); color: var(--asphalt); border-color: var(--steel); }
.btn--danger { background: var(--alert); color: #fff; }
.btn--danger:hover { background: #8f1c13; color: #fff; }
.btn--sm { padding: .5rem .8rem; font-size: .9rem; }
.btn--block { width: 100%; }

/* ---------- Bildirimler ---------- */

.flash {
  background: var(--ok-bg);
  color: var(--ok);
  border-left: 4px solid var(--ok);
  padding: .8rem 1rem;
  border-radius: var(--radius-s);
  margin-bottom: 1.25rem;
  font-weight: 500;
}
.flash--error { background: var(--alert-bg); color: var(--alert); border-color: var(--alert); }

/* ---------- Plaka rozeti (imza öğe) ---------- */

.plate {
  display: inline-flex;
  align-items: stretch;
  border: 2px solid var(--asphalt);
  border-radius: 5px;
  background: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1;
  overflow: hidden;
  flex: none;
}
.plate__tr {
  background: var(--plate-blue);
  color: #fff;
  font-size: .6rem;
  padding: .25rem .22rem;
  display: flex;
  align-items: flex-end;
  letter-spacing: .02em;
}
.plate__code {
  padding: .3rem .45rem;
  font-size: 1.05rem;
  color: var(--asphalt);
  font-variant-numeric: tabular-nums;
}
.plate--lg .plate__tr { font-size: .75rem; padding: .35rem .3rem; }
.plate--lg .plate__code { font-size: 1.5rem; padding: .35rem .6rem; }

/* ---------- İlan listesi ---------- */

.browse {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1.75rem;
  align-items: start;
}

.filters {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 1.25rem;
  position: sticky;
  top: 1rem;
}
.filters h2 { font-size: 1.15rem; margin-bottom: 1rem; }

.field { margin-bottom: 1rem; }
.field > label,
.field > .field__label {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: .35rem;
}
.field__hint { font-size: .825rem; color: var(--steel); margin-top: .3rem; }
.field__error { font-size: .85rem; color: var(--alert); margin-top: .3rem; font-weight: 500; }

input[type="text"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--asphalt);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: .6rem .7rem;
}
input:hover, select:hover, textarea:hover { border-color: var(--steel); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(245, 183, 0, .55);
  outline-offset: 0;
  border-color: var(--asphalt);
}
.has-error input, .has-error select, .has-error textarea { border-color: var(--alert); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block;
  padding: .35rem .7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .9rem;
  cursor: pointer;
  background: #fff;
}
.chip input:checked + span { background: var(--asphalt); color: #fff; border-color: var(--asphalt); }
.chip input:focus-visible + span { outline: 3px solid var(--signal); outline-offset: 2px; }

.filters__actions { display: grid; gap: .5rem; margin-top: 1.25rem; }

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.results-head strong { font-family: var(--font-display); font-size: 1.25rem; }
.results-head select { width: auto; }

.listing-table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  overflow: hidden;
}
.listing-row,
.listing-table__head {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 70px 110px 90px 150px;
  gap: 1rem;
  align-items: center;
  padding: .9rem 1.1rem;
}
.listing-table__head {
  font-size: .8rem;
  font-weight: 600;
  color: var(--steel);
  background: #f7f9fb;
  border-bottom: 1px solid var(--line);
  padding-top: .6rem;
  padding-bottom: .6rem;
}
.listing-table__head .right { text-align: right; }
.listing-row {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.listing-row:last-child { border-bottom: 0; }
.listing-row:hover { background: #fffbea; color: inherit; }
.listing-row__title { font-weight: 600; font-size: 1.05rem; }
.listing-row__desc {
  color: var(--steel);
  font-size: .875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.listing-row__price {
  text-align: right;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}
.listing-row__price small { font-size: .8rem; font-weight: 600; color: var(--steel); }
.cell-label { display: none; }

.empty {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-m);
  padding: 3rem 1.5rem;
  text-align: center;
}
.empty p { color: var(--steel); }

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
}
.pagination__status { color: var(--steel); font-variant-numeric: tabular-nums; }
.pagination .btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }

/* ---------- İlan detayı ---------- */

.detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 2rem;
  align-items: start;
}
.crumbs { font-size: .9rem; margin-bottom: 1rem; }
.crumbs a { color: var(--steel); }

.detail__title { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.detail__title h1 { margin: 0; }
.detail__sub { color: var(--steel); margin: .35rem 0 1.5rem; }

.specs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}
.specs div { padding: 1rem 1.1rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.specs div:nth-child(3n) { border-right: 0; }
.specs div:nth-last-child(-n+3) { border-bottom: 0; }
.specs dt { font-size: .825rem; color: var(--steel); }
.specs dd { margin: .15rem 0 0; font-weight: 600; font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.prose { max-width: 68ch; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 1.25rem;
}
.panel + .panel { margin-top: 1rem; }

.price-panel { border-top: 6px solid var(--signal); }
.price-panel__label { color: var(--steel); font-size: .9rem; margin-bottom: .2rem; }
.price-panel__price {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.4rem;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  margin-bottom: 1rem;
}
.price-panel__price small { font-size: 1.1rem; color: var(--steel); }
.price-panel__actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: 1rem; }

.verdict {
  display: inline-block;
  font-weight: 600;
  font-size: .85rem;
  padding: .25rem .6rem;
  border-radius: 999px;
  margin-bottom: .75rem;
}
.verdict--ok { background: var(--ok-bg); color: var(--ok); }
.verdict--alert { background: var(--alert-bg); color: var(--alert); }
.verdict--neutral { background: var(--concrete); color: var(--steel); }

/* Fiyat cetveli: ortada ortalama, gri bant ±2σ (normal aralık) */
.meter { margin: 1.25rem 0 .5rem; }
.meter__track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--alert-bg) 0 16.66%, #dfe5ea 16.66% 83.33%, var(--alert-bg) 83.33% 100%);
}
.meter__mean {
  position: absolute; top: -4px; bottom: -4px; left: 50%;
  width: 2px; background: var(--steel);
}
.meter__marker {
  position: absolute; top: 50%;
  width: 20px; height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  background: var(--asphalt);
  border: 3px solid var(--signal);
}
.meter__scale {
  display: flex; justify-content: space-between;
  font-size: .75rem; color: var(--steel); margin-top: .4rem;
}
.facts { margin: 1rem 0 0; display: grid; gap: .35rem; font-size: .925rem; }
.facts div { display: flex; justify-content: space-between; gap: 1rem; }
.facts dt { color: var(--steel); }
.facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.similar { margin-top: 2.5rem; }

/* ---------- Form ---------- */

.form-layout { max-width: 820px; }
.form-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 1.25rem 1.25rem .25rem;
  margin: 0 0 1rem;
}
.form-section legend {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0 .35rem;
  margin-left: -.35rem;
}
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1rem; }
.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-actions { display: flex; gap: .5rem; margin-top: 1.25rem; }

.confirm {
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 6px solid var(--alert);
  border-radius: var(--radius-m);
  padding: 1.5rem;
}

/* ---------- İstatistik ---------- */

.figures {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.figures dt { color: var(--steel); font-size: .9rem; }
.figures dd {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.9rem;
  font-variant-numeric: tabular-nums;
}

.stats-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th {
  text-align: left; font-size: .8rem; color: var(--steel); font-weight: 600;
  padding: .5rem .6rem; border-bottom: 1px solid var(--line);
}
table.data td { padding: .55rem .6rem; border-bottom: 1px solid var(--concrete); }
table.data .right { text-align: right; }
.chart-box { position: relative; height: 320px; }
.fuel-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.fuel-list li { display: grid; grid-template-columns: 90px 1fr 50px; gap: .75rem; align-items: center; }
.fuel-bar { height: 8px; background: var(--concrete); border-radius: 999px; overflow: hidden; }
.fuel-bar span { display: block; height: 100%; background: var(--plate-blue); }

.sql-note {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
  background: var(--asphalt);
  color: #e6ebf0;
  padding: 1rem;
  border-radius: var(--radius-s);
  overflow-x: auto;
  margin: 1rem 0 0;
  white-space: pre;
}

/* ---------- Asistan ---------- */

.chat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 1.75rem;
  align-items: start;
}
.chat__log {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 1.25rem;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.msg { max-width: 85%; }
.msg--user {
  align-self: flex-end;
  background: var(--asphalt);
  color: #fff;
  padding: .7rem 1rem;
  border-radius: 14px 14px 4px 14px;
}
.msg--bot {
  align-self: flex-start;
  background: var(--concrete);
  padding: .8rem 1rem;
  border-radius: 14px 14px 14px 4px;
}
.msg--bot p:last-child, .msg--bot ul:last-child { margin-bottom: 0; }
.msg--bot ul { padding-left: 1.2rem; margin: 0 0 .75rem; }
.msg__source { font-size: .78rem; font-weight: 600; margin-bottom: .35rem; display: flex; align-items: center; gap: .35rem; }
.msg__source::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.src-local { color: var(--plate-blue); }
.src-gemini { color: #8a6500; }
.src-error { color: var(--alert); }

.chat__empty { margin: auto; text-align: center; color: var(--steel); max-width: 40ch; }
.chat__form { display: flex; gap: .5rem; margin-top: 1rem; }
.chat__form input { flex: 1; }

.examples { display: grid; gap: .5rem; }
.example {
  text-align: left;
  font: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: .65rem .8rem;
  cursor: pointer;
  color: var(--asphalt);
}
.example:hover { border-color: var(--asphalt); }
.how { font-size: .9rem; color: var(--steel); }
.how dt { font-weight: 600; color: var(--asphalt); margin-top: .75rem; }
.how dd { margin: .15rem 0 0; }

/* ---------- Mobil ---------- */

@media (max-width: 960px) {
  .browse, .detail, .chat, .stats-grid { grid-template-columns: minmax(0, 1fr); }
  .filters { position: static; }
  .listing-table__head { display: none; }
  .listing-row {
    grid-template-columns: 56px minmax(0, 1fr) auto;
    grid-template-areas:
      "plate title price"
      "plate meta  meta";
    row-gap: .35rem;
  }
  .listing-row > .plate { grid-area: plate; align-self: start; }
  .listing-row__main { grid-area: title; }
  .listing-row__price { grid-area: price; }
  .listing-row__meta { grid-area: meta; display: flex; gap: .9rem; flex-wrap: wrap; font-size: .9rem; color: var(--steel); }
  .cell-label { display: inline; }
}
@media (min-width: 961px) {
  .listing-row__meta { display: contents; }
}
@media (max-width: 640px) {
  .topbar__inner { flex-wrap: wrap; gap: .5rem; }
  .nav { margin-left: 0; width: 100%; }
  .specs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .specs div { border-right: 1px solid var(--line) !important; border-bottom: 1px solid var(--line) !important; }
  .form-grid, .form-grid--2 { grid-template-columns: 1fr; }
  .msg { max-width: 100%; }
  .chat__form { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Ek düzeltmeler */
.chip { position: relative; }
.fieldset-reset { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
.fieldset-reset > legend { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; padding: 0; }
.nav a.btn--signal { color: var(--asphalt); margin-left: .5rem; }
.nav a.btn--signal:hover { background: var(--signal-dark); color: var(--asphalt); }
.stats-grid { align-items: start; }
.stats-grid > .panel + .panel { margin-top: 0; }
.verdict { border-radius: 6px; }
@media (max-width: 640px) {
  .pagination { flex-wrap: wrap; }
  .pagination__status { order: -1; width: 100%; text-align: center; }
  .pagination .btn { flex: 1; }
}
