/* Design tokens — from opet-asistan-tasarim/tokens/tokens.json.
   Only literal values from the token pack live here; no ad-hoc colors. */
:root {
  /* color.brand */
  --brand-blue: #134FAE;
  --brand-blue-dark: #0F3F8C;
  --brand-navy: #162133;
  --brand-orange: #ED7C23;
  --brand-yellow: #FFD300;
  --brand-amber: #FFB71B;

  /* color.surface */
  --surface-app: #FFFFFF;
  --surface-chat: #F3F5F9;
  --surface-card: #FFFFFF;
  --surface-badge: #EAF1FB;
  --surface-badge-muted: #F1F4F9;
  --surface-stamp: #FAFBFD;
  --surface-context-pill: #E9EDF4;

  /* color.border */
  --border-default: #DFE4EC;
  --border-subtle: #EDF1F6;
  --border-hairline: #F1F4F9;
  --border-bubble: #E5EAF2;
  --border-chip: #CFDAEA;
  --border-cta-alt: #C3D2E8;

  /* color.text */
  --text-primary: #162133;
  --text-on-brand: #FFFFFF;
  --text-secondary: #8A9AB4;
  --text-link: #134FAE;

  /* radius */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-bubble: 16px;
  --r-pill: 20px;
  --r-avatar: 9px;
  --r-mark: 10px;

  /* space */
  --s-xxs: 4px;
  --s-xs: 6px;
  --s-sm: 8px;
  --s-md: 12px;
  --s-lg: 14px;
  --s-xl: 16px;
  --s-xxl: 20px;

  --font-body: "Opet", "Source Sans 3", "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  height: 100%; margin: 0; padding: 0;
  background: var(--surface-chat);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex; flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface-chat);
}

/* ---- Marka filigranı ------------------------------------------------------
   Sayfanın tamamını kaplayan, soluk Opet logosu (web/opet-logo.webp).
   Sabit konumludur: sohbet kaydıkça kaymaz, arkada durur.

   Renkler korunur, yalnızca soluklaşır — grileştirme yok. Logonun şeffaf zemini
   olmadığı için sarı bir kare içinde gelir; ekranın TAMAMINI kaplattığımızda o
   kare kenarı diye bir şey kalmaz, sarı sayfaya yayılmış bir marka zeminine
   dönüşür. `cover` bu yüzden hem istenen görünüm hem de kare sorununun çözümü.

   Zemin #F3F5F9 üzerinde %16 opaklıkta:
     sarı  #FFD300 → #F5F0D1   (yumuşak krem)
     mavi  #134FAE → #CFDAED   (yumuşak mavi, kelime markası okunur)

   Tek ayar düğmesi opacity'dir: .20 daha doygun, .10 daha soluk.

   İçeriğin arkasında kalması için .app şeffaflaştırılır; başlık ve besteci
   kendi opak zeminlerini taşımaya devam eder, böylece metin her zaman okunur
   bir yüzeyin üstünde kalır. */
:root {
  --brand-watermark: url("/static/opet-logo.webp");
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--brand-watermark);
  background-repeat: no-repeat;
  background-position: center;
  /* Ekranın tamamını kaplar; kare logo geniş ekranda dikey, dar ekranda yatay
     kırpılır ve kelime markası ortada kaldığı için her iki durumda da görünür. */
  background-size: cover;
  opacity: 0.16;
}

@media (prefers-reduced-transparency: reduce) {
  body::before { opacity: 0.09; }
}

/* Filigran görünür kalsın diye sütunun kendi zemini kaldırılır. */
.app {
  position: relative;
  z-index: 1;
  background: transparent;
}


/* AssistantHeader */
.assistant-header {
  display: flex; align-items: center; gap: var(--s-md);
  padding: var(--s-md) var(--s-xl);
  background: var(--surface-app);
  border-bottom: 1px solid var(--border-default);
}
.assistant-header .back,
.assistant-header .menu {
  background: transparent; border: 0; color: var(--text-link);
  font-size: 22px; line-height: 1; padding: 4px 8px;
  cursor: pointer;
}
.assistant-header .menu { color: var(--text-secondary); margin-left: auto; }
.assistant-header .mark {
  width: 32px; height: 32px;
  border-radius: var(--r-mark);
  background: var(--brand-blue);
  color: var(--brand-yellow);
  display: grid; place-items: center;
}
.assistant-header .title-block { display: flex; flex-direction: column; gap: 2px; }
.app-title { font-size: 17px; line-height: 20px; font-weight: 700; color: var(--text-primary); }
.app-subtitle { font-size: 12px; line-height: 15px; font-weight: 400; color: var(--text-secondary); }

