/* ── CuraLex Search & Chat ─────────────────────────────── */

.search-hero {
  background: var(--bg-primary);
  padding: 40px 0 24px;
}
.search-hero .container { max-width: 800px; margin: 0 auto; padding: 0 48px; }
.search-hero h1 {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: .25rem;
}
.search-hero p {
  color: var(--text-secondary);
  font-size: 14.5px;
}

.dev-banner {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin-top: .75rem;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.dev-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
  font-family: var(--font-body);
}
.dev-text strong {
  display: block;
  margin-bottom: 2px;
  font-weight: 650;
  color: var(--text-primary);
}

/* ── Mode tabs ────────────────────────────────────────── */
.mode-tabs {
  display: flex;
  gap: 0;
  margin: 32px auto 0;
  max-width: 800px;
  padding: 0 48px;
}
.mode-tab {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s, color .2s;
  font-family: var(--font-body);
  margin-right: -1px;
}
.mode-tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border);
  position: relative;
  z-index: 1;
}
.mode-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0; right: 0;
  height: 1px;
  background: var(--bg-primary);
}

/* ── Search panel ─────────────────────────────────────── */
.search-panel {
  max-width: 800px;
  margin: 0 auto;
  padding: 28px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
}
.search-form {
  display: flex;
  gap: .5rem;
}
.search-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.search-input:focus {
  background: var(--bg-primary);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(12,155,131,0.12);
}
.search-input::placeholder { color: var(--text-muted); }

.search-filters {
  display: flex;
  gap: .75rem;
  margin-top: .75rem;
  align-items: center;
}
.search-filters select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text-secondary);
  background: var(--bg-secondary);
  outline: none;
  transition: border-color .2s;
}
.search-filters select:focus { border-color: var(--accent); }
.search-filters label {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
}

.btn-search {
  padding: 10px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s, transform .2s, box-shadow .2s;
  font-family: var(--font-body);
}
.btn-search:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(12,155,131,0.2);
}
.btn-search:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Results ──────────────────────────────────────────── */
.results-area {
  max-width: 800px;
  margin: 24px auto;
  padding: 0 48px;
}
.results-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-family: var(--font-body);
}

.search-hit {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 12px;
  background: var(--bg-primary);
  transition: border-color .2s, box-shadow .2s;
}
.search-hit:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}
.hit-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: .35rem;
}
.hit-bill {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}
.hit-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.hit-title {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: .3rem;
  line-height: 1.5;
}
.hit-snippet {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  border-left: 2px solid var(--border);
  padding-left: .75rem;
  margin-top: .5rem;
}
.hit-tags { display: flex; gap: 6px; margin-top: .5rem; flex-wrap: wrap; }
.hit-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 500;
}
.hit-tag.funding { background: var(--accent-subtle); color: var(--accent); }
.hit-link {
  font-size: 12px;
  margin-top: .5rem;
  display: inline-block;
  color: var(--accent);
}
.hit-link:hover { color: var(--accent-hover); }

/* ── Suggestions ──────────────────────────────────────── */
.suggestions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 1rem; }
.suggestion {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .2s;
  background: var(--bg-primary);
  font-family: var(--font-body);
}
.suggestion:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

/* ── Chat panel ───────────────────────────────────────── */
.chat-panel {
  max-width: 800px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  height: 560px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}

/* Welcome state */
.chat-welcome {
  text-align: center;
  padding: 56px 16px 16px;
  color: var(--text-muted);
}
.chat-welcome-icon {
  font-size: 2rem;
  margin-bottom: .5rem;
  opacity: .3;
}
.chat-welcome h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: .35rem;
}
.chat-welcome p {
  font-size: 14px;
  max-width: 420px;
  margin: 0 auto .75rem;
  line-height: 1.6;
  color: var(--text-secondary);
}
.chat-welcome .suggestions { justify-content: center; }

