/* JDIH AI Legal Consultation Widget Styles */
:root {
  --jdih-primary: #1e3a8a;
  --jdih-primary-hover: #1e40af;
  --jdih-primary-dark: #0f172a;
  --jdih-accent: #0284c7;
  --jdih-accent-gold: #d97706;
  --jdih-bg: #f8fafc;
  --jdih-card-bg: #ffffff;
  --jdih-text: #1e293b;
  --jdih-text-muted: #64748b;
  --jdih-border: #e2e8f0;
  --jdih-bot-msg: #f1f5f9;
  --jdih-user-msg: #1e3a8a;
  --jdih-radius: 16px;
  --jdih-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

/* Floating Launcher Button */
.jdih-widget-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--jdih-primary) 0%, var(--jdih-accent) 100%);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(30, 58, 138, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.jdih-widget-launcher:hover {
  transform: scale(1.08) rotate(5deg);
  box-shadow: 0 12px 28px rgba(30, 58, 138, 0.45);
}

.jdih-widget-launcher svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

.jdih-launcher-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: var(--jdih-accent-gold);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 10px;
  border: 2px solid white;
}

/* Main Chat Container */
.jdih-chat-container {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 400px;
  height: 600px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  background: var(--jdih-card-bg);
  border-radius: var(--jdih-radius);
  box-shadow: var(--jdih-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid var(--jdih-border);
}

.jdih-chat-container.jdih-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.jdih-header {
  background: linear-gradient(135deg, var(--jdih-primary-dark) 0%, var(--jdih-primary) 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.jdih-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.jdih-header-avatar svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.jdih-header-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.3px;
}

.jdih-header-subtitle {
  font-size: 11px;
  color: #93c5fd;
  margin: 2px 0 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.jdih-status-dot {
  width: 7px;
  height: 7px;
  background-color: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 8px #22c55e;
}

.jdih-close-btn {
  background: transparent;
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.jdih-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Chat Body */
.jdih-messages-area {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background-color: var(--jdih-bg);
}

/* Message Bubbles */
.jdih-message {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: jdihFadeIn 0.3s ease;
}

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

.jdih-message.jdih-user {
  align-self: flex-end;
}

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

.jdih-bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.jdih-user .jdih-bubble {
  background-color: var(--jdih-user-msg);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.jdih-bot .jdih-bubble {
  background-color: var(--jdih-card-bg);
  color: var(--jdih-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--jdih-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

/* Citations & Sources Box */
.jdih-sources-box {
  margin-top: 10px;
  padding: 10px 12px;
  background-color: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.jdih-sources-title {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.jdih-source-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 4px 10px;
  background-color: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  text-decoration: none;
  margin: 3px 3px 3px 0;
  transition: all 0.2s;
  font-weight: 500;
}

.jdih-source-chip:hover {
  background-color: #dbeafe;
  border-color: #93c5fd;
  transform: translateY(-1px);
}

/* Suggestion Chips */
.jdih-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.jdih-suggestion-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 11.5px;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.jdih-suggestion-chip:hover {
  background: #eff6ff;
  color: var(--jdih-primary);
  border-color: #93c5fd;
}

/* Typing Indicator */
.jdih-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid var(--jdih-border);
  width: fit-content;
  max-width: 85%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  animation: jdihFadeIn 0.3s ease;
}

.jdih-typing-text {
  font-size: 12px;
  color: #475569;
  font-weight: 500;
}

.jdih-typing-dots {
  display: flex;
  align-items: center;
  gap: 3px;
}

.jdih-typing-dot {
  width: 5px;
  height: 5px;
  background-color: var(--jdih-primary);
  border-radius: 50%;
  animation: jdihBounce 1.4s infinite ease-in-out both;
}

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

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

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

.jdih-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.jdih-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--jdih-border);
  border-radius: 24px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s;
  background: #f8fafc;
}

.jdih-input:focus {
  border-color: var(--jdih-accent);
  background: #fff;
}

.jdih-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--jdih-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.jdih-send-btn:hover:not(:disabled) {
  background: var(--jdih-primary-hover);
}

.jdih-send-btn.jdih-btn-stop {
  background: #dc2626;
  animation: jdihPulse 1.5s infinite ease-in-out;
}

.jdih-send-btn.jdih-btn-stop:hover {
  background: #b91c1c;
}

@keyframes jdihPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.jdih-stop-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
  border: 1px solid #fca5a5;
  transition: all 0.2s;
  animation: jdihFadeIn 0.2s ease;
}

.jdih-stop-bar:hover {
  background: #fecaca;
  transform: translateY(-1px);
}

.jdih-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.jdih-disclaimer-note {
  font-size: 10px;
  color: var(--jdih-text-muted);
  text-align: center;
  margin-top: 8px;
}
