/* Ask page styles — Claude.ai-inspired two-state layout. */

/* ============================================
   FORM LAYOUT (full height flex column)
   ============================================ */

.ask-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ============================================
   WELCOME VIEW (centered greeting + cards)
   ============================================ */

.welcome-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 0;
}

.welcome-content {
  max-width: 680px;
  width: 100%;
  text-align: center;
}

.welcome-greeting {
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 600;
  color: var(--primary-800);
  margin: 0 0 8px;
  line-height: 1.25;
  letter-spacing: -0.3px;
}

.welcome-subtitle {
  font-size: 15px;
  color: var(--gray-500);
  margin: 0 0 36px;
  line-height: 1.5;
}

.welcome-scope {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: -24px;
  margin-bottom: 32px;
  letter-spacing: 0.01em;
}

.starter-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  text-align: left;
}

.starter-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: var(--bg-card);
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  color: var(--gray-700);
  text-align: left;
  transition: all 0.15s var(--ease-out);
}

.starter-card:hover {
  border-color: var(--primary-300);
  background: var(--primary-50);
  color: var(--primary-800);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

.starter-card:active {
  transform: scale(0.98);
}

.starter-card-text {
  flex: 1;
}

.starter-card-arrow {
  flex-shrink: 0;
  color: var(--gray-400);
  transition: color 0.15s var(--ease-out), transform 0.15s var(--ease-out);
}

.starter-card:hover .starter-card-arrow {
  color: var(--primary-500);
  transform: translateX(2px);
}

/* ============================================
   CONVERSATION VIEW (messages)
   ============================================ */

.conversation-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 32px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.no-js-message {
  border: 1px solid var(--border-subtle);
  background: var(--warning-50);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--gray-800);
}

/* ============================================
   MESSAGES (clean, minimal style)
   ============================================ */

.message {
  max-width: 860px;
  border-radius: 14px;
  overflow: hidden;
}

.message-assistant {
  background: transparent;
}

.message-user {
  margin-left: auto;
  background: var(--primary-50);
  border: 1px solid var(--primary-100);
  padding: 14px 18px;
  max-width: 75%;
}

.message-user .message-text {
  color: var(--primary-900);
}

.message-content {
  padding: 4px 0;
}

.message-text {
  line-height: 1.6;
  color: var(--gray-800);
  font-size: 15px;
}

/* Markdown content styles */
.message-text.markdown-content {
  white-space: normal;
}

.message-text:not(.markdown-content) {
  white-space: pre-wrap;
}

/* Paragraphs */
.message-text p {
  margin: 0 0 1em 0;
}

.message-text p:last-child {
  margin-bottom: 0;
}

/* Tables */
.message-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 13px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
}

.message-text thead {
  background: var(--gray-50);
}

.message-text th,
.message-text td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.message-text th {
  font-weight: 600;
  color: var(--gray-700);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.message-text tbody tr:last-child td {
  border-bottom: none;
}

.message-text tbody tr:hover {
  background: var(--gray-50);
}

/* Code blocks */
.message-text pre {
  background: var(--gray-900);
  color: var(--gray-100);
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1em 0;
  font-size: 13px;
  line-height: 1.5;
}

.message-text code {
  font-family: "JetBrains Mono", "SF Mono", Monaco, "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
}

.message-text :not(pre) > code {
  background: var(--gray-100);
  color: var(--gray-800);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Lists */
.message-text ul,
.message-text ol {
  margin: 1em 0;
  padding-left: 1.5em;
}

.message-text li {
  margin: 0.4em 0;
}

.message-text ul ul,
.message-text ol ol,
.message-text ul ol,
.message-text ol ul {
  margin: 0.4em 0;
}

/* Blockquotes */
.message-text blockquote {
  margin: 1em 0;
  padding: 12px 16px;
  border-left: 3px solid var(--primary-300);
  background: var(--gray-50);
  border-radius: 0 8px 8px 0;
  color: var(--gray-700);
}

.message-text blockquote p:last-child {
  margin-bottom: 0;
}

/* Headings in markdown content */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
  margin: 1.2em 0 0.6em 0;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1.3;
}

.message-text h1:first-child,
.message-text h2:first-child,
.message-text h3:first-child {
  margin-top: 0;
}

.message-text h1 { font-size: 1.4em; }
.message-text h2 { font-size: 1.25em; }
.message-text h3 { font-size: 1.1em; }
.message-text h4 { font-size: 1em; }

/* Horizontal rule */
.message-text hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 1.5em 0;
}

