/* ==============================================================
   EPJ SMART AI ASSISTANT - REACT COMPONENT STYLING
   Yayasan Era Pembangunan Jaya (SMK, SMP, PKBM)
   ============================================================== */

/* Floating Launcher Button */
.epj-ai-launcher {
  position: fixed;
  bottom: 84px;
  right: 20px;
  z-index: 99995;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #ffffff !important;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1.5px solid rgba(245, 158, 11, 0.6);
  box-shadow: 0 8px 25px rgba(15, 23, 42, 0.45), 0 0 15px rgba(245, 158, 11, 0.25);
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  outline: none !important;
}
.epj-ai-launcher:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.6), 0 0 22px rgba(245, 158, 11, 0.45);
  border-color: #fbbf24;
}
.epj-ai-launcher-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0b132b;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}
.epj-ai-launcher-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background: #10b981;
  border: 2px solid #0f172a;
  border-radius: 50%;
  animation: epjPulseDot 2s infinite ease-in-out;
}
@keyframes epjPulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* Chatbot Modal Container */
.epj-ai-chat-window {
  position: fixed;
  bottom: 88px;
  right: 20px;
  width: 430px;
  max-width: calc(100vw - 24px);
  height: 635px;
  max-height: calc(100vh - 104px);
  z-index: 999999;
  background: rgba(15, 23, 42, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55), 0 0 30px rgba(30, 58, 138, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: inherit;
  color: #f8fafc;
  animation: epjSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes epjSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.epj-ai-header {
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.95) 0%, rgba(15, 23, 42, 0.95) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.epj-ai-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.epj-ai-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}
.epj-ai-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.epj-ai-header-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
}
.epj-ai-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #38bdf8;
  font-weight: 600;
}
.epj-ai-header-status .live-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}
.epj-ai-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.epj-ai-header-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 15px;
  outline: none !important;
}
.epj-ai-header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* Chat Messages Body */
.epj-ai-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.epj-ai-body::-webkit-scrollbar {
  width: 5px;
}
.epj-ai-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}

/* Messages */
.epj-ai-msg {
  display: flex;
  gap: 8px;
  max-width: 95%;
  font-size: 13px;
  line-height: 1.55;
  animation: epjMsgFade 0.25s ease-out;
  scroll-margin-top: 8px;
}
@keyframes epjMsgFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.epj-ai-msg.bot {
  align-self: flex-start;
}
.epj-ai-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.epj-ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0f172a;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}
.epj-ai-msg.user .epj-ai-msg-avatar {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #ffffff;
}
.epj-ai-msg-bubble {
  padding: 12px 15px;
  border-radius: 16px;
  word-break: break-word;
  line-height: 1.58;
  font-size: 13px;
}
.epj-ai-line {
  line-height: 1.58;
  margin-bottom: 2px;
}
.epj-ai-line-spacer {
  height: 8px;
}
.epj-ai-msg.bot .epj-ai-msg-bubble {
  background: rgba(30, 41, 59, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  border-top-left-radius: 4px;
}
.epj-ai-msg.bot .epj-ai-msg-bubble strong {
  font-weight: 700;
  color: #38bdf8;
}
.epj-ai-msg.bot .epj-ai-msg-bubble em {
  font-style: italic;
  color: #94a3b8;
}
.epj-ai-msg.user .epj-ai-msg-bubble {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.epj-ai-msg.user .epj-ai-msg-bubble strong {
  font-weight: 700;
  color: #fef08a;
}

/* Direct Action Buttons inside Bot Reply */
.epj-ai-actions-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
  margin-bottom: 4px;
}
.epj-ai-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 13px;
  border-radius: 999px;
  text-decoration: none !important;
  transition: all 0.2s ease;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}
.epj-ai-action-primary {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0f172a !important;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.epj-ai-action-primary:hover {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: #000000 !important;
  transform: translateY(-1px);
}
.epj-ai-action-wa {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  color: #ffffff !important;
  border: 1px solid rgba(74, 222, 128, 0.35);
}
.epj-ai-action-wa:hover {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #ffffff !important;
  transform: translateY(-1px);
}
.epj-ai-action-secondary {
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8 !important;
  border: 1px solid rgba(56, 189, 248, 0.4);
}
.epj-ai-action-secondary:hover {
  background: rgba(56, 189, 248, 0.28);
  color: #7dd3fc !important;
  transform: translateY(-1px);
}

/* Typing Indicator */
.epj-ai-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  border-top-left-radius: 4px;
  align-self: flex-start;
}
.epj-ai-typing span {
  width: 6px;
  height: 6px;
  background: #38bdf8;
  border-radius: 50%;
  animation: epjBounceDot 1.4s infinite ease-in-out both;
}
.epj-ai-typing span:nth-child(1) { animation-delay: -0.32s; }
.epj-ai-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes epjBounceDot {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Quick Suggestion Chips */
.epj-ai-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.epj-ai-chip {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.epj-ai-chip:hover {
  background: rgba(245, 158, 11, 0.3);
  border-color: #f59e0b;
  transform: translateY(-1px);
}

/* Footer / Input Area */
.epj-ai-footer {
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.98);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.epj-ai-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.25s ease;
}
.epj-ai-input-form:focus-within {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}
.epj-ai-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 13.5px;
  padding: 6px 0;
}
.epj-ai-input::placeholder {
  color: #94a3b8;
  font-size: 12.5px;
}
.epj-ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border: none;
  color: #0b132b;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none !important;
  flex-shrink: 0;
}
.epj-ai-send-btn:hover:not(:disabled) {
  transform: scale(1.06);
  background: #fbbf24;
}
.epj-ai-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Small WA link footer */
.epj-ai-wa-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: #94a3b8;
  margin-top: 8px;
  text-decoration: none;
}
.epj-ai-wa-link a {
  color: #22c55e;
  font-weight: 700;
  text-decoration: none;
}
.epj-ai-wa-link a:hover {
  text-decoration: underline;
}

/* Mobile Responsiveness */
@media (max-width: 576px) {
  .epj-ai-launcher {
    bottom: 78px;
    right: 14px;
    padding: 10px 14px;
    font-size: 12.5px;
  }
  .epj-ai-chat-window {
    bottom: 12px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    height: calc(100vh - 24px);
    max-height: none;
    border-radius: 18px;
  }
}
