/* ============================================================
   ISG Chatbot Widget - Floating Chat Assistant
   Kendi iç tasarımı - dashboard'a karışmaz
   ============================================================ */

/* === Container === */
.isg-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* === Floating Buton === */
.isg-chat-fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(30, 41, 59, 0.35), 0 2px 4px rgba(0,0,0,0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  outline: none;
}

.isg-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(30, 41, 59, 0.45), 0 4px 8px rgba(0,0,0,0.15);
}

.isg-chat-fab:active {
  transform: scale(0.95);
}

/* Buton İkonu - İnsan silueti */
.isg-chat-fab-icon {
  width: 32px;
  height: 32px;
  color: #ffffff;
  transition: all 0.3s ease;
}

.isg-chat-fab.active .isg-chat-fab-icon {
  transform: rotate(90deg);
  opacity: 0;
}

/* Kapatma ikonu */
.isg-chat-fab-close {
  position: absolute;
  width: 24px;
  height: 24px;
  color: #ffffff;
  opacity: 0;
  transform: rotate(-90deg);
  transition: all 0.3s ease;
}

.isg-chat-fab.active .isg-chat-fab-close {
  opacity: 1;
  transform: rotate(0deg);
}

/* Pulse Animasyonu */
.isg-chat-fab::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  z-index: -1;
  animation: isg-pulse 2.5s ease-in-out infinite;
}

.isg-chat-fab.active::before {
  animation: none;
  opacity: 0;
}

@keyframes isg-pulse {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.25);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

/* === Tooltip Balon === */
.isg-chat-tooltip {
  position: absolute;
  bottom: 72px;
  right: 0;
  background: #ffffff;
  color: #1e293b;
  padding: 12px 18px;
  border-radius: 12px 12px 4px 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(8px);
  animation: isg-tooltip-bounce 4s ease-in-out infinite;
  pointer-events: none;
  border: 1px solid rgba(0,0,0,0.05);
}

.isg-chat-tooltip::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 20px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-right: 1px solid rgba(0,0,0,0.05);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  transform: rotate(45deg);
}

@keyframes isg-tooltip-bounce {
  0%, 100% {
    opacity: 0;
    transform: translateY(8px);
  }
  15%, 85% {
    opacity: 1;
    transform: translateY(0);
  }
  30% {
    transform: translateY(-3px);
  }
  45% {
    transform: translateY(0);
  }
}

.isg-chat-fab.active + .isg-chat-tooltip,
.isg-chat-fab:hover + .isg-chat-tooltip {
  animation: none;
  opacity: 0;
}

/* Badge - mesaj sayısı */
.isg-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: isg-badge-pop 0.3s ease;
}

@keyframes isg-badge-pop {
  0% { transform: scale(0); }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* === Chat Kutusu === */
.isg-chat-box {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  max-height: 520px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  border: 1px solid rgba(0,0,0,0.06);
}

.isg-chat-box.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Chat Header */
.isg-chat-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.isg-chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.isg-chat-header-avatar svg {
  width: 22px;
  height: 22px;
  color: #93c5fd;
}

.isg-chat-header-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #1e293b;
}

.isg-chat-header-info h6 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
}

.isg-chat-header-info span {
  font-size: 11px;
  color: #94a3b8;
}

/* Chat Mesajları */
.isg-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 280px;
  max-height: 340px;
  background: #f8fafc;
}

.isg-chat-messages::-webkit-scrollbar {
  width: 4px;
}

.isg-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.isg-chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Mesaj Stili - Bot */
.isg-msg {
  max-width: 85%;
  animation: isg-msg-in 0.3s ease;
}

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

.isg-msg-bot {
  align-self: flex-start;
}

.isg-msg-bot .isg-msg-bubble {
  background: #ffffff;
  color: #334155;
  padding: 12px 16px;
  border-radius: 4px 16px 16px 16px;
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid #e2e8f0;
}

/* Mesaj Stili - Kullanıcı */
.isg-msg-user {
  align-self: flex-end;
}

.isg-msg-user .isg-msg-bubble {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
  font-size: 13.5px;
  line-height: 1.5;
}

/* Mesaj Zamanı */
.isg-msg-time {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 4px;
  padding: 0 4px;
}

.isg-msg-user .isg-msg-time {
  text-align: right;
}

/* Yazıyor Göstergesi */
.isg-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: #ffffff;
  border-radius: 4px 16px 16px 16px;
  border: 1px solid #e2e8f0;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.isg-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: isg-typing-anim 1.4s ease-in-out infinite;
}

.isg-typing-dot:nth-child(2) { animation-delay: 0.16s; }
.isg-typing-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes isg-typing-anim {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* Hızlı Mesajlar */
.isg-quick-msgs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
  background: #f8fafc;
}

.isg-quick-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.isg-quick-btn:hover {
  background: #1e293b;
  color: #ffffff;
  border-color: #1e293b;
  transform: translateY(-1px);
}

/* Chat Input */
.isg-chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  flex-shrink: 0;
}

.isg-chat-input input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  background: #f8fafc;
}

.isg-chat-input input:focus {
  border-color: #3b82f6;
  background: #ffffff;
}

.isg-chat-input input::placeholder {
  color: #94a3b8;
}

.isg-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.isg-chat-send:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(30, 41, 59, 0.3);
}

.isg-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.isg-chat-send svg {
  width: 18px;
  height: 18px;
}

/* Spinner */
.isg-chat-send .isg-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: isg-spin 0.6s linear infinite;
}

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

/* === Responsive === */
@media (max-width: 480px) {
  .isg-chat-box {
    width: calc(100vw - 24px);
    right: -12px;
    bottom: 68px;
    max-height: 70vh;
  }

  .isg-chat-tooltip {
    display: none;
  }

  .isg-chat-fab {
    width: 52px;
    height: 52px;
  }
}