/* Strong and emphasis */
.message-text strong,
.message-text b {
  font-weight: 600;
}

.message-text em,
.message-text i {
  font-style: italic;
}

/* Strikethrough */
.message-text del,
.message-text s {
  text-decoration: line-through;
  color: var(--gray-500);
}

/* ============================================
   INLINE CITATION CHIPS
   ============================================ */

.cite-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--primary-50);
  border: 1px solid var(--primary-200);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  color: var(--primary-700);
  text-decoration: none;
  transition: all 0.15s var(--ease-out);
  cursor: pointer;
  vertical-align: middle;
  margin: 0 2px;
  white-space: nowrap;
}

.cite-chip:hover {
  background: var(--primary-100);
  border-color: var(--primary-300);
}

a.cite-chip-link {
  text-decoration: none;
}

a.cite-chip-link:hover {
  background: var(--primary-100);
  border-color: var(--primary-400);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cite-chip-icon {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

/* ============================================
   LOADING INDICATOR
   ============================================ */

.loading-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--gray-400);
  animation: il-pulse 1.2s infinite ease-in-out;
}

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

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

@keyframes il-pulse {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  50% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

/* Loading dots are essential status indicators — keep them animated under
   reduced-motion, but use a gentler opacity-only pulse (no movement). */
@media (prefers-reduced-motion: reduce) {
  .loading-dot {
    animation: il-pulse-gentle 1.6s infinite ease-in-out !important;
    animation-iteration-count: infinite !important;
  }
}

@keyframes il-pulse-gentle {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}

.loading-text {
  color: var(--gray-500);
  font-size: 14px;
  font-weight: 500;
}

/* ============================================
   RECOVERY PANEL
   ============================================ */

.answer-recovery {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.answer-recovery-text {
  font-size: 13px;
  line-height: 1.4;
  color: var(--gray-800);
}

.answer-recovery-btn {
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid var(--primary-600);
  background: var(--primary-600);
  color: var(--text-inverse);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s var(--ease-out);
}

.answer-recovery-btn:hover {
  background: var(--primary-700);
  border-color: var(--primary-700);
}

.answer-recovery-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.answer-recovery.answer-recovery-error {
  background: var(--error-50);
  border-color: var(--error-100);
}

.answer-recovery.answer-recovery-error .answer-recovery-text {
  color: var(--error-700);
}

.answer-recovery.answer-recovery-warning {
  background: var(--warning-50);
  border-color: var(--warning-100);
}

.answer-recovery.answer-recovery-warning .answer-recovery-text {
  color: var(--warning-700);
}

.answer-recovery.answer-recovery-info {
  background: var(--primary-50);
  border-color: var(--primary-100);
}

.answer-recovery.answer-recovery-info .answer-recovery-text {
  color: var(--primary-700);
}

/* ============================================
   SOURCES PANEL
   ============================================ */

.sources-panel {
  margin-top: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.sources-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--gray-50);
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  color: var(--gray-800);
  font: inherit;
  text-align: left;
  transition: background 0.15s var(--ease-out);
}

.sources-header:hover {
  background: var(--gray-100);
}

.sources-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}

.sources-count {
  background: var(--primary-100);
  color: var(--primary-700);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.sources-toggle {
  color: var(--gray-500);
  transition: transform 0.2s var(--ease-out);
}

.sources-list {
  padding: 12px;
}

.sources-panel.collapsed .sources-toggle {
  transform: rotate(-90deg);
}

.sources-panel.collapsed .sources-list {
  display: none;
}

.source-item {
  padding: 16px 18px;
  border-radius: 10px;
  margin-bottom: 10px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  transition: all 0.2s var(--ease-out);
}

.source-item:last-child {
  margin-bottom: 0;
}

.source-item:hover {
  border-color: var(--primary-300);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.source-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.source-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-800);
  margin-bottom: 3px;
}

.source-item-section {
  color: var(--gray-600);
  font-size: 13px;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  cursor: help;
}

.source-badge-active {
  background: var(--success-100);
  color: var(--success-700);
}

.source-badge-repealed {
  background: var(--error-100);
  color: var(--error-700);
}

.source-badge-pending {
  background: var(--warning-100);
  color: var(--warning-700);
}

.source-badge-partial {
  background: var(--primary-100);
  color: var(--primary-700);
}

.source-badge-amended {
  background: var(--warning-100);
  color: var(--warning-700);
}

