/* CRM kullanım asistanı — her ekranın sağ altındaki düğme ve sohbet paneli
   (2026-11-30; pages/_partials/ai_helper.php, _shared/ai_helper.js). */

.ai-helper {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .625rem;
  pointer-events: none;
}
.ai-helper > * { pointer-events: auto; }
/* Gelen kutusu: yazma kutusunun gönder düğmesinin üstünde kalsın. */
.ai-helper--raised { bottom: 92px; }

.ai-helper__fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: var(--brand);
  color: var(--brand-contrast, #fff);
  box-shadow: var(--shadow-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .15s ease;
}
.ai-helper__fab:hover { transform: scale(1.06); }
.ai-helper__fab:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 2px; }
.ai-helper__fab svg { width: 22px; height: 22px; }
.ai-helper--open .ai-helper__fab { order: 2; }

.ai-helper__panel {
  order: 1;
  width: min(400px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.ai-helper__panel[hidden] { display: none; }
.ai-helper--raised .ai-helper__panel { height: min(620px, calc(100vh - 190px)); }

.ai-helper__head {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .625rem .75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.ai-helper__head > svg { width: 18px; height: 18px; color: var(--brand); flex-shrink: 0; }
.ai-helper__title { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.ai-helper__title .tiny { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Sohbetin toplam harcaması (2026-12-01): Yeni sohbet sıfırlar. */
.ai-helper__total { font-weight: 600; color: var(--brand); font-variant-numeric: tabular-nums; }

.ai-helper__log {
  flex: 1;
  overflow-y: auto;
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.ai-helper__chips { display: flex; flex-wrap: wrap; gap: .375rem; margin-top: .5rem; }
.ai-helper__chip {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: .3rem .7rem;
  font-size: .75rem;
  cursor: pointer;
}
.ai-helper__chip:hover { background: var(--surface-2); }

.ai-helper__msg {
  max-width: 92%;
  padding: .5rem .7rem;
  border-radius: 12px;
  font-size: .8125rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-helper__msg--user { align-self: flex-end; background: color-mix(in srgb, var(--brand) 14%, var(--surface)); }
.ai-helper__msg--assistant { align-self: flex-start; background: var(--surface-2); }
.ai-helper__msg--pending { align-self: flex-start; color: var(--text-muted); font-style: italic; }
.ai-helper__msg--error { align-self: flex-start; background: var(--danger-bg); color: var(--danger); }
.ai-helper__msg code { font-size: .75rem; }
.ai-helper__cost { margin-top: .4rem; padding-top: .3rem; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }

.ai-helper__action { white-space: normal; margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--border); }
.ai-helper__diff {
  margin-top: .375rem;
  max-height: 16rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .375rem;
  white-space: pre-wrap;
  background: var(--surface);
}

.ai-helper__form {
  display: flex;
  gap: .5rem;
  align-items: flex-end;
  padding: .625rem;
  border-top: 1px solid var(--border);
}
.ai-helper__form .textarea { flex: 1; resize: none; min-height: 2.5rem; max-height: 8rem; }

/* Asistanın doldurduğu / gösterdiği alan bir an vurgulanır. */
.ai-helper-flash {
  outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent);
  outline-offset: 4px;
  border-radius: 6px;
  transition: outline-color .3s ease;
}

/* Telefon: alttaki gezinme şeridinin üstünde; panel tam genişlik. */
@media (max-width: 720px) {
  .ai-helper { right: 12px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .ai-helper--raised { bottom: calc(132px + env(safe-area-inset-bottom, 0px)); }
  .ai-helper__fab { width: 44px; height: 44px; }
  .ai-helper__panel { width: calc(100vw - 24px); height: calc(100vh - 170px); }
}

@media print { .ai-helper { display: none; } }

/* CRM asistanı › Kullanımlar (232): 30 günlük harcama çubukları. */
.ai-usage-chart { display: flex; align-items: flex-end; gap: 2px; height: 120px; border-bottom: 1px solid var(--border); }
.ai-usage-chart__bar { flex: 1; min-width: 3px; background: var(--brand); border-radius: 2px 2px 0 0; opacity: .85; }
.ai-usage-chart__bar:hover { opacity: 1; }
.ai-usage-chart__bar--empty { background: var(--border); }

/* CRM asistanı › Sohbet (232): soru sağda, cevap solda. */
.ai-chat { display: flex; flex-direction: column; gap: 1.25rem; }
.ai-chat__turn { display: flex; flex-direction: column; gap: .375rem; }
.ai-chat__q { align-self: flex-end; max-width: 80%; padding: .5rem .75rem; border-radius: 12px 12px 2px 12px; background: var(--brand); color: #fff; white-space: normal; }
.ai-chat__a { align-self: flex-start; max-width: 85%; padding: .5rem .75rem; border-radius: 12px 12px 12px 2px; background: var(--surface-2, var(--bg)); border: 1px solid var(--border); }
.ai-chat__a--error { border-color: var(--danger, #dc2626); }
.ai-chat__meta { align-self: flex-end; }
.ai-chat__foot { align-self: flex-start; }

/* Panel (232): cevabın altındaki 👍 / 👎 ve Kopyala. */
.ai-helper__rate { display: flex; gap: .25rem; align-items: center; margin-top: .3rem; flex-wrap: wrap; }
.ai-helper__rate .btn { padding: .1rem .4rem; min-height: 0; font-size: .8rem; }
.ai-helper__rate .btn[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.ai-helper__rate input { flex: 1; min-width: 8rem; font-size: .8rem; padding: .2rem .4rem; }
