/* ==========================================================================
   Analiz — tasarim standardi
   Renkler referans ekran goruntusundeki degerlerden alinmistir.
   ========================================================================== */

:root {
  /* Renk paleti */
  --bg:          #0a090d;
  --surface:     #111018;
  --surface-2:   #16151f;
  --surface-3:   #1c1b26;
  --border:      #211f2c;
  --border-soft: #1a1924;

  --text:        #ffffff;
  --muted:       #a5a9b3;
  --muted-dim:   #6f7380;

  --accent:      #6ad8f2;
  --grad-from:   #52b3cf;
  --grad-to:     #55b786;
  --danger:      #ef5f6b;

  /* Olcu ve bicim */
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --pad: 20px;

  --shadow-card: 0 1px 0 rgba(255,255,255,.03) inset, 0 12px 32px rgba(0,0,0,.45);
  --shadow-btn:  0 8px 22px rgba(82,179,207,.22);

  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #060509;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

img { max-width: 100%; display: block; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

[hidden] { display: none !important; }


/* ==========================================================================
   Cihaz cercevesi — mobil uygulama gorunumu
   Telefonda tam ekran, genis ekranda ortalanmis telefon govdesi.
   ========================================================================== */

.device {
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

@media (min-width: 560px) and (min-height: 760px) {
  body { padding: 28px 0; }
  .device {
    height: min(920px, calc(100dvh - 56px));
    border-radius: 44px;
    border: 1px solid #23212e;
    box-shadow: 0 40px 90px rgba(0,0,0,.65), 0 0 0 10px #0e0d13;
  }
}

.app {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}


/* ==========================================================================
   Ortak bilesenler
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* --- Form alanlari --- */
.field { display: block; margin-bottom: 16px; }
.field:last-of-type { margin-bottom: 18px; }

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--muted);
  margin-bottom: 8px;
}

.field input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 15.5px;
  outline: none;
  transition: border-color .18s var(--ease), background .18s var(--ease);
}

.field input::placeholder { color: var(--muted-dim); }

.field input:focus {
  border-color: var(--grad-from);
  background: var(--surface-3);
}

.field-pw { position: relative; display: block; }
.field-pw input { padding-right: 50px; }

.pw-toggle {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: none; border: 0;
  color: var(--muted-dim);
  border-radius: 10px;
  transition: color .18s var(--ease);
}
.pw-toggle:hover { color: var(--muted); }
.pw-toggle svg { width: 19px; height: 19px; }
.pw-toggle.is-on { color: var(--accent); }

/* --- Butonlar --- */
.btn {
  width: 100%;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .01em;
  transition: transform .14s var(--ease), box-shadow .2s var(--ease), opacity .2s var(--ease);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(90deg, var(--grad-from) 0%, var(--grad-to) 100%);
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0) scale(.99); }

.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.btn-icon { width: 18px; height: 18px; flex-shrink: 0; }
.btn-arrow { width: 20px; height: 20px; transition: transform .2s var(--ease); }
.btn-primary:hover:not(:disabled) .btn-arrow { transform: translateX(3px); }

.btn-compact { width: auto; height: 50px; padding: 0 20px; font-size: 15px; flex-shrink: 0; }

/* Buton icindeki yukleniyor durumu */
.btn.is-busy .btn-text { opacity: .75; }
.btn.is-busy .btn-arrow { display: none; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--muted);
  transition: color .18s var(--ease), border-color .18s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: #2c2a39; }
.icon-btn svg { width: 18px; height: 18px; }

/* --- Hata metni --- */
.form-error {
  margin: -4px 0 14px;
  padding: 11px 14px;
  background: rgba(239,95,107,.09);
  border: 1px solid rgba(239,95,107,.26);
  border-radius: var(--radius-sm);
  color: #ff9ba3;
  font-size: 13.5px;
  line-height: 1.45;
}

/* --- Spinner --- */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ==========================================================================
   Giris / kayit ekrani
   ========================================================================== */

