/* ============================================================
   Algo Veri Bankası — Telegram Mini App stilleri
   Tema: Telegram var(--tg-theme-*) değişkenleri; yoksa
   prefers-color-scheme'e göre koyu/açık fallback.
   Renk dili: nötr mavi/mor vurgu — AL/SAT çağrışımı yok.
   ============================================================ */

:root {
  /* Açık tema fallback değerleri */
  --fb-bg: #eef1f7;
  --fb-card: #ffffff;
  --fb-text: #1c2333;
  --fb-hint: #66708a;
  --fb-border: rgba(28, 35, 51, 0.08);
  --fb-seg: rgba(28, 35, 51, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fb-bg: #101319;
    --fb-card: #1a1f2b;
    --fb-text: #e9ecf5;
    --fb-hint: #8f97ad;
    --fb-border: rgba(233, 236, 245, 0.08);
    --fb-seg: rgba(233, 236, 245, 0.07);
  }
}

:root {
  --bg: var(--tg-theme-secondary-bg-color, var(--fb-bg));
  --card: var(--tg-theme-bg-color, var(--fb-card));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  --border: var(--fb-border);
  --seg: var(--fb-seg);

  --accent: #5b7cfa;      /* nötr mavi */
  --accent-2: #8b5cf6;    /* mor */
  --accent-soft: rgba(91, 124, 250, 0.12);
  --track: rgba(128, 138, 160, 0.22);
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}

button { font-family: inherit; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Yerleşim ---------- */

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 14px calc(96px + env(safe-area-inset-bottom, 0px));
}

/* ---------- Başlık ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: 14px 0 10px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.icon-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: opacity 0.15s;
}
.icon-btn:active { opacity: 0.65; }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.spinning svg { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Sekmeler (segmented control) ---------- */

.tabs {
  position: relative;
  display: flex;
  background: var(--seg);
  border-radius: 12px;
  padding: 4px;
}

.tab {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 8px 0;
  border: none;
  background: transparent;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--hint);
  cursor: pointer;
  transition: color 0.2s;
}
.tab.active { color: var(--text); }

.tab-indicator {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: var(--card);
  border-radius: 9px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.tabs[data-active="stats"] .tab-indicator { transform: translateX(100%); }

/* ---------- Panel ve listeler ---------- */

.panel { padding-top: 4px; }

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary {
  font-size: 11.5px;
  color: var(--hint);
  margin: 2px 2px 10px;
  font-variant-numeric: tabular-nums;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* ---------- Sinyal kartı ---------- */

.signal-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.signal-body { flex: 1; min-width: 0; }

.signal-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 3px;
}

.sym {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.chip {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--hint);
  background: var(--seg);
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.chip-accent {
  color: var(--accent);
  background: var(--accent-soft);
}
.chip-pf {
  font-size: 10px;
  margin-left: 6px;
  vertical-align: 1px;
}

.signal-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--hint);
  font-variant-numeric: tabular-nums;
}
.signal-meta .dot { opacity: 0.6; }

.price-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 8px;
}
.price-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.price {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.signal-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--hint);
}

/* ---------- Dairesel isabet göstergesi ---------- */

.gauge {
  flex-shrink: 0;
  width: 62px;
  height: 62px;
}
.gauge svg { width: 100%; height: 100%; display: block; }

.gauge-track {
  fill: none;
  stroke: var(--track);
  stroke-width: 5;
}
.gauge-fill {
  fill: none;
  stroke: url(#gaugeGrad);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}
.gauge-label {
  fill: var(--text);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
}
.gauge-label.muted { fill: var(--hint); }

/* ---------- Karne satırı ---------- */

.stat-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.stat-pct {
  margin-left: auto;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.bar {
  margin-top: 10px;
  height: 6px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.6s ease;
}

.stat-meta {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--hint);
  font-variant-numeric: tabular-nums;
}

/* ---------- Boş / hata durumları ---------- */

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--hint);
}
.empty-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--seg);
  display: grid;
  place-items: center;
  color: var(--accent);
}
.empty-icon svg { width: 24px; height: 24px; }
.empty h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.empty p {
  font-size: 12.5px;
  max-width: 260px;
  margin: 0 auto;
}
.retry-btn {
  margin-top: 16px;
  padding: 9px 20px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.retry-btn:active { opacity: 0.8; }

/* ---------- İskelet (yükleniyor) ---------- */

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sk-lines { flex: 1; }
.sk-line {
  height: 12px;
  border-radius: 6px;
  background: var(--seg);
  margin-bottom: 9px;
}
.sk-line:last-child { margin-bottom: 0; }
.sk-line.w40 { width: 40%; }
.sk-line.w60 { width: 60%; }
.sk-line.w80 { width: 80%; }
.sk-circle {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--seg);
}
.skeleton-row .sk-line,
.skeleton-row .sk-circle {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* ---------- Uyarı balonu (toast) ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(66px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(8px);
  max-width: min(90vw, 440px);
  padding: 9px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--card);
  font-size: 12.5px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Kalıcı feragat ---------- */

.disclaimer {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  padding: 10px 18px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-size: 10.5px;
  line-height: 1.4;
  text-align: center;
  color: var(--hint);
  z-index: 30;
}
