/* ============================================================
   ALGEONEX AI Chat Widget — v2 Professional
   ============================================================ */

#algeonex-chat {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  font-family: 'Inter', system-ui, sans-serif;
}

/* ── Proaktif Balon ── */
#algeonex-proactive {
  position: absolute;
  bottom: 78px;
  right: 0;
  width: 280px;
  background: #1a1a2e;
  border: 1px solid rgba(99,102,241,0.35);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(99,102,241,0.1);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

#algeonex-proactive.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
  animation: proactiveEntrance 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

#algeonex-proactive.hiding {
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  pointer-events: none;
}

@keyframes proactiveEntrance {
  0% { opacity: 0; transform: translateY(14px) scale(0.93); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.proactive-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.proactive-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.proactive-title {
  font-size: 13px;
  font-weight: 700;
  color: #f0f0ff;
  letter-spacing: -0.01em;
  margin-bottom: 3px;
}

.proactive-sub {
  font-size: 12px;
  color: #8888aa;
  line-height: 1.4;
}

#algeonex-proactive-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: #5555775;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  color: #666688;
  transition: color 0.15s;
  line-height: 1;
}
#algeonex-proactive-close:hover { color: #a0a0c0; }

/* ── Toggle Button ── */
#algeonex-chat-toggle {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(99,102,241,0.5), 0 6px 16px rgba(0,0,0,0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#algeonex-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 28px rgba(99,102,241,0.7), 0 8px 20px rgba(0,0,0,0.5);
}

#algeonex-chat-toggle:active { transform: scale(0.96); }

.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0A0A0F;
  animation: badgePulse 2.5s infinite;
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
  50% { box-shadow: 0 0 0 5px rgba(239,68,68,0); }
}

/* ── Chat Panel ── */
#algeonex-chat-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 370px;
  max-height: 540px;
  background: #0f0f1a;
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 20px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04),
    0 0 60px rgba(99,102,241,0.1),
    0 32px 80px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4,0,0.2,1), transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

#algeonex-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ── */
#algeonex-chat-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(99,102,241,0.12) 0%, rgba(139,92,246,0.08) 100%);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 11px;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(99,102,241,0.4);
}

.chat-name {
  font-size: 14px;
  font-weight: 700;
  color: #f0f0ff;
  letter-spacing: -0.02em;
}

.chat-status {
  font-size: 11px;
  color: #22C55E;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22C55E;
  animation: statusPulse 2s infinite;
  flex-shrink: 0;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

#algeonex-chat-close {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: #8888aa;
  cursor: pointer;
  font-size: 16px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.2s, color 0.2s;
}
#algeonex-chat-close:hover {
  background: rgba(255,255,255,0.11);
  color: #f0f0ff;
}

/* ── Messages Area ── */
#algeonex-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(99,102,241,0.3) transparent;
}

#algeonex-chat-messages::-webkit-scrollbar { width: 3px; }
#algeonex-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(99,102,241,0.35);
  border-radius: 3px;
}

.chat-msg {
  max-width: 86%;
  padding: 12px 15px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.7;
  word-wrap: break-word;
  animation: msgIn 0.22s ease forwards;
}

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

.chat-msg.bot {
  background: rgba(99,102,241,0.09);
  border: 1px solid rgba(99,102,241,0.18);
  color: #d8d8f5;
  align-self: flex-start;
  border-bottom-left-radius: 5px;
}

.chat-msg.user {
  background: linear-gradient(135deg, rgba(99,102,241,0.22), rgba(139,92,246,0.18));
  border: 1px solid rgba(99,102,241,0.32);
  color: #f0f0ff;
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}

.chat-msg.error {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  color: #fca5a5;
  font-size: 13px;
}

/* ── Rating ── */
.chat-rating {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 4px 0 2px 2px;
  animation: msgIn 0.2s ease;
}

.rating-label {
  font-size: 11px;
  color: #555575;
}

.rating-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  line-height: 1;
}
.rating-btn:hover {
  background: rgba(99,102,241,0.15);
  transform: scale(1.15);
}

.rating-thanks {
  font-size: 11px;
  color: #6366F1;
  font-weight: 600;
}

/* ── Typing Indicator ── */
.chat-msg.typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 14px 18px;
}

.chat-msg.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6366F1;
  animation: bounce 1.3s infinite ease-in-out;
}
.chat-msg.typing span:nth-child(2) { animation-delay: 0.18s; }
.chat-msg.typing span:nth-child(3) { animation-delay: 0.36s; }

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

/* ── Quick Replies ── */
#algeonex-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 16px 12px;
  flex-shrink: 0;
}

.quick-reply-btn {
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 20px;
  color: #9090cc;
  font-size: 12px;
  font-family: inherit;
  padding: 6px 13px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.1s;
  text-align: left;
  line-height: 1.4;
}

.quick-reply-btn:hover {
  background: rgba(99,102,241,0.18);
  border-color: rgba(99,102,241,0.5);
  color: #c0c0e8;
  transform: translateY(-1px);
}

/* ── Input Area ── */
#algeonex-chat-input-area {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  gap: 9px;
  align-items: center;
  background: #09090f;
  flex-shrink: 0;
}

.input-wrapper {
  flex: 1;
  position: relative;
}

#algeonex-chat-input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(99,102,241,0.07);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 12px;
  padding: 10px 14px;
  padding-right: 38px;
  color: #f0f0ff;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

#algeonex-chat-input:focus {
  border-color: rgba(99,102,241,0.55);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

#algeonex-chat-input::placeholder { color: #3a3a5a; }

.char-count {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  pointer-events: none;
  font-weight: 600;
}

#algeonex-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.15s;
  box-shadow: 0 3px 10px rgba(99,102,241,0.45);
}

#algeonex-chat-send:hover {
  transform: scale(1.07);
  box-shadow: 0 4px 16px rgba(99,102,241,0.6);
}

#algeonex-chat-send:active { transform: scale(0.95); }

/* ── Mobile ── */
@media (max-width: 480px) {
  #algeonex-chat {
    bottom: 16px;
    right: 16px;
  }
  #algeonex-chat-panel {
    width: calc(100vw - 24px);
    right: -4px;
    border-radius: 16px;
  }
  #algeonex-proactive {
    width: calc(100vw - 56px);
  }
}
