/* ==========================================================================
   Albert Solar Power (ASP) — AI RAG Chatbot Widget Styles
   ========================================================================== */

:root {
  --asp-chat-primary: #0052cc;
  --asp-chat-primary-hover: #003fa8;
  --asp-chat-gold: #f59e0b;
  --asp-chat-dark: #0f172a;
  --asp-chat-light: #f8fafc;
  --asp-chat-border: #e2e8f0;
}

/* Floating Launcher Button */
.asp-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #0052cc 0%, #003580 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 12px 20px 12px 14px;
  border-radius: 9999px;
  box-shadow: 0 10px 25px -5px rgba(0, 82, 204, 0.4), 0 8px 10px -6px rgba(0, 82, 204, 0.3);
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.asp-chat-launcher:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 14px 30px -4px rgba(0, 82, 204, 0.5);
  background: linear-gradient(135deg, #005ce6 0%, #003fa8 100%);
}

.asp-chat-launcher:active {
  transform: translateY(0) scale(0.98);
}

.asp-launcher-icon {
  width: 34px;
  height: 34px;
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  position: relative;
}

.asp-launcher-pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  background: #22c55e;
  border: 2px solid #ffffff;
  border-radius: 50%;
  animation: aspPulse 2s infinite;
}

@keyframes aspPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.asp-launcher-text {
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* Chat Popup Window */
.asp-chat-window {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.06);
  z-index: 9995;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  animation: aspChatSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes aspChatSlideUp {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.asp-chat-window.open {
  display: flex;
}

/* Header */
.asp-chat-header {
  background: linear-gradient(135deg, #0052cc 0%, #0a2540 100%);
  color: #ffffff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.asp-header-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.asp-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: #ffffff;
  color: #0b1f4d;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.asp-header-info h4 {
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.asp-header-info p {
  margin: 3px 0 0;
  font-size: 12px;
  color: #93c5fd;
  display: flex;
  align-items: center;
  gap: 6px;
}

.asp-status-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
}

.asp-chat-close-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.2s;
}

.asp-chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Chat Messages Container */
.asp-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Message Bubbles */
.asp-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: aspMsgFade 0.2s ease-out;
}

@keyframes aspMsgFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.asp-msg.bot {
  align-self: flex-start;
}

.asp-msg.user {
  align-self: flex-end;
}

.asp-bubble {
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

.asp-msg.bot .asp-bubble {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.asp-msg.bot .asp-bubble strong {
  color: #0052cc;
}

.asp-msg.user .asp-bubble {
  background: #0052cc;
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 82, 204, 0.25);
}

/* Agent (Engr. Albert Teria) Direct Reply Bubble */
.asp-msg.agent {
  align-self: flex-start;
}

.asp-msg.agent .asp-bubble {
  background: #f0fdf4;
  color: #0f172a;
  border: 1.5px solid #86efac;
  border-bottom-left-radius: 4px;
  box-shadow: 0 3px 10px rgba(34, 197, 94, 0.15);
}

.asp-agent-badge {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 5px;
  background: #16a34a;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 9999px;
  margin-bottom: 7px;
  letter-spacing: 0.2px;
}

.asp-chip.asp-chip-albert {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
  font-weight: 700;
}

.asp-chip.asp-chip-albert:hover {
  background: #fde68a;
  color: #78350f;
}

.asp-msg-time {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 4px;
  padding: 0 4px;
}

.asp-msg.user .asp-msg-time {
  text-align: right;
}

/* Quick Suggestion Chips */
.asp-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.asp-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  text-align: left;
}

.asp-chip:hover {
  background: #eff6ff;
  border-color: #0052cc;
  color: #0052cc;
  transform: translateY(-1px);
}

/* Typing Indicator */
.asp-typing {
  display: none;
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 10px 14px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  gap: 4px;
  align-items: center;
}

.asp-typing.active {
  display: flex;
}

.asp-typing-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: aspBlink 1.4s infinite both;
}

.asp-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.asp-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes aspBlink {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

/* Footer / Input Box */
.asp-chat-footer {
  padding: 12px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.asp-bubble a {
  color: #0052cc;
  font-weight: 600;
  text-decoration: underline;
  word-break: break-all;
}

.asp-msg.user .asp-bubble a {
  color: #ffffff;
}

.asp-chat-note {
  padding: 0 14px 10px;
  background: #ffffff;
  font-size: 11px;
  line-height: 1.4;
  color: #64748b;
  text-align: center;
}

.asp-chat-note a {
  color: #0052cc;
  text-decoration: underline;
}

.asp-chat-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  padding: 10px 14px;
  border-radius: 9999px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: #f8fafc;
}

.asp-chat-input:focus {
  border-color: #0052cc;
  background: #ffffff;
}

.asp-chat-send-btn {
  background: #0052cc;
  border: none;
  color: #ffffff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.asp-chat-send-btn:hover {
  background: #003fa8;
  transform: scale(1.05);
}

.asp-chat-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .asp-chat-launcher {
    bottom: 80px;
  }
}

/* Phones and tablets: 16px keeps iOS from zooming the page when the input is tapped */
@media (max-width: 1024px), (pointer: coarse) {
  .asp-chat-input {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .asp-chat-launcher {
    bottom: 80px;
    right: 16px;
    padding: 10px 16px 10px 12px;
    font-size: 13px;
  }
  .asp-chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
  }
  .asp-chat-input {
    font-size: 16px; /* Prevents auto-zoom on iOS Safari */
  }
  .asp-chat-footer {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
  }
}