.source-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.source-quote {
  font-family: var(--font-legal);
  font-size: 14px;
  line-height: 1.7;
  color: var(--gray-600);
  padding: 14px 18px;
  background: var(--bg-card);
  border-left: 3px solid var(--primary-300);
  border-radius: 0 8px 8px 0;
  margin-bottom: 14px;
  font-style: italic;
  white-space: normal;
}

.source-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.source-link {
  font-size: 12px;
  color: var(--primary-600);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: 6px;
  transition: all 0.15s var(--ease-out);
}

.source-link:hover {
  background: var(--primary-50);
}

.source-link.source-link-disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.source-relevance {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--gray-500);
  cursor: help;
}

.relevance-label {
  font-weight: 500;
  color: var(--gray-600);
}

.relevance-percent {
  min-width: 28px;
  text-align: right;
}

.relevance-bar {
  width: 60px;
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  overflow: hidden;
}

.relevance-fill {
  width: 0%;
  height: 100%;
  background: var(--primary-500);
  border-radius: 2px;
  transition: width 0.3s var(--ease-out);
}

.relevance-fill.relevance-fill-0 { width: 0%; }
.relevance-fill.relevance-fill-5 { width: 5%; }
.relevance-fill.relevance-fill-10 { width: 10%; }
.relevance-fill.relevance-fill-15 { width: 15%; }
.relevance-fill.relevance-fill-20 { width: 20%; }
.relevance-fill.relevance-fill-25 { width: 25%; }
.relevance-fill.relevance-fill-30 { width: 30%; }
.relevance-fill.relevance-fill-35 { width: 35%; }
.relevance-fill.relevance-fill-40 { width: 40%; }
.relevance-fill.relevance-fill-45 { width: 45%; }
.relevance-fill.relevance-fill-50 { width: 50%; }
.relevance-fill.relevance-fill-55 { width: 55%; }
.relevance-fill.relevance-fill-60 { width: 60%; }
.relevance-fill.relevance-fill-65 { width: 65%; }
.relevance-fill.relevance-fill-70 { width: 70%; }
.relevance-fill.relevance-fill-75 { width: 75%; }
.relevance-fill.relevance-fill-80 { width: 80%; }
.relevance-fill.relevance-fill-85 { width: 85%; }
.relevance-fill.relevance-fill-90 { width: 90%; }
.relevance-fill.relevance-fill-95 { width: 95%; }
.relevance-fill.relevance-fill-100 { width: 100%; }

/* ============================================
   INPUT AREA
   ============================================ */

.input-area {
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  padding: 16px 24px 20px;
}

/* In welcome state: no border-top, visually part of the centered layout */
.ask-form:not(.has-conversation) .input-area {
  border-top: none;
  padding-top: 24px;
}

.input-container {
  max-width: 680px;
  margin: 0 auto;
}

/* In conversation state: wider container to match chat width */
.ask-form.has-conversation .input-container {
  max-width: 860px;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.input-box {
  flex: 1;
  border: 1px solid var(--gray-300);
  background: var(--bg-card);
  border-radius: 16px;
  padding: 12px 16px;
  transition: border-color 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out);
}

.input-box:focus-within {
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.input-field {
  width: 100%;
  border: 0;
  background: transparent;
  resize: none;
  outline: none;
  overflow-y: hidden;
  font-size: 15px;
  line-height: 1.45;
  color: var(--gray-900);
  max-height: 200px;
}

.input-field.input-field-scroll {
  overflow-y: auto;
}

.query-limit-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 6px;
}

.query-limit-message {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--error-700);
}

.query-limit-message-warning {
  color: var(--warning-700);
}

.query-limit-message-error {
  color: var(--error-700);
}

.query-limit-counter {
  margin-left: auto;
  font-size: 12px;
  color: var(--gray-500);
  white-space: nowrap;
}

.query-limit-counter-warning {
  color: var(--warning-700);
}

.query-limit-counter-error {
  color: var(--error-700);
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-send,
.btn-stop {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--gray-800);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease-out);
  font-size: 14px;
}

.btn-send {
  background: var(--primary-600);
  border-color: var(--primary-600);
  color: #fff;
}

.btn-send:hover {
  background: var(--primary-700);
  border-color: var(--primary-700);
}

.btn-stop:hover {
  background: var(--gray-100);
}

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

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 720px) {
  .starter-cards {
    grid-template-columns: 1fr;
  }

  .welcome-greeting {
    font-size: 26px;
  }

  .chat-content {
    padding: 24px 16px 16px;
  }

  .input-area {
    padding: 12px 16px 16px;
  }
}
