/****************************************************
 * "Ask MEZTech" chat widget — MEZTech Design System
 ****************************************************/

.mez-chat-bubble {
  position: fixed;
  bottom: var(--mez-space-6, 1.5rem);
  right: var(--mez-space-6, 1.5rem);
  z-index: 1050;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--mez-primary, #4f46e5), var(--mez-accent, #06b6d4));
  color: #fff;
  font-size: 1.4rem;
  box-shadow: var(--mez-shadow-lg, 0 10px 25px rgba(0, 0, 0, 0.25));
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mez-chat-bubble:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 14px 30px rgba(79, 70, 229, 0.4);
}

.mez-chat-panel {
  position: fixed;
  bottom: calc(var(--mez-space-6, 1.5rem) + 68px);
  right: var(--mez-space-6, 1.5rem);
  z-index: 1050;
  width: 380px;
  max-width: calc(100vw - 2rem);
  height: 520px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  background: var(--mez-white, #fff);
  border-radius: var(--mez-radius-lg, 16px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  border: 1px solid var(--mez-gray-200, #e5e7eb);
}

.mez-chat-panel[hidden] { display: none; }

.mez-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, var(--mez-primary, #4f46e5), #312e81);
  color: #fff;
}

.mez-chat-title {
  font-weight: var(--mez-font-weight-bold, 700);
  font-size: var(--mez-font-size-base, 1rem);
}

.mez-chat-sublabel {
  font-size: 0.7rem;
  opacity: 0.75;
}

.mez-chat-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.mez-chat-icon-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.8;
  padding: 0.25rem;
}

.mez-chat-icon-btn:hover { opacity: 1; }

.mez-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--mez-gray-50, #f9fafb);
}

.mez-chat-msg {
  max-width: 85%;
  padding: 0.6rem 0.85rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.mez-chat-msg.user {
  align-self: flex-end;
  background: var(--mez-primary, #4f46e5);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.mez-chat-msg.assistant {
  align-self: flex-start;
  background: var(--mez-white, #fff);
  color: var(--mez-gray-800, #1f2937);
  border: 1px solid var(--mez-gray-200, #e5e7eb);
  border-bottom-left-radius: 4px;
}

.mez-chat-msg.assistant p { margin: 0 0 0.5rem; }
.mez-chat-msg.assistant p:last-child { margin-bottom: 0; }
.mez-chat-msg.assistant a { color: var(--mez-primary, #4f46e5); }
.mez-chat-msg.assistant ul, .mez-chat-msg.assistant ol { margin: 0.4rem 0; padding-left: 1.2rem; }
.mez-chat-msg.assistant code {
  background: var(--mez-gray-100, #f3f4f6);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.mez-chat-msg.error {
  align-self: flex-start;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.mez-chat-msg.error a { color: #991b1b; font-weight: 600; }

.mez-chat-retry {
  display: inline-block;
  margin-top: 0.4rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid #991b1b;
  border-radius: 999px;
  background: none;
  color: #991b1b;
  font-size: 0.8rem;
  cursor: pointer;
}

.mez-chat-typing {
  align-self: flex-start;
  color: var(--mez-gray-500, #6b7280);
  font-size: 0.85rem;
  font-style: italic;
  padding: 0.3rem 0.85rem;
}

.mez-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--mez-gray-200, #e5e7eb);
  background: var(--mez-white, #fff);
}

.mez-chat-chips:empty { display: none; }

.mez-chat-chip {
  border: 1px solid var(--mez-primary, #4f46e5);
  color: var(--mez-primary, #4f46e5);
  background: none;
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mez-chat-chip:hover {
  background: var(--mez-primary, #4f46e5);
  color: #fff;
}

.mez-chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--mez-gray-200, #e5e7eb);
  background: var(--mez-white, #fff);
}

.mez-chat-form input {
  flex: 1;
  border: 1px solid var(--mez-gray-300, #d1d5db);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  outline: none;
}

.mez-chat-form input:focus {
  border-color: var(--mez-primary, #4f46e5);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.mez-chat-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--mez-primary, #4f46e5);
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
}

.mez-chat-send:disabled { opacity: 0.5; cursor: default; }

/* Clear-chat confirmation overlay */
.mez-chat-confirm {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 15, 30, 0.55);
}

.mez-chat-confirm[hidden] { display: none; }

.mez-chat-confirm-card {
  background: var(--mez-white, #fff);
  border-radius: var(--mez-radius-lg, 16px);
  padding: 1.25rem;
  max-width: 300px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.mez-chat-confirm-title {
  font-weight: var(--mez-font-weight-bold, 700);
  font-size: 0.95rem;
  color: var(--mez-gray-800, #1f2937);
  margin-bottom: 0.5rem;
}

.mez-chat-confirm-text {
  font-size: 0.85rem;
  color: var(--mez-gray-600, #4b5563);
  line-height: 1.5;
  margin: 0 0 1rem;
}

.mez-chat-confirm-btns {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.mez-chat-confirm-btn {
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid var(--mez-gray-300, #d1d5db);
  background: none;
  color: var(--mez-gray-700, #374151);
}

.mez-chat-confirm-btn.delete {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

.mez-chat-confirm-btn.delete:hover { background: #b91c1c; }

/* Inline "Ask about this article" button (blog hero band) */
.mez-chat-ask-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: var(--mez-space-4, 1rem);
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.mez-chat-ask-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: var(--mez-accent, #06b6d4);
}

/* Mobile: full-screen panel */
@media (max-width: 576px) {
  .mez-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .mez-chat-bubble {
    bottom: 1rem;
    right: 1rem;
  }
}
