/* ============================================================
   SNEH AI — CHAT UI (NO TABLE STYLES)
   All table rules moved to css/table.css
   ============================================================ */

/* ──────────────────────────────────────────────────────────────
   1.  PANEL & BASE CONTAINER
   ────────────────────────────────────────────────────────────── */
.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ──────────────────────────────────────────────────────────────
   2.  MESSAGES – USER & ASSISTANT
   ────────────────────────────────────────────────────────────── */
.message {
  width: 100%;
  display: flex;
  gap: 0;
  max-width: 100%;
}

.message-avatar {
  display: none;
}

.message-content {
  flex: 1;
}

/* ── User message ── */
.message-user .message-content {
  max-width: 95%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-left: auto;
}

.message-user .message-bubble {
  background: var(--ms1-bg);
  color: var(--txt1);
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-2xl);
  border-bottom-right-radius: var(--radius-sm);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-weight: 500;
  user-select: text;
  -webkit-user-select: text;
}

/* ── Assistant message ── */
.message-assistant .message-content {
  max-width: 100%;
  width: 100%;
}

.message-assistant .message-bubble {
  background: transparent !important;
  color: var(--text-primary);
  padding: 0.25rem 0 0.25rem 0;
  border: none;
  border-radius: 0;
  font-size: 1.0625rem;
  line-height: 1.65;
  font-weight: 500;
  max-width: 100%;
  user-select: text;
  -webkit-user-select: text;
}

/* ── Shared bubble typography (strong, em) ── */
.message-bubble strong {
  font-weight: 700;
  color: var(--highlight);
}

.message-bubble em {
  color: var(--text-secondary);
  font-style: italic;
}

/* ──────────────────────────────────────────────────────────────
   3.  MESSAGE ACTIONS
   ────────────────────────────────────────────────────────────── */
.message-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  opacity: 1;
  transition: var(--transition);
}

.action-btn svg {
  width: 16px;
  height: 16px;
}

.action-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.895rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.action-btn:hover,
.action-btn:focus {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
}

.action-btn.active-feedback {
  color: var(--card-bg);
}
.action-btn.active-feedback i {
  color: var(--card-bg);
}

.action-btn.active-feedback i,
.action-btn.active-feedback svg {
  stroke: var(--highlight);
  fill: var(--highlight);
  filter: drop-shadow(0 0 0px var(--card-bg));
}

/* ── User message action buttons override ── */
.message-user .action-btn {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
}

