/*==========================================================================
  ISETI AI Chat - Styles
  ==========================================================================*/

:root {
  --chat-bg: #f6f7fb;
  --bubble-user: #2563eb;
  --bubble-bot: #ffffff;
  --bubble-radius: 0.9rem;
  --iseti-dark: #0b1220;
  --iseti-primary: #2563eb;
  --iseti-success: #10b981;
  --iseti-gray-50: #f9fafb;
  --iseti-gray-100: #f3f4f6;
  --iseti-gray-200: #e5e7eb;
  --iseti-gray-800: #1f2937;
}

/* Page frame */
.chat-frame {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 160px);
  margin-top: 80px;
}

.chat-main {
  flex: 1 1 auto;
  background: var(--chat-bg);
}

/* Chat area */
.chat-container {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem 1rem 7.5rem;
}

.msg {
  display: flex;
  gap: 0.75rem;
  margin: 1rem 0;
}

.msg .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e9ecef;
  flex: 0 0 36px;
}

.msg.user .avatar {
  background: #e7f0ff;
}

.msg.bot .avatar {
  background: #eef7f1;
}

.msg .bubble {
  padding: 0.8rem 1rem;
  border-radius: var(--bubble-radius);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user .bubble {
  background: var(--bubble-user);
  color: #fff;
  border-top-right-radius: 0.35rem;
}

.msg.bot .bubble {
  background: var(--bubble-bot);
  color: #111;
  border-top-left-radius: 0.35rem;
}

.msg .meta {
  font-size: 0.8rem;
  opacity: 0.65;
  margin-top: 0.35rem;
}

.msg-actions {
  display: flex;
  gap: 0.5rem;
  opacity: 0.8;
}

.msg-actions .btn {
  --bs-btn-padding-y: 0.15rem;
  --bs-btn-padding-x: 0.45rem;
  --bs-btn-font-size: 0.8rem;
}

/* Composer */
.composer-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1020;
  background: linear-gradient(
    180deg,
    rgba(246, 247, 251, 0) 0%,
    rgba(246, 247, 251, 1) 24%
  );
  padding: 0.5rem 0;
}

.composer {
  max-width: 980px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 0.75rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.composer textarea {
  border: 0;
  resize: none;
  height: 44px;
  min-height: 44px;
  max-height: 140px;
  padding: 0.6rem 0.25rem 0.6rem 0;
}

.composer .controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.composer .controls .btn {
  border-radius: 0.55rem;
  padding: 0.45rem 0.8rem;
}

/* Thinking animation */
.thinking {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.thinking .dot {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: #6c757d;
  animation: blink 1.2s infinite ease-in-out;
}

.thinking .dot:nth-child(2) {
  animation-delay: 0.15s;
}

.thinking .dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.2;
  }
  40% {
    opacity: 1;
  }
}

/* Citations */
.citations .badge {
  margin-right: 0.35rem;
  margin-bottom: 0.35rem;
}

.badge-doc {
  background: #6c757d;
  padding: 0.35rem 0.65rem;
}

a.badge-doc:hover {
  background: #5a6268;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

a.badge-doc {
  cursor: pointer;
  transition: all 0.2s ease;
}

.badge-sql {
  background: var(--iseti-primary);
  padding: 0.35rem 0.65rem;
  color: white;
}

.badge-table {
  background: var(--iseti-success);
  padding: 0.35rem 0.65rem;
  color: white;
}

/* Grouped citations */
.grouped-citation {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.grouped-citation .badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  vertical-align: middle;
}

/* =================================================================
   ONBOARDING STYLES
   ================================================================= */

.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1055;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-out;
}

.onboarding-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.onboarding-overlay.hidden-hard {
  display: none !important;
}

.onboarding-card {
  position: relative;
  max-width: 600px;
  width: 100%;
  background: radial-gradient(
    120% 120% at 0% 0%,
    #ecf3ff 0%,
    #ffffff 40%,
    #f8fafc 100%
  );
  border-radius: 1.25rem;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.45);
  padding: 1.8rem 1.9rem 1.3rem;
  animation: ob-pop 0.24s ease-out;
  color: var(--iseti-dark);
}

