/* RishionBot v3 — Chat UI styles (scoped to .rb-* selectors only) */

/* ─── Chat Page Layout ────────────────────────────────────── */
.rb-chat-page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10px;
  min-height: 0;
}

.rb-chat-card {
  width: 100%;
  max-width: 720px;
  height: calc(100vh - var(--header-h, 70px) - 20px);
  height: calc(100dvh - var(--header-h, 70px) - 20px);
  display: flex;
  flex-direction: column;
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border, #e2e8f0);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  overflow: hidden;
}

/* ─── Chat Header Strip ───────────────────────────────────── */
.rb-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--c-border, #e2e8f0);
  background: linear-gradient(135deg, #091832 0%, #0f2847 100%);
  color: #fff;
  flex-shrink: 0;
}
.rb-chat-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.rb-chat-clear {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.rb-chat-clear:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* ─── Messages Area ───────────────────────────────────────── */
.rb-chat-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* ─── Message Row ─────────────────────────────────────────── */
.rb-msg {
  display: flex;
  flex-direction: column;
  animation: rb-fadeIn 0.3s ease;
  max-width: 80%;
}
.rb-msg--user {
  align-self: flex-end;
  align-items: flex-end;
}
.rb-msg--bot {
  align-self: flex-start;
  align-items: flex-start;
}

/* ─── Bubble ──────────────────────────────────────────────── */
.rb-bubble {
  padding: 10px 16px;
  font-size: 0.95rem;
  line-height: 1.6;
  word-break: break-word;
}
.rb-bubble--user {
  background: var(--c-primary, #2563eb);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}
.rb-bubble--bot {
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border, #e2e8f0);
  color: var(--c-text, #0f172a);
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* RTL bubble tail flip */
[dir="rtl"] .rb-bubble--user {
  border-radius: 18px 18px 18px 4px;
}
[dir="rtl"] .rb-bubble--bot {
  border-radius: 18px 18px 4px 18px;
}

/* ─── Bot Avatar Icon ─────────────────────────────────────── */
.rb-bot-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #091832, #1e3a5f);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  flex-shrink: 0;
}
.rb-bot-avatar svg {
  width: 14px;
  height: 14px;
  stroke: #fff;
  fill: none;
  stroke-width: 1.5;
}

/* ─── Timestamp ───────────────────────────────────────────── */
.rb-msg-time {
  font-size: 0.7rem;
  color: var(--c-text-muted, #64748b);
  margin-top: 3px;
  opacity: 0.7;
}

/* ─── Category Badge (inside bot bubble) ──────────────────── */
.rb-category-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-primary, #2563eb);
  background: rgba(37, 99, 235, 0.08);
  padding: 2px 8px;
  border-radius: 12px;
  margin-bottom: 6px;
}

/* ─── Weak Confidence Badge ───────────────────────────────── */
.rb-weak-badge {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 8px;
  font-size: 0.8rem;
  color: #92400e;
  line-height: 1.4;
}

/* ─── Answer Body ─────────────────────────────────────────── */
.rb-answer-body {
  line-height: 1.7;
}
.rb-answer-body a {
  color: var(--c-primary, #2563eb);
  text-decoration: underline;
}

/* ─── Quick-start Chips & Related Chips ───────────────────── */
.rb-chips,
.rb-related-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.rb-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 20px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--c-primary, #2563eb);
  border: 1px solid rgba(37, 99, 235, 0.15);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: start;
  line-height: 1.3;
}
.rb-chip:hover {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.3);
}
.rb-related-label {
  font-size: 0.75rem;
  color: var(--c-text-muted, #64748b);
  margin-top: 10px;
  margin-bottom: 2px;
}

/* ─── Inline Link (inside bot bubble) ─────────────────────── */
.rb-inline-link {
  color: var(--c-primary, #2563eb);
  text-decoration: underline;
  font-weight: 500;
}
.rb-inline-link:hover {
  text-decoration: none;
}

/* ─── Typing Indicator ────────────────────────────────────── */
.rb-typing-indicator {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 14px 20px;
}
.rb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-text-muted, #64748b);
  animation: rb-bounce 1.4s infinite ease-in-out both;
}
.rb-dot:nth-child(2) { animation-delay: 0.16s; }
.rb-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes rb-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ─── Input Bar ───────────────────────────────────────────── */
.rb-chat-input-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--c-border, #e2e8f0);
  background: var(--c-surface, #fff);
  flex-shrink: 0;
}
.rb-chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.rb-chat-input {
  flex: 1;
  border: 1px solid var(--c-border, #e2e8f0);
  border-radius: 20px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--c-bg, #efefef);
  color: var(--c-text, #0f172a);
  outline: none;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rb-chat-input:focus {
  border-color: var(--c-primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.rb-chat-input::placeholder {
  color: var(--c-text-muted, #64748b);
  opacity: 0.7;
}
/* RTL textarea — text & placeholder start from the right */
[dir="rtl"] .rb-chat-input,
.rb-chat-input[dir="rtl"] {
  text-align: right;
}
[dir="rtl"] .rb-chat-input::placeholder,
.rb-chat-input[dir="rtl"]::placeholder {
  text-align: right;
}
[dir="ltr"] .rb-chat-input,
.rb-chat-input[dir="ltr"] {
  text-align: left;
}

/* Desktop-only: taller, more comfortable input area */
@media (min-width: 601px) {
  .rb-chat-input {
    min-height: 54px;
    padding: 14px 20px;
    font-size: 1rem;
  }
  .rb-chat-send {
    width: 48px;
    height: 48px;
  }
  .rb-chat-send svg {
    width: 22px;
    height: 22px;
  }
  .rb-chat-input-bar {
    padding: 14px 20px;
  }
}

.rb-chat-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--c-primary, #2563eb);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.rb-chat-send:hover {
  background: var(--c-primary-hover, #1d4ed8);
}
.rb-chat-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.rb-chat-send svg {
  width: 20px;
  height: 20px;
}

/* ─── Animations ──────────────────────────────────────────── */
@keyframes rb-fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Responsive: Tablet ──────────────────────────────────── */
@media (max-width: 900px) {
  .rb-chat-page {
    padding: 6px;
  }
  .rb-chat-card {
    max-width: 100%;
    border-radius: 12px;
    height: calc(100vh - var(--header-h, 70px) - 12px);
    height: calc(100dvh - var(--header-h, 70px) - 12px);
  }
}

/* ─── Image Search Results ────────────────────────────────── */
.rb-msg--image-search {
  max-width: 95%;
}
.rb-photo-intro {
  margin-bottom: 10px;
  line-height: 1.6;
}
.rb-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 4px;
}
.rb-photo-card {
  display: block;
  border-radius: var(--radius-md, 0.5rem);
  border: 1px solid var(--c-border, #e2e8f0);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  background: var(--c-surface, #fff);
}
.rb-photo-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}
.rb-photo-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}
.rb-photo-info {
  padding: 6px 8px 8px;
}
.rb-photo-title {
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--c-text, #0f172a);
}
.rb-photo-meta {
  font-size: 0.72rem;
  color: var(--c-text-muted, #64748b);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rb-refinement-label {
  font-size: 0.75rem;
  color: var(--c-text-muted, #64748b);
  margin-top: 12px;
  margin-bottom: 4px;
}
.rb-refinement-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.rb-no-results {
  text-align: center;
  color: var(--c-text-muted, #64748b);
  padding: 12px 0;
  font-size: 0.9rem;
}

/* ─── Responsive: Mobile ──────────────────────────────────── */
@media (max-width: 600px) {
  .rb-chat-page {
    padding: 0;
  }
  .rb-chat-card {
    border-radius: 0;
    border-left: none;
    border-right: none;
    height: calc(100vh - var(--header-h, 70px));
    height: calc(100dvh - var(--header-h, 70px));
    box-shadow: none;
  }
  .rb-chat-messages {
    padding: 14px 12px;
  }
  .rb-chat-input-bar {
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .rb-msg {
    max-width: 88%;
  }
  .rb-bubble {
    font-size: 0.9rem;
  }
  .rb-chip {
    font-size: 0.8rem;
    padding: 6px 12px;
  }
  .rb-msg--image-search {
    max-width: 95%;
  }
  .rb-photo-grid {
    gap: 8px;
  }
  .rb-photo-info {
    padding: 4px 6px 6px;
  }
  .rb-photo-title {
    font-size: 0.78rem;
  }
  .rb-photo-meta {
    font-size: 0.68rem;
  }
}

/* ─── Follow-up Chips (below bot bubble, persistent) ──── */
.rb-followup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