.message-user .action-btn:hover,
.message-user .action-btn:focus {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

/* ──────────────────────────────────────────────────────────────
   4.  THINKING / SHIMMER / THOUGHT TIME
   ────────────────────────────────────────────────────────────── */
.thinking {
  display: inline-block;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  /* no gradient, no clip, no animation */
}

.thinking-dots {
  display: flex;
  gap: 4px;
}

.thinking-dot {
  width: 6px;
  height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: thinking-wave 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 thinking-wave {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.shimmer-bubble {
  background: linear-gradient(90deg, transparent 0%, rgba(94, 159, 255, 0.15) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius-md);
}

.thought-time {
  font-size: 0.9rem;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  padding: 0 4px;
}

/* ──────────────────────────────────────────────────────────────
   5.  ASSISTANT MESSAGE – RICH TEXT FORMATTING
   (headings, paragraphs, lists, blockquotes, code, pre)
   ────────────────────────────────────────────────────────────── */
.ai-message,
.message-assistant .message-bubble {
  font-size: 1.09rem;
  line-height: 1.49;
  color: var(--text-primary);
}

/* ── Headings ── */
.message-assistant .message-bubble h1,
.message-assistant .message-bubble h2,
.message-assistant .message-bubble h3,
.message-assistant .message-bubble h4,
.message-assistant .message-bubble h5,
.message-assistant .message-bubble h6 {
  color: var(--text-primary);
  margin: 1.5rem 0 0.75rem;
  line-height: 1.3;
  font-weight: 750;
}

.message-assistant .message-bubble h1 {
  font-size: 2.5rem;
  color: var(--highlight);
}
.message-assistant .message-bubble h2 {
  font-size: 2.3rem;
  border-bottom: 1px solid var(--input-border-color);
  padding-bottom: 0.33rem;
}
.message-assistant .message-bubble h3 { font-size: 1.50rem; }
.message-assistant .message-bubble h4 { font-size: 1.1rem; font-weight: 600; }
.message-assistant .message-bubble h5 { font-size: 1.05rem; font-weight: 600; }
.message-assistant .message-bubble h6 { font-size: 1rem; font-weight: 600; }

/* ── Paragraphs ── */
.message-assistant .message-bubble p {
  margin: 0.75rem 0;
}

/* ── Lists ── */
.message-assistant .message-bubble ul,
.message-assistant .message-bubble ol {
  padding-left: 1.5rem;
  margin: 0.75rem 0;
}

.message-assistant .message-bubble li {
  margin: 0.4rem 0;
  line-height: 1.6;
}

/* ── Blockquotes ── */
.message-assistant .message-bubble blockquote {
  border-left: 4px solid var(--highlight);
  padding-left: 1rem;
  margin: 1.25rem 0;
  color: var(--text-secondary);
  font-style: italic;
  background: rgba(0, 0, 0, 0.02);
  padding: 10px 15px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ── Code & Pre (scrollbar hidden for <pre> only) ── */
.message-assistant .message-bubble pre {
  background: var(--ms1-bg);
  border-radius: 18px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.message-assistant .message-bubble pre::-webkit-scrollbar {
  display: none;
}

.message-assistant .message-bubble code {
  background: rgba(0,0,0,0.1);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
}

.message-assistant .message-bubble pre code {
  background: transparent;
  padding: 0;
  font-size: 0.9rem;
}

/* ──────────────────────────────────────────────────────────────
   6.  WELCOME SCREEN
   ────────────────────────────────────────────────────────────── */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 2rem 1rem;
  text-align: center;
  
  animation: fadeInWelcome 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInWelcome {
  0% { opacity: 0; transform: scale(0.98); }
  100% { opacity: 1; transform: scale(1); }
}

.welcome-screen h1 {
  font-size: 2.4rem;
  font-weight: 730;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.1;
  opacity: 0;
  transform: translateY(10px);
  animation: fadeSlideGlow 0.9s ease-out forwards;
}

@keyframes fadeSlideGlow {
  0% {
    opacity: 0;
    transform: translateY(10px);
    text-shadow: 0 0 0px rgba(255,255,255,0);
  }
  60% {
    opacity: 1;
    transform: translateY(0);
    text-shadow: 0 0 6px rgba(255,255,255,0.15);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    text-shadow: 0 0 0px rgba(255,255,255,0);
  }
}

.welcome-screen p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 420px;
  margin: 0 auto 2.5rem;
  animation: fadeSlideGlow 0.4s ease-out forwards;
}

/* ──────────────────────────────────────────────────────────────
   7.  PROMPT GRID & CARDS
   ────────────────────────────────────────────────────────────── */
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 820px;
}

.prompt-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 1.05rem;
  color: var(--text-primary);
  line-height: 1.4;
}

.prompt-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--highlight);
}

.prompt-card i {
  font-size: 1.4rem;
  color: var(--highlight);
  flex-shrink: 0;
}

[data-theme="dark"] .prompt-card {
  background: #1e1e1e;
  border-color: #333;
}

/* ──────────────────────────────────────────────────────────────
   8.  FOLLOW-UP PILLS & SKELETON LOADERS
   ────────────────────────────────────────────────────────────── */
.follow-up-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 8px;
  width: 100%;
}

.follow-up-pill {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  text-align: left;
  line-height: 1.3;
}

.follow-up-pill:hover {
  background: var(--bg-primary);
  border-color: var(--highlight);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: var(--highlight);
}

[data-theme="dark"] .follow-up-pill {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .follow-up-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--highlight);
}

.follow-up-skeleton {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 8px;
}

.skeleton-pill {
  height: 34px;
  width: 180px;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--input-bg1) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
}