/* Messages */
.msg {
  margin-bottom: 16px;
  max-width: 88%;
}
.msg-user {
  margin-left: auto;
  text-align: right;
}
.msg-assistant {
  margin-right: auto;
}
.msg-label {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.msg-text {
  display: inline-block;
  text-align: left;
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}
.msg-user .msg-text {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 2px;
}
.msg-assistant .msg-text {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
}
.msg-error .msg-text {
  background: var(--status-vetoed-bg);
  border-color: #fecaca;
  color: var(--status-vetoed-text);
}

.msg-assistant .msg-text h1,
.msg-assistant .msg-text h2,
.msg-assistant .msg-text h3,
.msg-assistant .msg-text h4 {
  margin: .6rem 0 .3rem;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}
.msg-assistant .msg-text h2 { font-size: 15.5px; }
.msg-assistant .msg-text h3 { font-size: 14.5px; }
.msg-assistant .msg-text p {
  margin: .35rem 0;
  line-height: 1.6;
}
.msg-assistant .msg-text ul,
.msg-assistant .msg-text ol {
  margin: .35rem 0;
  padding-left: 1.3rem;
}
.msg-assistant .msg-text li {
  margin: .2rem 0;
  line-height: 1.6;
}
.msg-assistant .msg-text strong {
  font-weight: 650;
  color: var(--text-primary);
}
.msg-assistant .msg-text code {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding: .1rem .35rem;
  border-radius: 4px;
  font-size: 12.5px;
}
.msg-assistant .msg-text table {
  width: 100%;
  border-collapse: collapse;
  margin: .5rem 0;
  font-size: 13px;
}
.msg-assistant .msg-text th,
.msg-assistant .msg-text td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}
.msg-assistant .msg-text th {
  background: var(--bg-tertiary);
  font-weight: 650;
  color: var(--text-primary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.msg-assistant .msg-text tr:nth-child(even) td {
  background: var(--bg-secondary);
}
.msg-assistant .msg-text hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: .75rem 0;
}
.msg-assistant .msg-text > *:first-child { margin-top: 0; }
.msg-assistant .msg-text > *:last-child { margin-bottom: 0; }

.streaming-cursor .msg-text::after {
  content: '▊';
  animation: blink .7s step-end infinite;
  color: var(--accent);
}
@keyframes blink { 50% { opacity: 0; } }

/* Input bar */
.chat-input-bar {
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.chat-form {
  display: flex;
  gap: .5rem;
}
.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  background: var(--bg-primary);
  color: var(--text-primary);
}
.chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(12,155,131,0.12);
}
.chat-input::placeholder { color: var(--text-muted); }
.chat-input:disabled { opacity: .5; }

.btn-chat-send {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}
.btn-chat-send:hover { background: var(--accent-hover); }
.btn-chat-send:disabled { opacity: .4; cursor: not-allowed; }

.chat-footer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: .4rem;
  min-height: 1.2rem;
}
.chat-footer-meta span {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.btn-new-chat {
  font-size: 12px;
  color: var(--accent);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px 10px;
  cursor: pointer;
  transition: background .2s;
  font-family: var(--font-body);
}
.btn-new-chat:hover { background: var(--accent-subtle); }

/* Loading */
.search-loading {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 14px;
}
.search-loading .spinner-sm {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-right: .5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .search-hero { padding: 32px 0 20px; }
  .search-hero .container { padding: 0 20px; }
  .search-hero h1 { font-size: 26px; }
  .results-area { padding: 0 20px; }
}

@media (max-width: 640px) {
  .search-form { flex-direction: column; }
  .search-filters { flex-wrap: wrap; }
  .hit-header { flex-direction: column; gap: .25rem; }
  .search-panel { padding: 20px; }
  .chat-panel { height: calc(100vh - 200px); border-radius: 0; border-left: 0; border-right: 0; }
  .results-area { padding: 0 16px; }
  .msg { max-width: 95%; }
  .chat-messages { padding: 16px; }
}
