/* PreisWächter — elle yazılmış tek dosya CSS.
 *
 * Neden elle: sunucuda node/npm yok (Tailwind build edilemez), CDN de
 * istemiyoruz (dış bağımlılık + CSP). Modern görünüm için framework şart değil:
 * CSS değişkenleri + flex/grid + prefers-color-scheme yeter.
 *
 * Mobil öncelikli: temel düzen tek sütun; geniş ekran kuralları en altta
 * (min-width media query) — telefon varsayılan, masaüstü ekleme.
 */

:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #16181d;
  --text-muted: #667085;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --success: #0f9d58;
  --success-soft: #e7f6ee;
  --danger: #d92d20;
  --danger-soft: #fdeceb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
  --radius: 14px;
}

/* Koyu tema: telefon karanlıkta kullanılıyor; sistem tercihi neyse o.
 * Manuel tema düğmesi yok — bilinçli: JS + state + saklama gerektirir,
 * sistem tercihi zaten doğru cevabı biliyor. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1e222b;
    --border: #2a2f3a;
    --text: #e8eaee;
    --text-muted: #98a2b3;
    --accent: #6aa1ff;
    --accent-soft: #1a2338;
    --success: #3ddc84;
    --success-soft: #12291d;
    --danger: #ff6b5e;
    --danger-soft: #2c1614;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* Fiyatlar hizalansın: rakamlar eşit genişlikte (1 ile 8 aynı yer kaplar) */
.price, .num, td.num, .chart-label { font-variant-numeric: tabular-nums; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- üst çubuk --- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 900px;
  margin: 0 auto;
  padding: 10px 16px;
  flex-wrap: wrap;
}

.brand { font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }

.nav-links { display: flex; gap: 4px; margin-left: auto; }

.nav-links a {
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 15px;
}
.nav-links a:hover { background: var(--surface-2); text-decoration: none; }
.nav-links a.active { background: var(--accent-soft); color: var(--accent); }

.logout-form { display: flex; align-items: center; gap: 8px; }
.username { color: var(--text-muted); font-size: 14px; }

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  padding: 4px;
  text-decoration: underline;
}
.btn-link:hover { color: var(--danger); }

/* --- düzen --- */

.container { max-width: 900px; margin: 0 auto; padding: 16px; }

h1 { font-size: 22px; margin: 4px 0 16px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 24px 0 10px; letter-spacing: -.01em; }

.muted { color: var(--text-muted); }
.small { font-size: 13px; }

/* --- flash mesajları --- */

.flashes { display: grid; gap: 8px; margin-bottom: 16px; }

.flash {
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 15px;
  border: 1px solid transparent;
}
.flash-success { background: var(--success-soft); color: var(--success); border-color: currentColor; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: currentColor; }

/* --- kartlar --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

/* Ürün listesi satırı: mobilde dikey yığın, geniş ekranda yatay */
.product-card { display: block; color: inherit; }
.product-card:hover { text-decoration: none; border-color: var(--accent); }

.product-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.product-name { font-weight: 600; letter-spacing: -.01em; }

.product-price { font-size: 20px; font-weight: 700; white-space: nowrap; }

/* Hedefin altındaki fiyat belirgin yeşil — listede aranan tek bilgi bu */
.product-card.target-met { border-color: var(--success); background: var(--success-soft); }
.product-card.target-met .product-price { color: var(--success); }

.product-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.product-meta .sparkline { margin-left: auto; }

/* --- rozetler --- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: currentColor; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: currentColor; }
.badge-paused { background: var(--surface-2); color: var(--text-muted); }

/* --- formlar --- */

label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }

input[type="text"], input[type="password"], input[type="url"], input[type="search"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* < 16px iOS'ta odaklanınca sayfayı zoomlar */
}

input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  display: inline-block;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn:hover { text-decoration: none; filter: brightness(0.97); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-block { display: block; width: 100%; }

.form-row { display: flex; gap: 8px; align-items: flex-end; }
.form-row > * { margin: 0; }
.form-row .grow { flex: 1; }

.field { margin-bottom: 14px; }

.hint { color: var(--text-muted); font-size: 13px; margin-top: 6px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- giriş sayfası --- */

.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card { width: 100%; max-width: 360px; margin: 0; }

.login-brand { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-brand span { color: var(--accent); }
.login-sub { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }

/* --- grafikler (charts.py'nin ürettiği SVG) --- */

.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: var(--accent); opacity: .10; stroke: none; }
.chart-dot { fill: var(--accent); }
.chart-label { fill: var(--text-muted); font-size: 11px; font-family: inherit; }
.chart-empty { fill: var(--text-muted); font-size: 13px; font-family: inherit; }

.sparkline { display: block; width: 80px; height: 24px; }
.sparkline-line { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; opacity: .8; }

/* --- tablolar --- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-weight: 600; }

/* --- arama sonuçları --- */

.result { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.result:last-child { border-bottom: none; }
.result-info { flex: 1; min-width: 0; }
.result-name { font-weight: 500; overflow-wrap: anywhere; }
.result-meta { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* --- boş durum --- */

.empty { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 40px; }
.empty h2 { margin: 12px 0 6px; }
.empty p { color: var(--text-muted); margin: 0 0 18px; }

/* --- kaynak listesi --- */

.source { padding: 12px 0; border-bottom: 1px solid var(--border); }
.source:last-child { border-bottom: none; }
.source-url { overflow-wrap: anywhere; font-size: 13px; }
.source-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; font-size: 13px; color: var(--text-muted); }

/* --- detay başlığı --- */

.detail-price { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.detail-price.target-met { color: var(--success); }
.detail-sub { color: var(--text-muted); font-size: 14px; }

.back-link { display: inline-block; margin-bottom: 12px; font-size: 14px; color: var(--text-muted); }

/* --- geniş ekran (mobil öncelikli: bu blok EKLEME) --- */

@media (min-width: 640px) {
  .container { padding: 24px 16px; }
  h1 { font-size: 26px; }
  .product-card { display: flex; align-items: center; gap: 16px; }
  .product-card .product-body { flex: 1; min-width: 0; }
  .product-head { display: block; }
  .product-card .product-price { font-size: 22px; }
}

/* Hareket hassasiyeti olan kullanıcılar için (şu an animasyon yok; ileride eklenirse korunur) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