[data-theme="dark"] .skeleton-pill {
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
  background-size: 200% 100%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ──────────────────────────────────────────────────────────────
   9.  SCROLLBAR HIDING (shared utilities)
   ────────────────────────────────────────────────────────────── */
.chat-container {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chat-container::-webkit-scrollbar {
  display: none;
}

/* (Pre scrollbar hiding is already included inside the pre rule above) */

/* ──────────────────────────────────────────────────────────────
   10. CHAT CONTAINER – DYNAMIC PADDING & FADE MASK
   ────────────────────────────────────────────────────────────── */
.chat-container {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: var(--message-gap);
  -webkit-overflow-scrolling: touch;

  /* ── Dynamic bottom offset (set by JS) ── */
  --sneh-input-offset: var(--input-height, 120px);

  /* ── Fade control parameters ── */
  --sneh-header-height: var(--header-height, 80px);
  --sneh-top-fade-depth: 100px;
  --sneh-bottom-fade-depth: 135px;

  --sneh-top-opacity-0: 0.05;
  --sneh-top-opacity-1: 0.20;
  --sneh-top-opacity-2: 0.35;
  --sneh-top-opacity-3: 0.55;

  /* ── Adjusted to allow a smooth fade transition at the absolute edge ── */
  --sneh-bottom-opacity-3: 0.30;
  --sneh-bottom-opacity-2: 0.17;
  --sneh-bottom-opacity-1: 0.08;
  --sneh-bottom-opacity-0: 0.03;

  --sneh-opacity-solid: 1.00;

  /* ── Padding (uses dynamic variable) ── */
  padding: var(--sneh-header-height) 1rem var(--sneh-input-offset);

  will-change: scroll-position;

  /* ── Fade mask ── */
  mask-image: linear-gradient(
    to bottom,
    rgba(0, 0, 0, var(--sneh-top-opacity-0)) 0px,
    rgba(0, 0, 0, var(--sneh-top-opacity-1)) calc(var(--sneh-top-fade-depth) * 0.25),
    rgba(0, 0, 0, var(--sneh-top-opacity-2)) calc(var(--sneh-top-fade-depth) * 0.50),
    rgba(0, 0, 0, var(--sneh-top-opacity-3)) calc(var(--sneh-top-fade-depth) * 0.75),
    rgba(0, 0, 0, var(--sneh-opacity-solid)) var(--sneh-top-fade-depth),
    rgba(0, 0, 0, var(--sneh-opacity-solid)) calc(100% - var(--sneh-bottom-fade-depth)),
    rgba(0, 0, 0, var(--sneh-bottom-opacity-3)) calc(100% - (var(--sneh-bottom-fade-depth) * 0.75)),
    rgba(0, 0, 0, var(--sneh-bottom-opacity-2)) calc(100% - (var(--sneh-bottom-fade-depth) * 0.50)),
    rgba(0, 0, 0, var(--sneh-bottom-opacity-1)) calc(100% - (var(--sneh-bottom-fade-depth) * 0.25)),
    rgba(0, 0, 0, var(--sneh-bottom-opacity-0)) 100%
  );

  -webkit-mask-image: linear-gradient(
    to bottom,
    rgba(0, 0, 0, var(--sneh-top-opacity-0)) 0px,
    rgba(0, 0, 0, var(--sneh-top-opacity-1)) calc(var(--sneh-top-fade-depth) * 0.25),
    rgba(0, 0, 0, var(--sneh-top-opacity-2)) calc(var(--sneh-top-fade-depth) * 0.50),
    rgba(0, 0, 0, var(--sneh-top-opacity-3)) calc(var(--sneh-top-fade-depth) * 0.75),
    rgba(0, 0, 0, var(--sneh-opacity-solid)) var(--sneh-top-fade-depth),
    rgba(0, 0, 0, var(--sneh-opacity-solid)) calc(100% - var(--sneh-bottom-fade-depth)),
    rgba(0, 0, 0, var(--sneh-bottom-opacity-3)) calc(100% - (var(--sneh-bottom-fade-depth) * 0.75)),
    rgba(0, 0, 0, var(--sneh-bottom-opacity-2)) calc(100% - (var(--sneh-bottom-fade-depth) * 0.50)),
    rgba(0, 0, 0, var(--sneh-bottom-opacity-1)) calc(100% - (var(--sneh-bottom-fade-depth) * 0.25)),
    rgba(0, 0, 0, var(--sneh-bottom-opacity-0)) 100%
  );

  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-size: 100% 100%;
  -webkit-mask-size: 100% 100%;
}

/* ── Mobile override: keep gap but let padding be dynamic ── */
@media (max-width: 480px) {
  .chat-container {
    gap: 1.5rem;
  }
}

/* ──────────────────────────────────────────────────────────────
   11. MISCELLANEOUS (send button state)
   ────────────────────────────────────────────────────────────── */
.send-button.text-empty:not(:disabled) {
  opacity: 0.35;
}