.screen-auth {
  justify-content: center;
  overflow-y: auto;
  padding: 32px 22px calc(32px + env(safe-area-inset-bottom));
}

.auth-wrap { width: 100%; margin: auto; }

.brand { text-align: center; margin-bottom: 30px; }

.brand-logo {
  display: block;
  width: min(148px, 52%);
  height: auto;
  margin: 0 auto 10px;
}

.brand-mark {
  width: 62px; height: 62px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  border-radius: 19px;
  color: #fff;
  background: linear-gradient(135deg, var(--grad-from), var(--grad-to));
  box-shadow: 0 14px 30px rgba(82,179,207,.26);
}
.brand-mark svg { width: 30px; height: 30px; }

.brand-name {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.3;
}

.brand-sub { margin: 0; font-size: 14.5px; color: var(--muted); }

.auth-card { padding: var(--pad); }

.auth-switch {
  margin: 20px 0 0;
  text-align: center;
  font-size: 14.5px;
  color: var(--muted);
}

.auth-switch a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.auth-switch a:hover { text-decoration: underline; }


/* ==========================================================================
   Ust bar — hos geldiniz + kalan hak
   ========================================================================== */

.appbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) 18px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
}

.appbar-user { display: flex; align-items: center; gap: 11px; min-width: 0; }

.avatar {
  width: 42px; height: 42px;
  flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 13px;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--grad-from), var(--grad-to));
}

.appbar-greet { display: flex; flex-direction: column; min-width: 0; }

.greet-hello { font-size: 12px; color: var(--muted-dim); line-height: 1.3; }

.greet-name {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Kalan analiz hakki rozeti */
.credits {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 38px;
  padding: 0 12px;
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(82,179,207,.15), rgba(85,183,134,.15));
  border: 1px solid rgba(106,216,242,.26);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.credits svg { width: 15px; height: 15px; }
.credits-num { font-size: 14.5px; }
.credits-label { color: var(--muted); font-weight: 600; }

.credits.is-empty {
  background: rgba(239,95,107,.1);
  border-color: rgba(239,95,107,.3);
  color: #ff9ba3;
}
.credits.is-empty .credits-label { color: #c98a90; }


/* ==========================================================================
   Sekmeler
   ========================================================================== */

.tabs {
  flex-shrink: 0;
  position: relative;
  display: flex;
  padding: 0 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
}

.tab {
  flex: 1;
  height: 48px;
  background: none;
  border: 0;
  color: var(--muted-dim);
  font-size: 14.5px;
  font-weight: 700;
  transition: color .2s var(--ease);
}
.tab:hover { color: var(--muted); }
.tab.is-active { color: var(--text); }

.tab-indicator {
  position: absolute;
  bottom: -1px; left: 18px;
  height: 2px;
  width: 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--grad-from), var(--grad-to));
  transition: transform .28s var(--ease), width .28s var(--ease);
}


/* ==========================================================================
   Icerik
   ========================================================================== */

.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px calc(24px + env(safe-area-inset-bottom));
}

.tabpanel { display: none; }
.tabpanel.is-active { display: block; animation: fade .26s var(--ease); }

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* --- Sembol arama --- */
.search-card { padding: 18px; margin-bottom: 16px; }
.search-card .field { margin-bottom: 0; }

.search-row { display: flex; gap: 10px; align-items: flex-start; }
.search-row input { text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

.symbol-box { position: relative; flex: 1; min-width: 0; }

.suggest {
  position: absolute;
  z-index: 8;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  max-height: 248px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
}

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

.sym-logo {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  background: var(--surface-3);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0;
}
.sym-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.suggest button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  background: none;
  border: 0;
  border-radius: 8px;
  text-align: left;
}

.suggest button.is-active,
.suggest button:hover { background: var(--surface-3); }

.suggest-sym { font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.suggest-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.back-terminal {
  flex-shrink: 0;
  align-self: center;
  margin: 4px 18px calc(14px + env(safe-area-inset-bottom));
  height: 44px;
  padding: 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  text-decoration: none;
  color: #fff;
  font-size: 14.5px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--grad-from) 0%, var(--grad-to) 100%);
  box-shadow: var(--shadow-btn);
}

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