/* Chat area — .chat scrolls, .chat-log is the content whose height it follows. */
.chat {
  flex: 1;
  /* A flex item defaults to min-height:auto, which refuses to shrink below its
     content. Without this the log grows past 100dvh, the composer is pushed off
     the bottom of the screen, and this element never becomes scrollable. */
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* Separate element so a ResizeObserver can watch the content's real height and
   re-pin the view whenever a card reflows after it was appended. */
.chat-log {
  padding: var(--s-md) var(--s-lg);
  display: flex; flex-direction: column; gap: var(--s-md);
}

/* MessageBubble */
.msg { display: flex; gap: var(--s-sm); align-items: flex-start; max-width: 100%; }
.msg.assistant { justify-content: flex-start; }
.msg.user { justify-content: flex-end; }

.avatar {
  width: 28px; height: 28px; flex: 0 0 28px;
  border-radius: var(--r-avatar);
  background: var(--brand-blue);
  color: var(--brand-yellow);
  display: grid; place-items: center;
}
.avatar.hidden { visibility: hidden; }

.bubble {
  font-size: 16px; line-height: 23px; font-weight: 400;
  padding: var(--s-md) var(--s-lg);
  border-radius: var(--r-bubble);
  white-space: pre-wrap; word-wrap: break-word;
}
.msg.assistant .bubble {
  background: var(--surface-card);
  color: var(--text-primary);
  border: 1px solid var(--border-bubble);
  border-bottom-left-radius: var(--r-xs);
  max-width: 84%;
}
.msg.user .bubble {
  background: var(--brand-blue);
  color: var(--text-on-brand);
  border-bottom-right-radius: var(--r-xs);
  padding: 10px var(--s-lg);
  max-width: 82%;
}

/* ToolStatus */
.tool-status {
  margin-left: 36px;
  color: var(--text-secondary);
  font-size: 13px; line-height: 17px;
  display: flex; align-items: center; gap: var(--s-sm);
}
.tool-status .dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #CBD6E6;
  border-top-color: var(--brand-blue);
  animation: spin 0.8s linear infinite;
}
.tool-status.done .dot,
.tool-status.chained .dot,
.tool-status.memory .dot {
  border: none; background: transparent;
  color: var(--brand-blue); animation: none;
  width: auto; height: auto;
}
/* spec/components.md §3 allows three indicators only: spinner, ✓, or none.
   A memory hit is a completed lookup, so it takes the same ✓ as `done`. */
