/* =============================================
   CHATBOT  (.cb-*)
   ============================================= */

.cb-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  gap: 1rem;
}

/* ---------- Header ---------- */
.cb-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.cb-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
}

.cb-subtitle {
  font-size: 0.9rem;
  color: #64748b;
  margin: 4px 0 0;
}

.cb-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.cb-btn--outline {
  background: #fff;
  color: #64748b;
  border: 1.5px solid #e2e8f0;
}

.cb-btn--outline:hover {
  background: #fee2e2;
  color: #ef4444;
  border-color: #ef4444;
}

/* ---------- Chat Container ---------- */
.cb-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  min-height: 0;
}

/* ---------- Messages Area ---------- */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* Scrollbar */
.cb-messages::-webkit-scrollbar { width: 6px; }
.cb-messages::-webkit-scrollbar-track { background: transparent; }
.cb-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ---------- Empty State ---------- */
.cb-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 2rem;
}

.cb-empty-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #eff6ff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.cb-empty h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.5rem;
}

.cb-empty p {
  font-size: 0.9rem;
  color: #64748b;
  max-width: 420px;
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

/* ---------- Suggestions ---------- */
.cb-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  max-width: 600px;
}

.cb-suggestion {
  background: #f1f5f9;
  border: 1.5px solid #e2e8f0;
  border-radius: 20px;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  line-height: 1.4;
}

.cb-suggestion:hover {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
}

/* ---------- Message Bubble ---------- */
.cb-message {
  display: flex;
  gap: 0.75rem;
  max-width: 85%;
  animation: cbFadeIn 0.25s ease;
}

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

.cb-message--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.cb-message--assistant {
  align-self: flex-start;
}

.cb-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.cb-message--user .cb-avatar {
  background: #3b82f6;
  color: #fff;
}

.cb-message--assistant .cb-avatar {
  background: #f0fdf4;
  color: #16a34a;
  border: 1.5px solid #bbf7d0;
}

.cb-bubble {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cb-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  padding: 0 0.25rem;
}

.cb-message--user .cb-name {
  text-align: right;
}

.cb-text {
  padding: 0.85rem 1.1rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.cb-message--user .cb-text {
  background: #3b82f6;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.cb-message--assistant .cb-text {
  background: #f8fafc;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

/* ---------- Typing Indicator ---------- */
.cb-typing {
  color: #94a3b8;
  font-style: italic;
}

.cb-typing::after {
  content: '';
  animation: cbDots 1.2s steps(4, end) infinite;
}

@keyframes cbDots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* ---------- Sources ---------- */
.cb-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  padding: 0.6rem 0.25rem 0;
}

.cb-sources-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  margin-right: 0.25rem;
}

.cb-source-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  color: #1d4ed8;
  font-weight: 500;
}

.cb-source-score {
  background: #dbeafe;
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: #3b82f6;
}

/* ---------- Input Area ---------- */
.cb-input-area {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid #e2e8f0;
  background: #fafbfc;
}

.cb-input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s ease;
  line-height: 1.5;
  background: #fff;
}

.cb-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.cb-input:disabled {
  background: #f1f5f9;
  cursor: not-allowed;
}

.cb-send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: #3b82f6;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.cb-send:hover:not(:disabled) {
  background: #2563eb;
  transform: scale(1.05);
}

.cb-send:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

/* Spinner */
.cb-spin {
  animation: cbSpin 1s linear infinite;
}

@keyframes cbSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .cb-page {
    height: calc(100vh - 120px);
  }

  .cb-message {
    max-width: 95%;
  }

  .cb-suggestions {
    flex-direction: column;
    align-items: stretch;
  }

  .cb-suggestion {
    text-align: center;
  }

  .cb-header-row {
    flex-direction: column;
    align-items: stretch;
  }
}
