/* ReputaGuard — Chat UI styles (CleverT). */

/* Layout: sidebar + main */
.chat-layout {
  display: flex;
  height: calc(100vh - 56px); /* below topbar */
  overflow: hidden;
}

/* Sidebar */
.chat-sidebar {
  width: 280px;
  min-width: 240px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.chat-sidebar-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--ink);
}

.chat-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.chat-conv-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  margin-bottom: 2px;
  transition: background 0.15s;
}

.chat-conv-item:hover {
  background: var(--accent-soft);
}

.chat-conv-item.active {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
}

.chat-conv-title {
  font-size: 0.9rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-conv-date {
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin-top: 2px;
}

.chat-empty {
  padding: 1rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
}

/* Main chat area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  scroll-behavior: smooth;
}

/* Welcome */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--ink-soft);
}

.chat-welcome-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.chat-welcome h3 {
  margin: 0 0 0.5rem;
  color: var(--ink);
}

.chat-welcome p {
  max-width: 480px;
  margin: 0 0 0.5rem;
}

.chat-welcome-hint {
  font-size: 0.85rem;
  opacity: 0.7;
}

/* Message bubbles */
.chat-msg {
  margin-bottom: 1.25rem;
  max-width: 780px;
}

.chat-msg-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.chat-msg-label {
  font-weight: 600;
  font-size: 0.85rem;
}

.chat-meta {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.chat-msg-content {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  line-height: 1.6;
  font-size: 0.92rem;
}

.chat-bubble-user .chat-msg-content {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble-bot .chat-msg-content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  color: var(--ink);
}

/* Message content elements */
.chat-msg-content h2,
.chat-msg-content h3,
.chat-msg-content h4 {
  margin: 0.8em 0 0.4em;
  line-height: 1.3;
}

.chat-msg-content h2 { font-size: 1.1rem; }
.chat-msg-content h3 { font-size: 1rem; }
.chat-msg-content h4 { font-size: 0.92rem; }

.chat-msg-content p {
  margin: 0 0 0.6em;
}

.chat-msg-content ul {
  margin: 0.4em 0 0.6em 1.2em;
  padding: 0;
}

.chat-msg-content li {
  margin-bottom: 0.25em;
}

.chat-msg-content blockquote {
  margin: 0.5em 0;
  padding: 0.5em 1em;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  font-style: italic;
}

.chat-msg-content code {
  background: rgba(0,0,0,0.06);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
}

.chat-msg-content hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1em 0;
}

.chat-msg-content strong {
  font-weight: 600;
}

/* User bubble: white text */
.chat-bubble-user .chat-msg-content strong,
.chat-bubble-user .chat-msg-content a {
  color: #fff;
}

/* Typing indicator */
.chat-typing {
  color: var(--ink-soft);
  font-style: italic;
}

.dot-anim {
  animation: dots 1.4s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: ''; opacity: 0; }
  40% { opacity: 0.3; }
  60% { opacity: 0.6; }
  80%, 100% { opacity: 1; }
}

/* Input area */
.chat-input-area {
  border-top: 1px solid var(--line);
  padding: 0.75rem 1.5rem;
  background: var(--surface);
}

.chat-status-bar {
  min-height: 0;
  margin-bottom: 0.25rem;
}

.chat-status-degraded {
  display: inline-block;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.chat-input {
  flex: 1;
  resize: none;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: var(--font);
  line-height: 1.5;
  max-height: 150px;
  overflow-y: auto;
  background: var(--bg);
  color: var(--ink);
}

.chat-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chat-input::placeholder {
  color: var(--ink-soft);
  opacity: 0.6;
}

.chat-form button {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 0;
}

.chat-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive: mobile */
@media (max-width: 768px) {
  .chat-layout {
    flex-direction: column;
  }

  .chat-sidebar {
    width: 100%;
    min-width: unset;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .chat-conv-list {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .chat-conv-item {
    min-width: 180px;
    flex-shrink: 0;
  }

  .chat-messages {
    padding: 1rem;
  }

  .chat-input-area {
    padding: 0.5rem 1rem;
  }
}
