/* ═══════════════════════════════════════════════════════════════════════════
   ASSIST-TAB.CSS — Rev Intel Assist Tab Styles
   Modern chatbot UI with tenant selector in header, proper scroll,
   and polished message layout.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tab Container — full height flex column ─────────────────────────────── */

.assist-tab {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  max-width: 900px;
  margin: 0 auto;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.assist-tab .assist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(180deg, rgba(20, 24, 44, 0.98) 0%, rgba(15, 18, 35, 0.95) 100%);
  border: 1px solid rgba(99, 102, 241, 0.1);
  border-radius: 12px;
  margin-bottom: 12px;
  flex-shrink: 0;
  gap: 12px;
}

.assist-tab .assist-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.assist-tab .assist-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.assist-tab .assist-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.assist-tab .assist-header-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.2;
}

.assist-tab .assist-header-title .assist-icon {
  display: none;
}

.assist-tab .assist-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.assist-tab .assist-header-context {
  font-size: 11px;
  color: rgba(148, 163, 184, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Tenant Selector (inline in header) ─────────────────────────────────── */

.assist-tab .assist-tenant-select-wrap {
  flex-shrink: 0;
}

.assist-tab .assist-tenant-select-wrap select {
  background: rgba(15, 18, 35, 0.8);
  border: 1px solid rgba(99, 102, 241, 0.15);
  color: var(--text, #e2e8f0);
  padding: 7px 28px 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236366f1'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  max-width: 260px;
  transition: border-color 0.2s;
}

.assist-tab .assist-tenant-select-wrap select:hover {
  border-color: rgba(99, 102, 241, 0.3);
}

.assist-tab .assist-tenant-select-wrap select:focus {
  border-color: var(--accent, #6366f1);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.assist-tab .assist-header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.assist-tab .assist-header-btn {
  background: transparent;
  border: none;
  color: rgba(148, 163, 184, 0.5);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
  padding: 0;
}

.assist-tab .assist-header-btn:hover {
  background: rgba(99, 102, 241, 0.1);
  color: #fff;
}

/* ── Message Area ────────────────────────────────────────────────────────── */

.assist-tab .assist-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.15) transparent;
}

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

.assist-tab .assist-messages::-webkit-scrollbar-track {
  background: transparent;
}

.assist-tab .assist-messages::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.15);
  border-radius: 3px;
}

.assist-tab .assist-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.3);
}

/* ── Welcome Card ────────────────────────────────────────────────────────── */

.assist-tab .assist-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 48px 24px;
  gap: 10px;
}

.assist-tab .assist-welcome-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 8px;
}

.assist-tab .assist-welcome h4 {
  font-size: 17px;
  font-weight: 600;
  color: #fff;
}

.assist-tab .assist-welcome p {
  font-size: 13px;
  color: rgba(148, 163, 184, 0.65);
  max-width: 420px;
  line-height: 1.6;
}

/* ── No Tenant Prompt (shown in message area when no tenant selected) ───── */

.assist-tab .assist-no-tenant {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 48px 24px;
  gap: 10px;
  color: rgba(148, 163, 184, 0.6);
}

.assist-tab .assist-no-tenant-icon {
  font-size: 32px;
  opacity: 0.5;
  margin-bottom: 4px;
}

.assist-tab .assist-no-tenant p {
  font-size: 13px;
  line-height: 1.5;
  max-width: 320px;
}

/* ── Message Bubbles with Avatars ─────────────────────────────────────────── */

.assist-tab .assist-msg {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  animation: assistFadeIn 0.3s ease;
}

.assist-tab .assist-msg.user {
  flex-direction: row-reverse;
}

.assist-tab .assist-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}

.assist-tab .assist-msg.ai .assist-msg-avatar {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
}

.assist-tab .assist-msg.user .assist-msg-avatar {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent2, #818cf8);
}

.assist-tab .assist-msg-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: 85%;
}

.assist-tab .assist-msg-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(148, 163, 184, 0.45);
  padding: 0 2px;
}

.assist-tab .assist-msg.user .assist-msg-label {
  text-align: right;
}

.assist-tab .assist-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.assist-tab .assist-msg.user .assist-bubble {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 4px rgba(99, 102, 241, 0.2);
}

.assist-tab .assist-msg.ai .assist-bubble {
  background: rgba(30, 33, 58, 0.5);
  border: 1px solid rgba(99, 102, 241, 0.08);
  border-bottom-left-radius: 4px;
  color: var(--text, #e2e8f0);
}

/* ── AI Message Content (markdown) ───────────────────────────────────────── */

.assist-tab .assist-bubble h2 {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin: 12px 0 6px;
}

.assist-tab .assist-bubble h2:first-child {
  margin-top: 0;
}

.assist-tab .assist-bubble h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent2, #818cf8);
  margin: 10px 0 4px;
}

.assist-tab .assist-bubble p {
  margin: 0 0 8px;
}

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

.assist-tab .assist-bubble strong {
  color: #fff;
  font-weight: 600;
}

