
/* Public profile and chat styles */
/* --- AI Chatbot Styles --- */
.chat-container {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: auto;
  margin-top: 40px;
  margin-bottom: 40px;
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-title h2 {
  font-size: 1.1rem;
  margin: 0;
  color: #1e293b;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e2e8f0;
  display: grid;
  place-items: center;
  font-size: 20px;
}

.chat-status {
  font-size: 0.8rem;
  color: #16a34a;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-status::before {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
}

.chat-messages {
  flex: 0 0 auto;
  height: clamp(420px, 58vh, 680px);
  min-height: 320px;
  max-height: 78vh;
  overflow: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  resize: vertical;
  scrollbar-gutter: stable;
}

.message {
  display: flex;
  max-width: 85%;
}

.ai-message {
  align-self: flex-start;
}

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

.message-content {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.6;
  text-align: start;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
}

.ai-message .message-content {
  background: #f1f5f9;
  color: #334155;
  border-top-right-radius: 4px;
}

.user-message .message-content {
  background: #0f172a;
  color: #ffffff;
  border-top-left-radius: 4px;
}

.message-content.is-formatted {
  display: block;
}

.message-content.is-formatted p {
  margin: 0 0 10px;
}

.message-content.is-formatted p:last-child,
.message-content.is-formatted ul:last-child,
.message-content.is-formatted ol:last-child {
  margin-bottom: 0;
}

.message-content.is-formatted h3,
.message-content.is-formatted h4,
.message-content.is-formatted h5,
.message-content.is-formatted h6 {
  margin: 12px 0 6px;
  color: #0f172a;
  line-height: 1.35;
}

.message-content.is-formatted h3:first-child,
.message-content.is-formatted h4:first-child,
.message-content.is-formatted h5:first-child,
.message-content.is-formatted h6:first-child {
  margin-top: 0;
}

.message-content.is-formatted ul,
.message-content.is-formatted ol {
  margin: 0 0 10px;
  padding-inline-start: 22px;
}

.message-content.is-formatted li {
  margin-bottom: 4px;
}

.message-content.is-formatted hr {
  border: 0;
  border-top: 1px solid #cbd5e1;
  margin: 12px 0;
}

.ai-table-wrap {
  max-width: 100%;
  margin: 10px 0;
  overflow-x: auto;
}

.ai-table {
  width: 100%;
  min-width: 360px;
  border-collapse: collapse;
  background: #ffffff;
  font-size: 0.9rem;
}

.ai-table th,
.ai-table td {
  padding: 8px 10px;
  border: 1px solid #d7dee8;
  text-align: start;
  vertical-align: top;
}

.ai-table th {
  background: #eef8f5;
  color: #0f172a;
  font-weight: 700;
}

.chat-disclaimer {
  text-align: center;
  font-size: 0.75rem;
  color: #64748b;
  padding: 8px 20px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.chat-input-area {
  padding: 16px 20px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
}

.chat-form {
  display: flex;
  gap: 10px;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  outline: none;
  text-align: right;
  unicode-bidi: plaintext;
}

.chat-input::placeholder {
  text-align: right;
}

.chat-input:focus {
  border-color: #0f172a;
}

.chat-send-btn {
  padding: 10px 20px;
  background: #0f172a;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.chat-summary-btn {
  flex: 0 0 auto;
  max-width: 260px;
  padding: 10px 14px;
  background-color: #10b981 !important;
  color: #ffffff !important;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  text-align: center;
  animation: heartPulse 2.5s infinite cubic-bezier(0.4, 0, 0.2, 1);
  transition: background-color 0.3s;
}

.chat-summary-btn:hover {
  background-color: #059669 !important;
  animation: none;
}

@keyframes heartPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  15% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  30% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
  45% { transform: scale(1.02); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.chat-header-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 10px;
}

.chat-export-menu {
  position: relative;
}

.chat-export-menu summary {
  list-style: none;
  padding: 10px 12px;
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
}

.chat-export-menu summary::-webkit-details-marker {
  display: none;
}

.chat-export-menu summary::after {
  content: '▾';
  margin-inline-start: 8px;
  font-size: 0.75rem;
}

.chat-export-options {
  position: absolute;
  z-index: 10;
  inset-inline-end: 0;
  top: calc(100% + 6px);
  min-width: 150px;
  padding: 6px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14);
}

.chat-export-options button {
  display: block;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  color: #334155;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  text-align: start;
}

.chat-export-options button:hover,
.chat-export-options button:focus {
  background: #f1f5f9;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 8px 12px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}

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

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

@media (max-width: 640px) {
  .chat-header {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-summary-btn {
    max-width: none;
    width: 100%;
  }

  .chat-header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-export-menu summary {
    text-align: center;
  }

  .chat-export-options {
    position: static;
    margin-top: 6px;
  }

  .chat-messages {
    height: min(58vh, 520px);
    min-height: 320px;
    max-height: none;
    resize: none;
  }

  .message {
    max-width: 100%;
  }

  .ai-table {
    min-width: 300px;
  }
}
