/* ==========================================================================
   SI-JDIH Virtual Assistant - Premium AI Chatbot Widget Styles
   JDIH DPRD Kabupaten Gunungkidul
   ========================================================================== */

:root {
  --jdih-primary: #0d47a1;
  --jdih-primary-dark: #082d6c;
  --jdih-primary-light: #1976d2;
  --jdih-accent: #f59e0b;
  --jdih-accent-hover: #d97706;
  --jdih-bg-light: #f8fafc;
  --jdih-bubble-user: #0d47a1;
  --jdih-bubble-bot: #ffffff;
  --jdih-text-dark: #1e293b;
  --jdih-text-muted: #64748b;
  --jdih-border: #e2e8f0;
  --jdih-radius-lg: 18px;
  --jdih-radius-md: 12px;
  --jdih-radius-sm: 8px;
  --jdih-shadow-modal: 0 20px 40px -15px rgba(13, 71, 161, 0.25), 0 0 20px rgba(0, 0, 0, 0.08);
  --jdih-shadow-btn: 0 10px 25px -5px rgba(13, 71, 161, 0.4);
}

/* Floating Trigger Button */
.jdih-chat-trigger {
  position: fixed;
  bottom: 25px;
  right: 25px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--jdih-primary) 0%, var(--jdih-primary-dark) 100%);
  color: #ffffff !important;
  border: none;
  border-radius: 50px;
  padding: 12px 20px 12px 16px;
  cursor: pointer;
  box-shadow: var(--jdih-shadow-btn);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: 'Poppins', 'Roboto', sans-serif;
  font-weight: 600;
  font-size: 14px;
}

.jdih-chat-trigger:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 15px 30px -5px rgba(13, 71, 161, 0.5);
  color: #ffffff;
}

.jdih-chat-trigger:active {
  transform: translateY(0) scale(0.98);
}

.jdih-chat-trigger .trigger-icon-box {
  position: relative;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.jdih-chat-trigger .trigger-pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.jdih-chat-trigger .trigger-pulse-ring {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border: 2px solid #10b981;
  border-radius: 50%;
  animation: jdih-pulse-anim 2s infinite;
  opacity: 0.8;
}

@keyframes jdih-pulse-anim {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* Chat Modal Container */
.jdih-chat-window {
  position: fixed;
  bottom: 95px;
  right: 25px;
  width: 390px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: var(--jdih-radius-lg);
  box-shadow: var(--jdih-shadow-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9995;
  border: 1px solid rgba(226, 232, 240, 0.8);
  opacity: 0;
  visibility: hidden;
  transform: translateY(25px) scale(0.95);
  transform-origin: bottom right;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Poppins', 'Roboto', sans-serif;
}

.jdih-chat-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

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

.jdih-chat-header-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.jdih-chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--jdih-primary);
  font-size: 22px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.jdih-chat-header-info h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.jdih-chat-header-info .status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 3px;
}

.jdih-chat-header-info .status-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px #10b981;
}

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

.jdih-chat-header-actions button {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  font-size: 14px;
}

.jdih-chat-header-actions button:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

/* Chat Messages Body */
.jdih-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--jdih-bg-light);
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
.jdih-chat-body::-webkit-scrollbar {
  width: 6px;
}
.jdih-chat-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

/* Chat Bubble Container */
.jdih-msg-row {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: jdih-msg-fade 0.3s ease forwards;
}

@keyframes jdih-msg-fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.jdih-msg-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.jdih-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--jdih-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

.jdih-msg-bubble {
  padding: 12px 16px;
  border-radius: var(--jdih-radius-md);
  font-size: 13.5px;
  line-height: 1.55;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  word-break: break-word;
}

.jdih-msg-row.bot .jdih-msg-bubble {
  background: var(--jdih-bubble-bot);
  color: var(--jdih-text-dark);
  border-top-left-radius: 2px;
  border: 1px solid var(--jdih-border);
}

