/* ==============================================================================
   Serv Bot - AI FAQ & Diagnostics Chat UI CSS (v1.0.0)
   ============================================================================== */

/* Page layout */
.bot-page-container {
  max-width: 620px;
}

/* Badge dot */
.badge-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 4px;
}

.badge-status-dot.online {
  background-color: #3fb950;
  box-shadow: 0 0 8px #3fb950;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}

/* Chat Card Container */
.chat-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 14px;
  min-height: 560px;
  height: calc(100vh - 230px);
  max-height: 760px;
}

/* Messages feed */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 4px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(240, 246, 252, 0.15);
  border-radius: 4px;
}

/* Message bubbles */
.message-bubble {
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: fadeInBubble 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* User Bubble */
.user-message {
  align-self: flex-end;
  max-width: 85%;
}

.user-message .bubble-content {
  background: linear-gradient(135deg, rgba(31, 111, 235, 0.35) 0%, rgba(35, 134, 54, 0.3) 100%);
  border: 1px solid rgba(56, 139, 253, 0.4);
  color: #ffffff;
  padding: 11px 16px;
  border-radius: 16px 16px 4px 16px;
  font-size: 0.93rem;
  line-height: 1.45;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  word-break: break-word;
}

/* Bot Bubble */
.bot-message {
  align-self: flex-start;
  max-width: 95%;
}

.bot-message .bubble-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.bot-avatar {
  font-size: 1rem;
}

.sender-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.model-badge {
  font-size: 0.65rem;
  background: rgba(88, 166, 255, 0.15);
  border: 1px solid rgba(88, 166, 255, 0.3);
  color: #58a6ff;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.bot-message .bubble-content {
  background: rgba(18, 23, 31, 0.95);
  border: 1px solid rgba(240, 246, 252, 0.08);
  padding: 14px 16px;
  border-radius: 16px 16px 16px 4px;
  color: var(--text-primary);
  font-size: 0.92rem;
  line-height: 1.55;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
  word-break: break-word;
}

/* Markdown formatting inside Bot Content */
.bubble-content p {
  margin-bottom: 10px;
}

.bubble-content p:last-child {
  margin-bottom: 0;
}

.bubble-content strong {
  color: #ffffff;
  font-weight: 700;
}

.bubble-content code {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.84em;
  background: rgba(240, 246, 252, 0.1);
  color: #7ee787;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(240, 246, 252, 0.08);
}

.bubble-content pre {
  background: #090c10;
  border: 1px solid rgba(240, 246, 252, 0.12);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 10px 0;
  overflow-x: auto;
}

.bubble-content pre code {
  background: transparent;
  padding: 0;
  border: none;
  font-size: 0.82em;
}

.bubble-content ul, .bubble-content ol {
  padding-left: 20px;
  margin: 8px 0;
}

.bubble-content li {
  margin-bottom: 4px;
}

.bubble-content a {
  color: #58a6ff;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

.bubble-content a:hover {
  color: #79c0ff;
}

/* Quick Suggestion Chips */
.quick-chips-wrapper {
  margin: 6px 0 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-chips-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.quick-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-chip {
  background: rgba(22, 28, 38, 0.85);
  border: 1px solid rgba(240, 246, 252, 0.1);
  color: #c9d1d9;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-align: left;
}

.quick-chip:hover {
  background: rgba(31, 111, 235, 0.18);
  border-color: rgba(88, 166, 255, 0.4);
  color: #ffffff;
  transform: translateY(-1px);
}

.chip-emoji {
  font-size: 0.85rem;
}

/* ==============================================================================
   Stage 1: Scanning In-Flight Indicator
   ============================================================================== */
.diagnostic-scanning-box {
  background: rgba(13, 20, 32, 0.95);
  border: 1px dashed rgba(88, 166, 255, 0.5);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 6px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  animation: pulse-scanning 2s infinite ease-in-out;
}

@keyframes pulse-scanning {
  0%, 100% { border-color: rgba(88, 166, 255, 0.4); background: rgba(13, 20, 32, 0.95); }
  50% { border-color: rgba(63, 185, 80, 0.7); background: rgba(18, 28, 44, 0.95); }
}

.scanning-radar {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(88, 166, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.scanning-radar::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #58a6ff;
  box-shadow: 0 0 10px #58a6ff;
  animation: radar-ping 1.2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes radar-ping {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

.scanning-text-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scanning-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: #58a6ff;
}

.scanning-desc {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

/* ==============================================================================
   Stage 2: Compact Diagnostic Result Card
   ============================================================================== */
.bot-diagnostic-card {
  background: linear-gradient(135deg, rgba(16, 21, 30, 0.95) 0%, rgba(12, 16, 22, 0.98) 100%);
  border: 1px solid rgba(240, 246, 252, 0.12);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
}

.bot-diagnostic-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  bottom: 0;
}

.bot-diagnostic-card.status-success::before {
  background: #3fb950;
  box-shadow: 0 0 10px #3fb950;
}

.bot-diagnostic-card.status-warning::before {
  background: #d29922;
  box-shadow: 0 0 10px #d29922;
}

.bot-diagnostic-card.status-danger::before {
  background: #f85149;
  box-shadow: 0 0 10px #f85149;
}

.diag-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.diag-badge-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.diag-emoji {
  font-size: 1.3rem;
  line-height: 1;
}

.diag-title-box {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.diag-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
}

.diag-target-label {
  font-size: 0.78rem;
  font-family: 'JetBrains Mono', Consolas, monospace;
  color: var(--text-secondary);
}

/* Metric stats */
.diag-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.diag-stat-pill {
  background: rgba(24, 30, 42, 0.7);
  border: 1px solid rgba(240, 246, 252, 0.08);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.diag-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.diag-stat-val {
  font-size: 0.8rem;
  font-weight: 600;
  color: #e6edf3;
}

/* Anomalies Tags */
.diag-anomalies-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.diag-anomaly-chip {
  font-size: 0.74rem;
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: #ff7b72;
  padding: 3px 8px;
  border-radius: 4px;
}

/* CTA Link */
.btn-diag-report {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(31, 111, 235, 0.16);
  border: 1px solid rgba(56, 139, 253, 0.4);
  color: #58a6ff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.18s ease;
  margin-top: 2px;
}

.btn-diag-report:hover {
  background: rgba(31, 111, 235, 0.3);
  border-color: rgba(56, 139, 253, 0.6);
  color: #ffffff;
  transform: translateX(2px);
}

/* Sources Footer in Bot Message */
.sources-accordion {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(240, 246, 252, 0.08);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sources-label {
  font-weight: 600;
  margin-bottom: 4px;
}

.sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-tag {
  background: rgba(240, 246, 252, 0.06);
  border: 1px solid rgba(240, 246, 252, 0.1);
  color: var(--text-secondary);
  padding: 2px 7px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.73rem;
  transition: all 0.15s ease;
}

.source-tag:hover {
  background: rgba(88, 166, 255, 0.15);
  border-color: rgba(88, 166, 255, 0.3);
  color: #58a6ff;
}

/* ==============================================================================
   Rate Limit Countdown Banner
   ============================================================================== */
.rate-limit-banner {
  background: linear-gradient(135deg, rgba(210, 153, 34, 0.16) 0%, rgba(20, 16, 10, 0.95) 100%);
  border: 1px solid rgba(210, 153, 34, 0.4);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.rate-limit-banner.hidden {
  display: none;
}

.rate-limit-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rate-limit-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f0883e;
}

.rate-limit-sub {
  font-size: 0.78rem;
  color: #d29922;
}

.rate-limit-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(210, 153, 34, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.rate-limit-bar-fill {
  height: 100%;
  background: #f0883e;
  width: 100%;
  transition: width 1s linear;
}

/* ==============================================================================
   Chat Input Form
   ============================================================================== */
.chat-input-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid rgba(240, 246, 252, 0.08);
  padding-top: 12px;
}

.chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.chat-textarea {
  width: 100%;
  min-height: 44px;
  max-height: 130px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  padding: 10px 38px 10px 14px;
  resize: none;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.btn-clear-chat {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 0.95rem;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s ease, transform 0.15s ease;
  padding: 4px;
}

.btn-clear-chat:hover {
  opacity: 0.9;
  transform: scale(1.1);
}

.btn-chat-send {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-chat-send .send-icon {
  font-size: 1.05rem;
  transform: translateX(1px);
}

.btn-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0 4px;
}

@media (max-width: 480px) {
  .chat-card {
    height: calc(100vh - 190px);
    padding: 12px;
  }

  .diag-stats-grid {
    grid-template-columns: 1fr;
  }

  .chat-meta-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
}
