/* ============================================
   ENERJIONE AI ASSISTANT WIDGET
   Vanilla — her sayfada yüklenir.
   ============================================ */

:root {
  --eai-brand: #00d4ff;
  --eai-brand-2: #4d9fff;
  --eai-bg-0: #0a0e1a;
  --eai-bg-1: #0f1424;
  --eai-bg-2: #161c33;
  --eai-text: #e6eaf3;
  --eai-text-dim: #8b94ad;
  --eai-border: rgba(255,255,255,0.08);
  --eai-shadow: 0 24px 60px -16px rgba(0,0,0,0.55);
}
[data-theme="light"] {
  --eai-bg-0: #ffffff;
  --eai-bg-1: #f6f8fc;
  --eai-bg-2: #eef2f9;
  --eai-text: #0a1024;
  --eai-text-dim: #5b6580;
  --eai-border: rgba(0,0,0,0.08);
  --eai-shadow: 0 24px 60px -16px rgba(0,0,0,0.15);
}

/* FAB (yüzen tetikleyici) */
.eai-fab {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 9999;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--eai-brand), var(--eai-brand-2));
  color: #001528;
  box-shadow: 0 14px 32px -8px rgba(0, 212, 255, 0.55);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.2s ease;
}
.eai-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 18px 40px -8px rgba(0, 212, 255, 0.7); }
.eai-fab[hidden] { display: none !important; }

/* Sparkle (auto_awesome) solo ikon */
.eai-fab-spark-solo {
  font-size: 30px;
  font-variation-settings: 'FILL' 1, 'wght' 600;
  color: #001528;
  line-height: 1;
  animation: eai-spark 3s ease-in-out infinite;
  transform-origin: center;
}
@keyframes eai-spark {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(1.12) rotate(14deg); }
}
.eai-fab:hover .eai-fab-spark-solo { animation-duration: 1.4s; }

/* Tooltip baloncuğu (ilk açılışta dikkat çekmek için, hover'da da) */
.eai-fab-tip {
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--eai-bg-1);
  color: var(--eai-text);
  padding: 8px 14px;
  border-radius: 100px;
  border: 1px solid var(--eai-border);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 8px 22px rgba(0,0,0,0.3);
}
.eai-fab:hover .eai-fab-tip,
.eai-fab.eai-attract .eai-fab-tip { opacity: 1; transform: translateY(-50%) translateX(-3px); }

/* Pulse animasyonu (sayfada ilk açıldığında dikkat çekmek için) */
.eai-fab.eai-attract::before {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--eai-brand);
  animation: eai-pulse 2s ease-out infinite;
  pointer-events: none;
}
@keyframes eai-pulse {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.45); opacity: 0; }
}

/* Panel */
.eai-panel {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 9999;
  width: min(380px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 100px));
  background: var(--eai-bg-1);
  border: 1px solid var(--eai-border);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--eai-shadow);
  font-family: 'Inter', -apple-system, sans-serif;
  color: var(--eai-text);
  transform-origin: bottom right;
  animation: eai-pop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes eai-pop {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.eai-panel[hidden] { display: none !important; }

/* Header */
.eai-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(0,212,255,0.12), rgba(77,159,255,0.08));
  border-bottom: 1px solid var(--eai-border);
}
.eai-head-icon {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--eai-brand), var(--eai-brand-2));
  color: #001528;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.eai-head-spark-solo {
  font-size: 20px;
  font-variation-settings: 'FILL' 1, 'wght' 600;
  color: #001528;
  line-height: 1;
  animation: eai-spark 3s ease-in-out infinite;
}
.eai-head-title { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 15px; line-height: 1.2; }
.eai-head-sub { font-size: 11px; color: var(--eai-text-dim); display: flex; align-items: center; gap: 5px; }
.eai-head-sub .eai-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.eai-head-sub .eai-dot.eai-dot--off { background: #ef4444; box-shadow: 0 0 6px #ef4444; }
.eai-head-actions { margin-left: auto; display: flex; gap: 4px; }
.eai-icon-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--eai-text-dim);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.eai-icon-btn:hover { background: var(--eai-bg-2); color: var(--eai-text); }
.eai-icon-btn .material-symbols-rounded { font-size: 18px; }

/* Body */
.eai-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--eai-bg-0);
}
.eai-body::-webkit-scrollbar { width: 6px; }
.eai-body::-webkit-scrollbar-thumb { background: var(--eai-border); border-radius: 4px; }

