/* İyi Finans AI Chat Widget - Scoped Styles v2.0 */
/* All styles are scoped under #iyifinans-ai-root to avoid theme conflicts */

#iyifinans-ai-root {
  --iyf-primary: #1a56db;
  --iyf-primary-dark: #1240a0;
  --iyf-accent: #0e9f6e;
  --iyf-white: #ffffff;
  --iyf-gray-50: #f9fafb;
  --iyf-gray-100: #f3f4f6;
  --iyf-gray-200: #e5e7eb;
  --iyf-gray-400: #9ca3af;
  --iyf-gray-600: #4b5563;
  --iyf-gray-800: #1f2937;
  --iyf-radius: 16px;
  --iyf-radius-sm: 8px;
  --iyf-shadow: 0 20px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.1);
  --iyf-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --iyf-transition: cubic-bezier(0.34, 1.56, 0.64, 1);
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: var(--iyf-font);
}

#iyifinans-ai-root[data-position="bottom-left"] {
  right: auto;
  left: 24px;
}

/* ── LAUNCHER ─────────────────────────────────────────────── */
#iyf-launcher {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--iyf-primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 22px 14px 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--iyf-font);
  box-shadow: 0 4px 20px rgba(26,86,219,0.45), 0 1px 4px rgba(0,0,0,0.15);
  transition: all 0.3s ease;
  position: relative;
  outline: none;
}

#iyf-launcher:hover {
  background: var(--iyf-primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(26,86,219,0.5), 0 2px 6px rgba(0,0,0,0.15);
}

#iyf-launcher:active { transform: translateY(0); }

.iyf-launcher-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.iyf-launcher-label {
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.iyf-launcher-pulse {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 12px;
  height: 12px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: iyf-pulse 2.5s infinite;
}

@keyframes iyf-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  50% { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}

/* ── CHAT WINDOW ─────────────────────────────────────────── */
#iyf-chat-window {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 110px);
  background: var(--iyf-white);
  border-radius: var(--iyf-radius);
  box-shadow: var(--iyf-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: iyf-window-in 0.38s var(--iyf-transition) both;
  border: 1px solid rgba(0,0,0,0.07);
}

#iyifinans-ai-root[data-position="bottom-left"] #iyf-chat-window {
  right: auto;
  left: 0;
  transform-origin: bottom left;
}

@keyframes iyf-window-in {
  from { opacity: 0; transform: scale(0.85) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── HEADER ─────────────────────────────────────────────── */
.iyf-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--iyf-primary);
  color: #fff;
  flex-shrink: 0;
}

.iyf-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.iyf-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  position: relative;
  flex-shrink: 0;
}

.iyf-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}


  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid var(--iyf-primary);
}

.iyf-header-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.iyf-header-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.iyf-header-status {
  font-size: 11px;
  color: rgba(255,255,255,0.75);
}

.iyf-header-actions {
  display: flex;
  gap: 4px;
}

.iyf-header-btn {
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.iyf-header-btn:hover {
  background: rgba(255,255,255,0.28);
}

/* ── MESSAGES ─────────────────────────────────────────────── */
.iyf-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.iyf-messages::-webkit-scrollbar { width: 4px; }
.iyf-messages::-webkit-scrollbar-track { background: transparent; }
.iyf-messages::-webkit-scrollbar-thumb { background: var(--iyf-gray-200); border-radius: 4px; }

.iyf-message {
  display: flex;
  flex-direction: column;
  gap: 3px;
  animation: iyf-msg-in 0.25s ease-out both;
}

@keyframes iyf-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.iyf-message.iyf-user {
  align-items: flex-end;
}

.iyf-message.iyf-ai {
  align-items: flex-start;
}

.iyf-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
}

.iyf-user .iyf-bubble {
  background: var(--iyf-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.iyf-ai .iyf-bubble {
  background: var(--iyf-gray-100);
  color: var(--iyf-gray-800);
  border-bottom-left-radius: 4px;
}

.iyf-bubble p { margin: 0 0 6px; }
.iyf-bubble p:last-child { margin: 0; }
.iyf-bubble ul, .iyf-bubble ol { margin: 4px 0 4px 18px; padding: 0; }
.iyf-bubble li { margin-bottom: 3px; }
.iyf-bubble strong { font-weight: 600; }

.iyf-msg-time {
  font-size: 10px;
  color: var(--iyf-gray-400);
  padding: 0 4px;
}

/* ── TYPING INDICATOR ─────────────────────────────────────── */
.iyf-typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
}

.iyf-typing-dots {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--iyf-gray-100);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.iyf-typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--iyf-gray-400);
  border-radius: 50%;
  animation: iyf-bounce 1.2s infinite;
}

.iyf-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.iyf-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes iyf-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* ── SUGGESTIONS ─────────────────────────────────────────── */
.iyf-suggestions {
  padding: 8px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--iyf-gray-100);
  flex-shrink: 0;
}

.iyf-suggestion-chip {
  background: var(--iyf-gray-50);
  border: 1px solid var(--iyf-gray-200);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--iyf-gray-600);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--iyf-font);
  white-space: nowrap;
}

.iyf-suggestion-chip:hover {
  background: #eff6ff;
  border-color: var(--iyf-primary);
  color: var(--iyf-primary);
}

/* ── INPUT AREA ─────────────────────────────────────────── */
.iyf-input-area {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--iyf-gray-200);
  background: var(--iyf-white);
  flex-shrink: 0;
}

.iyf-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--iyf-gray-50);
  border: 1.5px solid var(--iyf-gray-200);
  border-radius: 12px;
  padding: 8px 10px 8px 14px;
  transition: border-color 0.2s;
}

.iyf-input-wrapper:focus-within {
  border-color: var(--iyf-primary);
  background: #fff;
}

#iyf-user-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 14px;
  font-family: var(--iyf-font);
  color: var(--iyf-gray-800);
  max-height: 100px;
  line-height: 1.5;
  padding: 0;
  overflow-y: auto;
}

#iyf-user-input::placeholder { color: var(--iyf-gray-400); }

#iyf-send-btn {
  width: 34px;
  height: 34px;
  background: var(--iyf-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

#iyf-send-btn:hover:not(:disabled) {
  background: var(--iyf-primary-dark);
  transform: scale(1.05);
}

#iyf-send-btn:disabled {
  background: var(--iyf-gray-200);
  cursor: not-allowed;
}

.iyf-input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
  padding: 0 2px;
}

.iyf-char-count {
  font-size: 10px;
  color: var(--iyf-gray-400);
}

.iyf-powered {
  font-size: 10px;
  color: var(--iyf-gray-400);
}

/* ── ERROR MESSAGES ─────────────────────────────────────── */
.iyf-error-bubble {
  background: #fef2f2;
  border: 1px solid #fee2e2;
  color: #b91c1c;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  max-width: 82%;
}

/* ── MOBILE ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  #iyifinans-ai-root {
    bottom: 16px;
    right: 16px;
  }

  #iyf-chat-window {
    width: calc(100vw - 32px);
    height: calc(100vh - 90px);
    max-height: calc(100vh - 90px);
    bottom: 66px;
    right: -16px;
    border-radius: 16px 16px 0 0;
  }

  #iyifinans-ai-root[data-position="bottom-left"] #iyf-chat-window {
    left: -16px;
    right: auto;
  }
}