.chip {
  height: 32px;
  padding: 0 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .04em;
  transition: color .16s var(--ease), border-color .16s var(--ease);
}
.chip:hover { color: var(--accent); border-color: rgba(106,216,242,.35); }

/* --- Analiz sonucu --- */
.result-card { overflow: hidden; margin-bottom: 16px; }

.result-figure { margin: 0; background: #0c0b11; }
.result-figure img { width: 100%; height: auto; }

.result-body { padding: 16px 18px 18px; }

.result-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.sym-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px 0 4px;
  border-radius: 8px;
  background: rgba(106,216,242,.12);
  border: 1px solid rgba(106,216,242,.26);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .06em;
}

.result-date { font-size: 12.5px; color: var(--muted-dim); }

.result-text {
  font-size: 15px;
  line-height: 1.68;
  color: #dfe2e8;
  word-break: break-word;
}
.result-text b { color: #fff; font-weight: 700; }
.result-text i { color: var(--muted); }
.result-text p { margin: 0 0 11px; }
.result-text p:last-child { margin-bottom: 0; }

/* --- Iskelet (yukleniyor) --- */
.skeleton-card { padding: 0 0 18px; overflow: hidden; }

.sk {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -300% 0; } }

.sk-chart { width: 100%; aspect-ratio: 16 / 10; }
.sk-line { height: 13px; border-radius: 6px; margin: 12px 18px 0; }
.sk-line.w60 { width: 55%; }
.sk-line.w80 { width: 80%; }

.loading-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 18px 18px 0;
  font-size: 13.5px;
  color: var(--muted);
}

/* --- Bos durum --- */
.empty { padding: 48px 20px; text-align: center; }

.empty-icon {
  width: 58px; height: 58px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--muted-dim);
}
.empty-icon svg { width: 26px; height: 26px; }

.empty-title { margin: 0 0 5px; font-size: 15.5px; font-weight: 700; }
.empty-sub { margin: 0; font-size: 13.5px; color: var(--muted-dim); }


/* ==========================================================================
   Gecmis analizler listesi
   ========================================================================== */

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

.history-item {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 13px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  transition: border-color .18s var(--ease), transform .14s var(--ease);
}
.history-item:hover { border-color: #2b2939; transform: translateY(-1px); }
.history-item:active { transform: translateY(0); }

.history-thumb {
  width: 62px; height: 48px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #0c0b11;
}
.history-thumb img { width: 100%; height: 100%; object-fit: cover; }

.history-info { flex: 1; min-width: 0; }

.history-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.history-sym { font-size: 14.5px; font-weight: 800; letter-spacing: .05em; }
.history-date { font-size: 11.5px; color: var(--muted-dim); }

.history-excerpt {
  margin: 0;
  font-size: 12.8px;
  line-height: 1.45;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-chev { flex-shrink: 0; color: var(--muted-dim); }
.history-chev svg { width: 17px; height: 17px; }


/* ==========================================================================
   Detay paneli
   ========================================================================== */

.sheet {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  animation: slide-in .28s var(--ease);
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(26px); }
  to   { opacity: 1; transform: none; }
}

.sheet-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) 18px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.sheet-title { display: flex; align-items: center; gap: 10px; }

.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 18px calc(28px + env(safe-area-inset-bottom));
}

.sheet-body .result-figure {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-soft);
  margin-bottom: 18px;
}


/* ==========================================================================
   Bildirim
   ========================================================================== */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  max-width: calc(100% - 44px);
  padding: 12px 18px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
  font-size: 13.5px;
  text-align: center;
  animation: toast-in .24s var(--ease);
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.toast.is-error { border-color: rgba(239,95,107,.35); color: #ff9ba3; }


/* Kucuk ekranlarda sikistir */
@media (max-height: 680px) {
  .brand { margin-bottom: 20px; }
  .brand-logo { width: min(128px, 46%); margin-bottom: 8px; }
  .brand-name { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
