/* ==========================================================================
   Floating AI Assistant Widget - Inspektorat Daerah Kabupaten Natuna
   ========================================================================== */
:root {
  --npu-ai-primary: #047857;
  --npu-ai-primary-dark: #064e3b;
  --npu-ai-primary-light: #10b981;
  --npu-ai-bg: #ffffff;
  --npu-ai-text: #0f172a;
  --npu-ai-muted: #64748b;
  --npu-ai-border: #e2e8f0;
}

#npu-ai-widget {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--npu-ai-text);
  box-sizing: border-box;
}

#npu-ai-widget * {
  box-sizing: border-box;
}

/* Floating Action Button */
#npu-ai-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99990;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 14px;
  background: linear-gradient(135deg, #047857 0%, #064e3b 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  box-shadow: 0 10px 25px -3px rgba(4, 120, 87, 0.4), 0 4px 10px -2px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

#npu-ai-trigger:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 16px 32px -4px rgba(4, 120, 87, 0.5), 0 6px 14px -3px rgba(0, 0, 0, 0.15);
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

#npu-ai-trigger:active {
  transform: translateY(-1px);
}

.npu-ai-trigger-icon {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #a7f3d0;
}

.npu-ai-trigger-dot {
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #064e3b;
  box-shadow: 0 0 8px #10b981;
  animation: npuAiPulse 2s infinite;
}

@keyframes npuAiPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.npu-ai-trigger-label {
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.2px;
}

/* Chat Popover Window */
#npu-ai-window {
  position: fixed;
  bottom: 84px;
  right: 24px;
  z-index: 99995;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: #ffffff;
  border-radius: 24px;
  border: 1px solid #cbd5e1;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.3), 0 10px 25px -5px rgba(4, 120, 87, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
}

#npu-ai-window.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header */
.npu-ai-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #064e3b 0%, #047857 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.npu-ai-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.npu-ai-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #ffffff;
  padding: 4px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.npu-ai-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.npu-ai-header-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  color: #ffffff;
  margin: 0;
}

.npu-ai-header-subtitle {
  font-size: 11.5px;
  color: #a7f3d0;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.npu-ai-header-subtitle::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
}

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

.npu-ai-btn-icon {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 13px;
  text-decoration: none;
}

.npu-ai-btn-icon:hover {
  background: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}

/* Quick Chips */
.npu-ai-chips-wrap {
  padding: 10px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
}

.npu-ai-chips-wrap::-webkit-scrollbar {
  height: 4px;
}

.npu-ai-chips-wrap::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.npu-ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 9999px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  margin-right: 6px;
  transition: all 0.15s ease;
}

.npu-ai-chip:hover {
  background: #ecfdf5;
  color: #047857;
  border-color: #34d399;
}

/* Messages Feed */
.npu-ai-feed {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.npu-ai-msg {
  max-width: 88%;
  display: flex;
  flex-direction: column;
  animation: msgSlideIn 0.2s ease-out;
}

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

.npu-ai-msg--user {
  align-self: flex-end;
}

.npu-ai-msg--assistant {
  align-self: flex-start;
}

.npu-ai-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
}

.npu-ai-msg--user .npu-ai-bubble {
  background: #047857;
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 10px rgba(4, 120, 87, 0.2);
}

.npu-ai-msg--assistant .npu-ai-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.npu-ai-bubble h3 {
  font-size: 14px;
  font-weight: 800;
  color: #047857;
  margin: 0 0 6px 0;
}

.npu-ai-bubble p {
  margin: 0 0 8px 0;
}

.npu-ai-bubble p:last-child {
  margin-bottom: 0;
}

.npu-ai-bubble ul, .npu-ai-bubble ol {
  margin: 4px 0 8px 0;
  padding-left: 20px;
}

.npu-ai-bubble li {
  margin-bottom: 4px;
}

.npu-ai-bubble a {
  color: #0284c7;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.npu-ai-bubble a:hover {
  color: #0369a1;
}

.npu-ai-sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.npu-ai-sources-label {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.npu-ai-source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #047857 !important;
  text-decoration: none !important;
  padding: 4px 8px;
  background: #ecfdf5;
  border-radius: 6px;
  border: 1px solid #a7f3d0;
  transition: all 0.15s;
}

.npu-ai-source-link:hover {
  background: #d1fae5;
  border-color: #34d399;
}

.npu-ai-governance-meta {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(15, 118, 110, .16);
  color: #64748b;
  font-size: 11px;
  line-height: 1.45;
}

/* Typing Indicator */
.npu-ai-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.npu-ai-typing span {
  width: 6px;
  height: 6px;
  background: #047857;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.npu-ai-typing span:nth-child(1) { animation-delay: -0.32s; }
.npu-ai-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Composer Form */
.npu-ai-composer {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.npu-ai-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-family: inherit;
  color: #0f172a;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #f8fafc;
}

.npu-ai-input:focus {
  border-color: #047857;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.15);
}

.npu-ai-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #047857;
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.npu-ai-send-btn:hover {
  background: #065f46;
  transform: scale(1.04);
}

.npu-ai-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Mobile responsive */
@media (max-width: 480px) {
  #npu-ai-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 85vh;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
  }
  #npu-ai-trigger {
    bottom: 16px;
    right: 16px;
    padding: 10px 14px;
  }
}