.jdih-msg-row.user .jdih-msg-bubble {
  background: linear-gradient(135deg, var(--jdih-primary) 0%, var(--jdih-primary-light) 100%);
  color: #ffffff;
  border-top-right-radius: 2px;
}

.jdih-msg-time {
  font-size: 10px;
  margin-top: 5px;
  display: block;
  opacity: 0.7;
}

.jdih-msg-row.user .jdih-msg-time {
  text-align: right;
  color: rgba(255, 255, 255, 0.85);
}

.jdih-msg-row.bot .jdih-msg-time {
  color: var(--jdih-text-muted);
}

/* Document Cards Inside Chat */
.jdih-doc-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

.jdih-doc-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 4px solid var(--jdih-primary);
  border-radius: var(--jdih-radius-sm);
  padding: 10px 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s, box-shadow 0.2s;
}

.jdih-doc-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(13, 71, 161, 0.1);
  border-color: #cbd5e1;
}

.jdih-doc-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.jdih-doc-card-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
}

.jdih-doc-card-nomor {
  font-size: 11px;
  font-weight: 600;
  color: var(--jdih-primary);
}

.jdih-doc-card-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--jdih-text-dark);
  margin-bottom: 8px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.jdih-doc-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.jdih-doc-card-actions a {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 6px;
  text-decoration: none !important;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.2s;
}

.jdih-btn-view {
  background: #eff6ff;
  color: var(--jdih-primary) !important;
  border: 1px solid #bfdbfe;
}
.jdih-btn-view:hover {
  background: var(--jdih-primary);
  color: #ffffff !important;
}

.jdih-btn-download {
  background: #f0fdf4;
  color: #166534 !important;
  border: 1px solid #bbf7d0;
}
.jdih-btn-download:hover {
  background: #16a34a;
  color: #ffffff !important;
}

/* Quick Suggestion Chips Area */
.jdih-chat-suggestions {
  padding: 10px 16px 6px 16px;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.jdih-chat-suggestions::-webkit-scrollbar {
  display: none;
}

.jdih-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  font-size: 12px;
  color: var(--jdih-text-dark);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  font-weight: 500;
}

.jdih-chip:hover {
  background: #e0f2fe;
  color: var(--jdih-primary);
  border-color: #bae6fd;
  transform: translateY(-1px);
}

/* Typing Indicator Animation */
.jdih-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: var(--jdih-bubble-bot);
  border: 1px solid var(--jdih-border);
  border-radius: var(--jdih-radius-md);
  border-top-left-radius: 2px;
  width: fit-content;
}

.jdih-typing-indicator span {
  width: 7px;
  height: 7px;
  background: var(--jdih-primary-light);
  border-radius: 50%;
  animation: jdih-bounce 1.4s infinite ease-in-out both;
}

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

@keyframes jdih-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Chat Input Bar */
.jdih-chat-footer {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid var(--jdih-border);
}

.jdih-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--jdih-bg-light);
  border: 1.5px solid #e2e8f0;
  border-radius: 25px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.jdih-chat-form:focus-within {
  border-color: var(--jdih-primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(13, 71, 161, 0.12);
}

.jdih-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--jdih-text-dark);
  padding: 6px 0;
}

.jdih-chat-input::placeholder {
  color: var(--jdih-text-muted);
}

.jdih-chat-submit {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--jdih-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.jdih-chat-submit:hover:not(:disabled) {
  background: var(--jdih-primary-dark);
  transform: scale(1.05);
}

.jdih-chat-submit:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.jdih-chat-branding {
  text-align: center;
  font-size: 10px;
  color: var(--jdih-text-muted);
  margin-top: 6px;
}

/* Responsive Styles */
@media (max-width: 576px) {
  .jdih-chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }

  .jdih-chat-trigger {
    bottom: 20px;
    right: 15px;
    padding: 10px 16px 10px 12px;
    font-size: 13px;
  }
}