/* Empty state */
.eai-empty {
  text-align: center;
  padding: 8px 0 4px;
}
.eai-empty .eai-empty-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  margin: 8px auto 12px;
  background: linear-gradient(135deg, rgba(0,212,255,0.18), rgba(77,159,255,0.1));
  display: flex; align-items: center; justify-content: center;
  color: var(--eai-brand);
}
.eai-empty .eai-empty-icon .material-symbols-rounded { font-size: 28px; }
.eai-empty h4 { font-family: 'Space Grotesk', sans-serif; font-size: 16px; margin: 0 0 6px; }
.eai-empty p { font-size: 13px; color: var(--eai-text-dim); margin: 0 0 14px; line-height: 1.5; }
.eai-suggestions { display: flex; flex-direction: column; gap: 6px; padding: 0 4px; }
.eai-suggestion {
  text-align: left;
  background: var(--eai-bg-2);
  border: 1px solid var(--eai-border);
  color: var(--eai-text);
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
  font-family: inherit;
}
.eai-suggestion:hover { border-color: var(--eai-brand); transform: translateX(2px); }

/* Messages */
.eai-msg { display: flex; gap: 8px; }
.eai-msg--user { justify-content: flex-end; }
.eai-msg-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.eai-msg--user .eai-msg-bubble {
  background: linear-gradient(135deg, var(--eai-brand), var(--eai-brand-2));
  color: #001528;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.eai-msg--assistant .eai-msg-bubble {
  background: var(--eai-bg-2);
  border: 1px solid var(--eai-border);
  color: var(--eai-text);
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.eai-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px !important;
}
.eai-typing span {
  width: 6px; height: 6px;
  background: var(--eai-text-dim);
  border-radius: 50%;
  animation: eai-bounce 1.4s ease-in-out infinite;
}
.eai-typing span:nth-child(2) { animation-delay: 0.2s; }
.eai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes eai-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Error banner */
.eai-error {
  margin: 0 16px 8px;
  padding: 9px 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.32);
  border-radius: 10px;
  color: #fca5a5;
  font-size: 12.5px;
  line-height: 1.5;
}
.eai-error a { color: inherit; font-weight: 600; }

/* Footer with CTA chips */
.eai-actions-bar {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 8px 16px;
  border-top: 1px solid var(--eai-border);
}
.eai-action-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  border-radius: 100px;
  background: var(--eai-bg-2);
  border: 1px solid var(--eai-border);
  color: var(--eai-text-dim);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
  font-family: inherit;
}
.eai-action-chip:hover { border-color: var(--eai-brand); color: var(--eai-text); }
.eai-action-chip .material-symbols-rounded { font-size: 14px; }

/* Input */
.eai-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--eai-border);
  background: var(--eai-bg-1);
}
.eai-input {
  flex: 1;
  border: 1px solid var(--eai-border);
  background: var(--eai-bg-0);
  color: var(--eai-text);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 38px;
  overflow-y: hidden;          /* JS scrollHeight > max olunca 'auto'ya çevirir */
  scrollbar-width: thin;        /* Firefox: ince */
  scrollbar-color: var(--eai-border) transparent;
  transition: border-color 0.15s ease;
}
.eai-input:focus { border-color: var(--eai-brand); }
.eai-input::placeholder { color: var(--eai-text-dim); }
/* WebKit: ince, oksuz scrollbar (varsayılan yukarı/aşağı okları kaldırır) */
.eai-input::-webkit-scrollbar { width: 6px; }
.eai-input::-webkit-scrollbar-track { background: transparent; }
.eai-input::-webkit-scrollbar-thumb { background: var(--eai-border); border-radius: 3px; }
.eai-input::-webkit-scrollbar-button { display: none; height: 0; }
.eai-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--eai-brand), var(--eai-brand-2));
  color: #001528;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.eai-send:hover:not(:disabled) { transform: scale(1.05); }
.eai-send:disabled { opacity: 0.4; cursor: not-allowed; }
.eai-send .material-symbols-rounded { font-size: 20px; }

/* Privacy footnote */
.eai-privacy {
  padding: 8px 14px 10px;
  text-align: center;
  font-size: 10.5px;
  color: var(--eai-text-dim);
  display: flex; align-items: center; justify-content: center; gap: 4px;
  background: var(--eai-bg-1);
  border-top: 1px solid var(--eai-border);
}
.eai-privacy .material-symbols-rounded { font-size: 13px; }

/* Mobile */
@media (max-width: 520px) {
  .eai-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 85vh;
    border-radius: 18px 18px 0 0;
  }
  .eai-fab { bottom: 16px; right: 16px; width: 52px; height: 52px; }
}