@keyframes ob-pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.onboarding-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.onboarding-title-wrap {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.onboarding-icon {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #0d6efd10;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--iseti-primary);
  font-size: 1.2rem;
}

.onboarding-title-text {
  display: flex;
  flex-direction: column;
}

.onboarding-title {
  font-size: 1.15rem;
  font-weight: 600;
}

.onboarding-subtitle {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-top: 0.1rem;
}

.onboarding-badge {
  font-size: 0.78rem;
  padding: 0.14rem 0.55rem;
  border-radius: 999px;
  background: #e7f0ff;
  color: #0d6efd;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.onboarding-close {
  border: 0;
  background: transparent;
  font-size: 1.3rem;
  opacity: 0.6;
}

.onboarding-close:hover {
  opacity: 1;
}

.onboarding-step {
  display: none;
  margin-top: 1rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease-out, transform 0.18s ease-out;
}

.onboarding-step.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.onboarding-step h6 {
  font-size: 1.02rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.onboarding-step h6 .step-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #0d6efd;
  background: #e7f0ff;
  border-radius: 999px;
  padding: 0.08rem 0.55rem;
}

.onboarding-step p {
  font-size: 0.92rem;
  margin-bottom: 0.35rem;
}

.onboarding-highlight-example {
  border-left: 3px solid var(--iseti-primary);
  background: #f8fafc;
  border-radius: 0.85rem;
  padding: 0.7rem 0.85rem;
  margin-top: 0.3rem;
  font-size: 0.86rem;
}

.onboarding-highlight-example strong {
  color: var(--iseti-dark);
}

.onboarding-highlight-example code {
  display: block;
  font-size: 0.84rem;
  background: transparent;
  padding: 0;
  margin-bottom: 0.18rem;
  white-space: normal;
  word-break: break-word;
}

.onboarding-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.onboarding-chip {
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.onboarding-chip i {
  font-size: 0.95rem;
  opacity: 0.7;
}

.onboarding-chip:hover {
  background: #edf2ff;
  border-color: #4c6fff;
}

.onboarding-footer {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  padding-top: 0.55rem;
}

.onboarding-step-counter {
  font-size: 0.8rem;
  opacity: 0.75;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.onboarding-steps-indicator {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.onboarding-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #d0d7e2;
}

.onboarding-dot.active {
  background: #0d6efd;
  width: 14px;
  transition: all 0.15s ease-out;
}

.onboarding-footer-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.onboarding-skip {
  background: transparent;
  border: 0;
  font-size: 0.8rem;
  text-decoration: underline;
  opacity: 0.75;
}

.onboarding-skip:hover {
  opacity: 1;
}

.onboarding-help-btn {
  position: fixed;
  right: 1.2rem;
  bottom: 6.2rem;
  z-index: 1040;
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.28);
  font-size: 0.9rem;
}

.onboarding-help-btn i {
  font-size: 1.05rem;
}

/* Welcome Card Styles */
.welcome-card {
  max-width: 700px;
  margin: 2rem auto;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 20px;
  padding: 3rem 2.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.1);
}

.welcome-icon {
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
}

.welcome-icon i {
  font-size: 2rem;
  color: white;
}

.welcome-title {
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  color: var(--iseti-gray-800);
  margin-bottom: 0.5rem;
}

.welcome-subtitle {
  text-align: center;
  color: #64748b;
  font-size: 1rem;
  margin-bottom: 2rem;
}

.welcome-features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: white;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  transition: all 0.3s;
}

.feature-item:hover {
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.feature-item i {
  font-size: 1.5rem;
  color: #2563eb;
}

.feature-item span {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--iseti-gray-800);
}

.welcome-examples {
  background: #f1f5f9;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.examples-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--iseti-gray-800);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.examples-title i {
  color: #f59e0b;
}

.example-question {
  background: white;
  padding: 0.875rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  font-size: 0.9rem;
  color: #475569;
}

.example-question:last-child {
  margin-bottom: 0;
}

.example-question:hover {
  border-color: #2563eb;
  background: #eff6ff;
  transform: translateX(4px);
}

.welcome-tip {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-radius: 10px;
  border-left: 3px solid #2563eb;
}

.welcome-tip i {
  font-size: 1.2rem;
  color: #2563eb;
  flex-shrink: 0;
  margin-top: 2px;
}

.welcome-tip span {
  font-size: 0.875rem;
  color: #475569;
  line-height: 1.5;
}

/* Improved Composer Styles */
.composer-inner {
  padding: 1rem;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.chat-input {
  flex: 1;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.875rem 1rem;
  font-size: 0.95rem;
  resize: none;
  min-height: 50px;
  max-height: 150px;
  transition: all 0.2s;
  font-family: inherit;
}

.chat-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.send-button {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  border: none;
  border-radius: 12px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.send-button:active {
  transform: translateY(0);
}

.send-button i {
  font-size: 1.1rem;
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.5rem;
  border-top: 1px solid #e5e7eb;
}

.action-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.action-button:hover {
  background: #f1f5f9;
  color: #ef4444;
}

.action-button i {
  font-size: 1rem;
}

.char-counter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: #94a3b8;
}

.char-counter i {
  font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
  .chat-container {
    padding: 1rem 0.5rem 8rem;
  }

  .composer-wrap {
    padding: 0.5rem;
  }

  .onboarding-card {
    margin: 1rem;
    padding: 1.5rem;
  }

  .onboarding-help-btn {
    right: 1rem;
    bottom: 5.5rem;
  }

  .welcome-card {
    padding: 2rem 1.5rem;
    margin: 1rem;
  }

  .welcome-features {
    grid-template-columns: 1fr;
  }

  .welcome-title {
    font-size: 1.4rem;
  }

  .composer-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .char-counter {
    font-size: 0.7rem;
  }
}