.assist-tab .assist-bubble em {
  color: var(--accent2, #818cf8);
  font-style: italic;
}

.assist-tab .assist-bubble code {
  background: rgba(99, 102, 241, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'SF Mono', Consolas, monospace;
}

.assist-tab .assist-bubble ul,
.assist-tab .assist-bubble ol {
  padding-left: 18px;
  margin: 6px 0;
}

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

.assist-tab .assist-bubble li::marker {
  color: rgba(99, 102, 241, 0.5);
}

.assist-tab .assist-bubble blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid rgba(99, 102, 241, 0.3);
  background: rgba(99, 102, 241, 0.04);
  border-radius: 0 8px 8px 0;
  color: rgba(226, 232, 240, 0.85);
  font-size: 12.5px;
}

.assist-tab .assist-bubble hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin: 12px 0;
}

/* ── Tables in AI responses ──────────────────────────────────────────────── */

.assist-tab .assist-table-wrap {
  overflow-x: auto;
  margin: 10px 0;
  border-radius: 8px;
  border: 1px solid rgba(99, 102, 241, 0.08);
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.2) transparent;
}

.assist-tab .assist-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  white-space: nowrap;
}

.assist-tab .assist-table-wrap th {
  background: rgba(99, 102, 241, 0.06);
  padding: 7px 10px;
  text-align: left;
  font-size: 10px;
  color: var(--accent2, #818cf8);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
  border-bottom: 1px solid rgba(99, 102, 241, 0.12);
}

.assist-tab .assist-table-wrap td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.assist-tab .assist-table-wrap tr:hover td {
  background: rgba(99, 102, 241, 0.03);
}

/* ── Usage / Tools Badge ─────────────────────────────────────────────────── */

.assist-tab .assist-usage {
  font-size: 10px;
  color: rgba(148, 163, 184, 0.4);
  padding: 2px 2px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.assist-tab .assist-tools-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.1);
  font-size: 9px;
  color: var(--accent2, #818cf8);
  letter-spacing: 0.3px;
}

/* ── Error Message ───────────────────────────────────────────────────────── */

.assist-tab .assist-error {
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border-radius: 10px;
  font-size: 12.5px;
  margin: 4px 0;
  line-height: 1.5;
}

/* ── FAQ Chips ────────────────────────────────────────────────────────────── */

.assist-tab .assist-chips-area {
  flex-shrink: 0;
  padding: 10px 0;
  border-top: 1px solid rgba(99, 102, 241, 0.06);
}

.assist-tab .assist-chips-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(148, 163, 184, 0.45);
  margin-bottom: 8px;
  font-weight: 500;
}

.assist-tab .assist-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.assist-tab .assist-chip {
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid rgba(99, 102, 241, 0.12);
  background: rgba(99, 102, 241, 0.05);
  color: var(--accent2, #818cf8);
  transition: all 0.15s;
  white-space: nowrap;
}

.assist-tab .assist-chip:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: #fff;
  transform: translateY(-1px);
}

.assist-tab .assist-chip:active {
  transform: scale(0.96);
}

.assist-tab .assist-chip.more {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.06);
  color: rgba(148, 163, 184, 0.5);
}

.assist-tab .assist-chip.more:hover {
  color: var(--text, #e2e8f0);
  background: rgba(255, 255, 255, 0.06);
}

/* ── Input Area ──────────────────────────────────────────────────────────── */

.assist-tab .assist-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 0 4px;
  flex-shrink: 0;
  border-top: 1px solid rgba(99, 102, 241, 0.06);
  align-items: flex-end;
}

.assist-tab .assist-input {
  flex: 1;
  background: rgba(20, 25, 50, 0.6);
  border: 1px solid rgba(99, 102, 241, 0.12);
  color: var(--text, #e2e8f0);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  line-height: 1.45;
  max-height: 120px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.assist-tab .assist-input:focus {
  border-color: rgba(99, 102, 241, 0.35);
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

.assist-tab .assist-input::placeholder {
  color: rgba(148, 163, 184, 0.35);
}

.assist-tab .assist-input:disabled {
  opacity: 0.4;
}

.assist-tab .assist-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  padding: 0;
}

.assist-tab .assist-send:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.assist-tab .assist-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Loading Dots ────────────────────────────────────────────────────────── */

.assist-tab .assist-loading {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  animation: assistFadeIn 0.3s ease;
}

.assist-tab .assist-loading-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.assist-tab .assist-loading-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  background: rgba(30, 33, 58, 0.5);
  border: 1px solid rgba(99, 102, 241, 0.08);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.assist-tab .assist-loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.6);
  animation: assistDotPulse 1.4s ease-in-out infinite;
}

.assist-tab .assist-loading-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.assist-tab .assist-loading-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* ── Scroll Anchor ───────────────────────────────────────────────────────── */

.assist-scroll-anchor {
  height: 1px;
  flex-shrink: 0;
}

/* ── Animations ──────────────────────────────────────────────────────────── */

@keyframes assistDotPulse {
  0%, 80%, 100% { opacity: 0.4; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

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

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .assist-tab {
    height: calc(100vh - 100px);
  }

  .assist-tab .assist-header {
    flex-wrap: wrap;
  }

  .assist-tab .assist-tenant-select-wrap select {
    max-width: 180px;
  }

  .assist-tab .assist-msg-body {
    max-width: 90%;
  }
}
