/* ── Variables ──────────────────────────────────────────── */
:root {
  --color-primary:      #2563EB;
  --color-primary-dark: #1D4ED8;
  --color-secondary:    #64748B;
  --color-accent:       #F59E0B;
  --color-accent-dark:  #D97706;
  --color-bg:           #F0F4FF;
  --color-surface:      #FFFFFF;
  --color-text:         #0F172A;
}

*, *::before, *::after { box-sizing: border-box; }
body { -webkit-font-smoothing: antialiased; }

/* ── Startup overlay ─────────────────────────────────────── */
#startup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #1E3A8A 0%, #1D4ED8 60%, #2563EB 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
#startup-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.startup-card {
  text-align: center;
  padding: 40px 48px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 24px;
  backdrop-filter: blur(12px);
  min-width: 300px;
}
.startup-logo {
  width: 64px; height: 64px;
  background: rgba(255,255,255,0.15);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.startup-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 6px;
}
.startup-status {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.75);
  margin: 0 0 20px;
  min-height: 1.25rem;
}
.startup-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 99px;
  overflow: hidden;
}
.startup-bar-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 99px;
  transition: width 0.4s ease;
}
.startup-attempt {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.45);
  margin: 10px 0 0;
  min-height: 1rem;
}

/* ── Header ─────────────────────────────────────────────── */
.header-glass {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(37, 99, 235, 0.07);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.logo-icon {
  background: linear-gradient(135deg, #1D4ED8 0%, #3B82F6 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.badge-pill {
  background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
}

/* ── Hero ───────────────────────────────────────────────── */
.hero-section {
  background: linear-gradient(140deg, #0C1F6B 0%, #1E3A8A 45%, #2563EB 100%);
  min-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 52px 24px 64px;
  position: relative;
  overflow: hidden;
  transition: min-height 0.45s cubic-bezier(.4,0,.2,1),
              padding    0.45s cubic-bezier(.4,0,.2,1);
}

.hero-section.hero-collapsed {
  min-height: 0;
  padding: 20px 24px 32px;
}

.hero-section.hero-collapsed .hero-title-block,
.hero-section.hero-collapsed .hero-idle-hint {
  display: none;
}

.hero-section.hero-collapsed .search-card {
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

/* Bounce arrow */
@keyframes bounceY {
  0%,100% { transform: translateY(0);   }
  50%      { transform: translateY(8px); }
}
.bounce { animation: bounceY 2s ease-in-out infinite; }

/* Animated blobs */
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.18;
  pointer-events: none;
  animation: blobFloat 9s ease-in-out infinite;
}
.blob-1 { width:420px; height:420px; background:#60A5FA; top:-120px; left:-80px;  animation-delay:0s; }
.blob-2 { width:320px; height:320px; background:#818CF8; top:-40px;  right:-70px; animation-delay:-3.5s; }
.blob-3 { width:260px; height:260px; background:#34D399; bottom:-60px; left:38%;  animation-delay:-6s; }

@keyframes blobFloat {
  0%,100% { transform: translateY(0)    scale(1);    }
  50%      { transform: translateY(-22px) scale(1.06); }
}

/* ── Search card ─────────────────────────────────────────── */
.search-card {
  background: rgba(255,255,255,0.98);
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow:
    0 32px 64px -12px rgba(0,0,0,0.4),
    0 0 0 1px rgba(255,255,255,0.08);
}

.search-input {
  border: 2px solid #E2E8F0;
  border-radius: 12px;
  background: #F8FAFC;
  color: #0F172A;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.search-input:focus {
  border-color: #2563EB;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
}
.search-input::placeholder { color: #94A3B8; }

.search-btn {
  background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 16px rgba(37,99,235,0.45);
  transition: transform 0.15s, box-shadow 0.15s;
}
.search-btn:hover {
  box-shadow: 0 6px 22px rgba(37,99,235,0.55);
  transform: translateY(-1px);
}
.search-btn:active { transform: translateY(0); }
.search-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ── Toggle ──────────────────────────────────────────────── */
.toggle-track {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: #CBD5E1;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.22s;
}
.toggle-track[aria-checked="true"] { background: #2563EB; }
.toggle-track:focus-visible { outline: 2px solid #2563EB; outline-offset: 2px; }

.toggle-knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.22);
  transition: transform 0.22s cubic-bezier(.34,1.56,.64,1);
}
.toggle-knob.on { transform: translateX(18px); }

/* ── Idle / empty state ──────────────────────────────────── */
.idle-icon {
  width: 72px; height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
  border: 1px solid #BFDBFE;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Loading ring ────────────────────────────────────────── */
.loading-ring { width: 44px; height: 44px; }
.ring-inner {
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 3px solid #DBEAFE;
  border-top-color: #2563EB;
  animation: spin 0.8s linear infinite;
}

/* ── Results badge ───────────────────────────────────────── */
.results-badge {
  background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
  color: #1E40AF;
  border: 1px solid #BFDBFE;
}

/* ── Result cards ────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity:0; transform:translateY(18px); }
  to   { opacity:1; transform:translateY(0);    }
}

.result-card {
  animation: fadeInUp 0.3s ease both;
  background: #fff;
  border-radius: 16px;
  border: 1px solid #E8EEFF;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
  box-shadow: 0 2px 8px rgba(37,99,235,0.06);
}
.result-card:hover {
  box-shadow: 0 10px 32px rgba(37,99,235,0.13);
  border-color: #C7D7FF;
  transform: translateY(-2px);
}

/* Left accent bar */
.result-accent {
  width: 4px;
  flex-shrink: 0;
  align-self: stretch;
}
.accent-high   { background: linear-gradient(to bottom, #059669, #34D399); }
.accent-medium { background: linear-gradient(to bottom, #D97706, #FBBF24); }
.accent-low    { background: linear-gradient(to bottom, #64748B, #94A3B8); }

/* Score badges */
.score-high   { background:#D1FAE5; color:#065F46; border:1px solid #A7F3D0; }
.score-medium { background:#FEF3C7; color:#92400E; border:1px solid #FDE68A; }
.score-low    { background:#F1F5F9; color:#475569; border:1px solid #E2E8F0; }

/* Query term highlight inside passage snippets */
.query-highlight {
  background: #FEF08A;
  color: #713F12;
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 600;
}

/* Passage snippets */
.passage-block {
  background: #F8FAFC;
  border: 1px solid #EEF2FF;
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color 0.15s, background 0.15s;
}
.passage-block:hover {
  border-color: #C7D7FF;
  background: #F5F8FF;
}

/* Open PDF button */
.open-pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #2563EB, #1D4ED8);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(37,99,235,0.32);
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
}
.open-pdf-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(37,99,235,0.45);
}
.open-pdf-btn:active { transform: translateY(0); }
.open-pdf-btn:focus-visible { outline: 2px solid #2563EB; outline-offset: 2px; }

/* Source link button — secondary style, sits beside Open PDF */
.source-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #F1F5F9;
  color: #475569;
  border: 1.5px solid #E2E8F0;
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}
.source-link-btn:hover {
  background: #E2E8F0;
  border-color: #CBD5E1;
  color: #1E293B;
  transform: translateY(-1px);
}
.source-link-btn:active  { transform: translateY(0); }
.source-link-btn:focus-visible { outline: 2px solid #64748B; outline-offset: 2px; }

/* ── PDF Modal ───────────────────────────────────────────── */
.modal-panel {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 48px 80px -12px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06);
}
.modal-header {
  border-bottom: 1px solid #F1F5F9;
}
.modal-close-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid #E2E8F0;
  background: #F8FAFC; color: #64748B; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.modal-close-btn:hover {
  background: #FEE2E2; color: #DC2626; border-color: #FECACA;
}
.modal-close-btn:focus-visible { outline: 2px solid #2563EB; outline-offset: 2px; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner { animation: spin 0.75s linear infinite; }

@keyframes dots {
  0%   { content: '.';  }
  33%  { content: '..'; }
  66%  { content: '...'; }
}
.loading-dots::after {
  content: '.';
  display: inline-block;
  animation: dots 1.2s steps(1,end) infinite;
}

@keyframes toastIn  {
  from { opacity:0; transform:translate(-50%,12px); }
  to   { opacity:1; transform:translate(-50%,0);    }
}
@keyframes toastOut {
  from { opacity:1; transform:translate(-50%,0);    }
  to   { opacity:0; transform:translate(-50%,12px); }
}
#toast { animation: toastIn 0.22s ease both; }
#toast.toast-exit { animation: toastOut 0.22s ease both; }

/* ── Legacy / ingest ─────────────────────────────────────── */
.status-pending    { color: #64748B; }
.status-processing { color: #2563EB; }
.status-done       { color: #059669; }
.status-error      { color: #DC2626; }

.drop-zone { outline: none; }
.drop-zone:hover, .drop-zone:focus-visible {
  border-color: #2563EB;
  background: #EFF6FF;
}
.drop-zone.drag-over {
  border-color: #2563EB;
  background: #DBEAFE;
  transform: scale(1.005);
}

.indexed-chip { transition: box-shadow 0.15s ease; }
.indexed-chip:hover { box-shadow: 0 1px 6px rgba(16,185,129,0.18); }

/* ── Metadata chips on cards ─────────────────────────────── */
.meta-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #3B82F6;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: 6px;
  padding: 2px 8px;
  white-space: nowrap;
  text-transform: capitalize;
}

/* ── Filters ─────────────────────────────────────────────── */
.filter-select {
  border: 1.5px solid #E2E8F0;
  border-radius: 10px;
  background: #F8FAFC;
  color: #0F172A;
  font-family: inherit;
  font-size: 0.8125rem;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.filter-select:focus {
  border-color: #2563EB;
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.filter-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Doc-type multi-select trigger */
.doc-type-trigger {
  border: 1.5px solid #E2E8F0;
  border-radius: 10px;
  background: #F8FAFC;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.doc-type-trigger:hover,
.doc-type-trigger:focus-visible {
  border-color: #2563EB;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.doc-type-trigger:focus-visible { outline: none; }

/* Checkbox row hover */
.doc-type-option { transition: background 0.1s; }

/* Date / number inputs inherit filter-select but don't need the custom chevron */
.filter-date-input,
input[type="number"].filter-select {
  background-image: none;
  padding-right: 10px;
}
.filter-date-input {
  color-scheme: light;
}
.filter-date-input::-webkit-calendar-picker-indicator {
  opacity: 0.4;
  cursor: pointer;
}
.filter-date-input::-webkit-calendar-picker-indicator:hover { opacity: 0.7; }

.filter-toggle-btn:focus-visible { outline: 2px solid #2563EB; outline-offset: 2px; border-radius: 4px; }
.filter-chevron-open { transform: rotate(180deg); }

/* Active filter indicator on toggle button */
#filter-toggle-btn.has-filters { color: #2563EB; }

/* open-dir-btn kept for backward compat */
.open-dir-btn { transition: background 0.15s, color 0.15s; }
.open-dir-btn:focus-visible { outline: 2px solid #2563EB; outline-offset: 2px; }
