/* ============================================================================
   Grace Chatbot Widget — WordPress Plugin Styles
   All classes prefixed with grace- to avoid theme/plugin conflicts
   ============================================================================ */

/* Container */
#grace-chatbot {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999999;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}
#grace-chatbot.grace-pos-left {
  right: auto;
  left: 20px;
}

/* ── Floating Toggle Button ── */
.grace-toggle-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background-color: var(--grace-primary, #0E348E);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transition: transform 0.15s;
  padding: 0;
}
.grace-toggle-btn:hover { transform: scale(1.08); }
.grace-toggle-btn img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

/* ── Chat Window ── */
.grace-chat-window {
  display: none;
  width: 380px;
  height: 550px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  flex-direction: column;
  overflow: hidden;
}
.grace-chat-window.grace-open { display: flex; }

/* ── Header ── */
.grace-header {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--grace-primary, #0E348E);
  flex-shrink: 0;
}
.grace-header-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  flex-shrink: 0;
}
.grace-header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.grace-header-info { flex: 1; }
.grace-header-name { color: #fff; font-weight: 700; font-size: 16px; }
.grace-header-status { color: rgba(255,255,255,0.9); font-size: 13px; }
.grace-header-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  line-height: 0;
}
.grace-header-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ── Messages Area ── */
.grace-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f7f8fa;
}
.grace-msg {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.grace-msg.grace-user { flex-direction: row-reverse; }
.grace-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.grace-msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.grace-msg-bubble {
  max-width: 75%;
  padding: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.grace-msg.grace-assistant .grace-msg-bubble {
  background: #fff;
  color: #1f2937;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.grace-msg.grace-user .grace-msg-bubble {
  background: var(--grace-primary, #0E348E);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}
.grace-msg-bubble a { color: #2563eb; text-decoration: underline; }
.grace-msg.grace-user .grace-msg-bubble a { color: #93c5fd; }

/* ── Typing Indicator ── */
.grace-typing {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.grace-typing-dots {
  background: #fff;
  padding: 12px;
  border-radius: 16px 16px 16px 4px;
  display: flex;
  gap: 6px;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.grace-dot {
  width: 8px;
  height: 8px;
  background: #9ca3af;
  border-radius: 50%;
  animation: grace-bounce 0.6s infinite alternate;
}
.grace-dot:nth-child(2) { animation-delay: 150ms; }
.grace-dot:nth-child(3) { animation-delay: 300ms; }
@keyframes grace-bounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px); }
}

/* ── Input Area ── */
.grace-input-area {
  padding: 16px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.grace-input-row { display: flex; gap: 8px; }
.grace-input {
  flex: 1;
  padding: 10px 16px;
  border-radius: 24px;
  border: 1px solid #d1d5db;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
.grace-input:focus { border-color: #3b82f6; }
.grace-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--grace-primary, #0E348E);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.grace-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.grace-footer {
  text-align: center;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 8px;
}

/* ── Quick-Reply Chips ── */
.grace-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.grace-quick-reply-btn {
  padding: 7px 14px;
  border-radius: 18px;
  border: 1px solid var(--grace-primary, #0E348E);
  background: #fff;
  color: var(--grace-primary, #0E348E);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.grace-quick-reply-btn:hover {
  background: var(--grace-primary, #0E348E);
  color: #fff;
}

/* ── Resource Cards ── */
.grace-resource-card {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  margin-top: 8px;
  border-left: 3px solid var(--grace-primary, #0E348E);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.grace-resource-card.grace-gov { border-left-color: #16a34a; }
.grace-resource-name { font-weight: 700; font-size: 14px; color: #1f2937; }
.grace-resource-detail { font-size: 12px; color: #6b7280; margin-top: 4px; }
.grace-resource-detail a { color: #2563eb; text-decoration: none; }
.grace-resource-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.grace-badge-gov { background: #dcfce7; color: #166534; }

/* ── Crisis Action Buttons ── */
.grace-crisis-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.grace-crisis-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  background: #dc2626;
  transition: background 0.15s;
}
.grace-crisis-btn:hover { background: #b91c1c; color: #fff; }

/* ── Export Panel ── */
.grace-export-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999999;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
.grace-export-overlay.grace-open { display: flex; }
.grace-export-panel {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  padding: 24px;
}
.grace-export-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.grace-export-header h2 { font-size: 18px; color: #1e293b; margin: 0; }
.grace-export-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: #64748b;
  border-radius: 6px;
  line-height: 0;
}
.grace-export-close-btn:hover { background: #f1f5f9; color: #334155; }
.grace-export-privacy {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 16px;
  font-size: 12px;
  color: #166534;
}
.grace-export-privacy svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  fill: #16a34a;
  margin-top: 1px;
}
.grace-export-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.grace-export-tab {
  padding: 8px 14px;
  border-radius: 20px;
  border: 1.5px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  transition: all 0.15s;
  font-family: inherit;
}
.grace-export-tab:hover { border-color: var(--grace-primary, #0E348E); color: var(--grace-primary, #0E348E); }
.grace-export-tab.grace-active {
  background: var(--grace-primary, #0E348E);
  color: #fff;
  border-color: var(--grace-primary, #0E348E);
}
.grace-export-tab .grace-rec-tag {
  display: block;
  font-size: 9px;
  font-weight: 600;
  color: #16a34a;
  margin-top: 2px;
}
.grace-export-tab.grace-active .grace-rec-tag { color: #86efac; }
.grace-export-preview {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
  max-height: 180px;
  overflow-y: auto;
  font-size: 12px;
  color: #334155;
  line-height: 1.6;
  white-space: pre-wrap;
  font-family: 'Inter', system-ui, sans-serif;
}
.grace-export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.grace-export-action-btn {
  flex: 1;
  min-width: 100px;
  padding: 12px 10px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  transition: all 0.15s;
  font-family: inherit;
}
.grace-export-action-btn:hover:not(:disabled) {
  border-color: var(--grace-primary, #0E348E);
  color: var(--grace-primary, #0E348E);
  background: #f0f4ff;
}
.grace-export-action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.grace-export-action-btn svg { width: 22px; height: 22px; }
.grace-export-action-btn .grace-hint { font-size: 10px; font-weight: 400; color: #94a3b8; }
.grace-export-action-btn.grace-copied { border-color: #16a34a; color: #16a34a; background: #f0fdf4; }
.grace-export-footer {
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

/* ── Responsive ── */
@media (max-width: 420px) {
  .grace-chat-window {
    width: calc(100vw - 20px);
    height: calc(100vh - 100px);
    border-radius: 12px;
  }
  .grace-export-panel {
    max-width: calc(100vw - 32px);
  }
}