.tool-status.done .dot::before,
.tool-status.chained .dot::before,
.tool-status.memory .dot::before { content: "✓"; font-weight: 700; }
.tool-status.none .dot { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* PriceCard */
.card {
  margin-left: 36px;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-header {
  padding: var(--s-md) var(--s-lg);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; justify-content: space-between; align-items: baseline;
}
.card-title { font-size: 15px; line-height: 18px; font-weight: 700; color: var(--text-primary); }
.card-subtitle { font-size: 13px; line-height: 16px; font-weight: 400; color: var(--text-secondary); margin-top: 2px; }
.card-badge {
  font-size: 11px; line-height: 15px; font-weight: 600;
  color: var(--text-link);
  background: var(--surface-badge);
  padding: 2px 8px; border-radius: var(--r-sm);
}
.price-row {
  padding: var(--s-md) var(--s-lg);
  border-bottom: 1px solid var(--border-hairline);
  display: flex; justify-content: space-between; align-items: baseline;
}
.price-row:last-of-type { border-bottom: 0; }
.product-name { font-size: 15px; line-height: 19px; color: var(--text-primary); }
.price-value {
  font-size: 18px; line-height: 22px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
/* PriceSummaryCard — one row per fuel, three figures across. The unit is in the
   subtitle, so the columns stay narrow enough for 390dp. */
.summary-row {
  padding: var(--s-sm) var(--s-lg);
  border-bottom: 1px solid var(--border-hairline);
  display: grid;
  grid-template-columns: 1fr repeat(3, minmax(56px, auto));
  align-items: baseline;
  column-gap: var(--s-sm);
}
.summary-row:last-of-type { border-bottom: 0; }
.summary-col {
  text-align: right;
  font-size: 15px; line-height: 20px; font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.summary-head {
  padding-top: var(--s-md);
  border-bottom: 1px solid var(--border-subtle);
}
.summary-head .summary-col {
  font-size: 11px; line-height: 15px; font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

.stamp {
  background: var(--surface-stamp);
  padding: var(--s-sm) var(--s-lg);
  font-size: 12px; line-height: 16px; color: var(--text-secondary);
  border-top: 1px solid var(--border-hairline);
}

/* StationCard */
.station-card { padding: 0; }

.map {
  position: relative;
  height: 88px;
  background: linear-gradient(115deg, #E3EBF6 0%, #EDF2F9 46%, #E7EEF8 100%);
  border-bottom: 1px solid var(--border-subtle);
  overflow: hidden;
}
.map .road { position: absolute; background: #FFFFFF; }
.map .r1 { left: 0; right: 0; top: 42%; height: 10px; }
.map .r2 { top: 0; bottom: 0; left: 38%; width: 8px; }
.map .r3 { left: 0; right: 0; top: 68%; height: 4px; background: #F5F8FC; }
/* Positions come from the server as 0..1 coordinates and are set inline; the
   translate centres each dot on its point instead of hanging it below-right. */
.map .me,
.map-dot {
  position: absolute;
  border-radius: 50%;
  border: 2px solid #fff;
  transform: translate(-50%, -50%);
}
.map .me {
  width: 12px; height: 12px;
  background: var(--brand-blue);
  box-shadow: 0 0 0 5px rgba(19, 79, 174, 0.16);
}
.map-dot {
  width: 14px; height: 14px;
  background: var(--brand-orange);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
}

/* Live map: taller than the 72dp schematic strip, because a real map that short
   shows no useful surroundings. Markers are drawn by the map itself. */
.map-live { height: auto; background: var(--surface-chat); }
.map-live img { display: block; width: 100%; height: auto; }

.station-row {
  padding: var(--s-lg) var(--s-lg);
  border-bottom: 1px solid var(--border-hairline);
  display: grid;
  grid-template-columns: 24px 1fr auto;
  column-gap: var(--s-md);
  align-items: start;
}
.station-row:last-of-type { border-bottom: 0; }

.rank {
  width: 22px; height: 22px;
  background: var(--surface-badge); color: var(--text-link);
  font-size: 12px; font-weight: 700;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  margin-top: 2px;
}

.station-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.station-name { font-size: 16px; line-height: 20px; font-weight: 700; color: var(--text-primary); }
.station-address { font-size: 13px; line-height: 17px; color: var(--text-secondary); }

.distance-block { text-align: right; }
.distance {
  font-size: 15px; line-height: 18px; font-weight: 700;
  color: var(--text-link);
  font-variant-numeric: tabular-nums;
}
.duration { font-size: 12px; line-height: 15px; color: var(--text-secondary); margin-top: 2px; }

.badges { margin-top: var(--s-sm); display: flex; flex-wrap: wrap; gap: var(--s-xxs); }
.badge {
  padding: 4px var(--s-md);
  border-radius: var(--r-pill);
  font-size: 12px; line-height: 16px; font-weight: 600;
}
.badge.matched { background: var(--surface-badge); color: var(--text-link); }
.badge.missing { background: var(--surface-badge-muted); color: var(--text-secondary); }

.cta {
  align-self: flex-start;
  margin-top: var(--s-md);
  padding: 10px 18px;
  border-radius: var(--r-md);
  font-size: 14px; line-height: 18px; font-weight: 700;
  background: var(--brand-orange);
  color: var(--text-on-brand);
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
}
.cta.alt {
  background: var(--surface-card);
  color: var(--text-link);
  border-color: var(--border-cta-alt);
}
.cta:active { filter: brightness(0.92); }

/* Chips */
.chips {
  margin-left: 36px;
  display: flex; flex-wrap: wrap; gap: var(--s-xs);
}
.chip {
  padding: var(--s-sm) 14px;
  border-radius: var(--r-pill);
  font-size: 14px; line-height: 18px; font-weight: 600;
  cursor: pointer;
  background: var(--surface-card);
  color: var(--text-link);
  border: 1px solid var(--border-chip);
}
.chip.solid { background: var(--brand-blue); color: var(--text-on-brand); border: 0; }
.chip:disabled { opacity: 0.5; cursor: default; }

/* ContextPill */
.context-pill {
  align-self: center;
  background: var(--surface-context-pill);
  color: var(--text-secondary);
  padding: 4px var(--s-md);
  border-radius: var(--r-pill);
  font-size: 12px; line-height: 16px;
}

/* Composer */
.composer {
  display: flex; align-items: center; gap: var(--s-sm);
  padding: var(--s-md) var(--s-lg);
  background: var(--surface-app);
  border-top: 1px solid var(--border-default);
}
.composer-field {
  flex: 1;
  background: var(--surface-chat);
  border: 1px solid var(--border-default);
  border-radius: var(--r-pill);
  padding: 10px var(--s-xl);
}
.composer-field input {
  width: 100%; border: 0; outline: none; background: transparent;
  font-size: 15px; line-height: 19px; color: var(--text-primary);
  font-family: inherit;
}
.composer-field input::placeholder { color: var(--text-secondary); }
.send {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--brand-orange); color: var(--text-on-brand);
  border: 0; display: grid; place-items: center; cursor: pointer;
}
.send:disabled { opacity: 0.4; cursor: default; }
.send:not(:disabled):active { background: var(--brand-orange); filter: brightness(0.9); }

/* Utility */
.hidden { display: none !important; }

/* Konum kapalıyken çıkan tek seferlik bildirim. Tasarımın kendi belirteçleriyle
   kurulur; <dialog> odak tuzağını ve Esc'i tarayıcıdan getirir. */
.notice {
  max-width: 320px;
  padding: var(--s-xxl);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  background: var(--surface-card);
  color: var(--text-primary);
  box-shadow: 0 8px 28px rgba(22, 33, 51, 0.18);
}

.notice::backdrop {
  background: rgba(22, 33, 51, 0.45);
}

.notice-text {
  margin: 0 0 var(--s-xl);
  font-size: 15px;
  line-height: 22px;
}

.notice-ok {
  display: block;
  margin-left: auto;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--brand-orange);
  color: var(--text-on-brand);
  font: inherit;
  font-size: 14px;
  line-height: 18px;
  font-weight: 700;
  cursor: pointer;
}

.notice-ok:hover {
  background: var(--brand-orange);
  filter: brightness(0.94);
}
