/* Medi-Cal Coverage — warm dark UI. No gradients, no shadows. */

:root {
  /* Backgrounds */
  --bg-base: #111110;
  --bg-card: #1C1C1A;
  --bg-input: #232320;
  --bg-hover: #2A2A27;

  /* Borders */
  --border: #2E2E2B;
  --border-focus: #4A4A45;

  /* Text */
  --text-primary: #EDEDEC;
  --text-secondary: #999991;
  --text-muted: #666660;

  /* Accent — matches landing Check coverage orange */
  --accent: #D4782A;
  --accent-hover: #E8A055;
  --accent-muted: rgba(212, 120, 42, 0.12);

  /* Semantic */
  --success: #5EC269;
  --success-bg: rgba(94, 194, 105, 0.08);
  --danger: #E25D5D;
  --danger-bg: rgba(226, 93, 93, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--text-secondary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

/* Layout */
.appLayout {
  display: flex;
  min-height: 100vh;
}

.sidebarWrap {
  display: flex;
  flex-shrink: 0;
  width: 312px;
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  transition: width 0.2s ease;
}

.appLayout.sidebarClosed .sidebarWrap {
  width: 40px;
}

.appLayout.sidebarClosed .sidebar {
  width: 0;
  min-width: 0;
  overflow: hidden;
  padding: 0;
}

.sidebarToggle {
  flex-shrink: 0;
  width: 40px;
  min-height: 44px;
  padding: 0;
  border: none;
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.sidebarToggle:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.appLayout.sidebarClosed .sidebarToggle {
  border-right: none;
}

.appLayout.sidebarClosed .sidebarToggle::before {
  content: "▶";
}

.appLayout:not(.sidebarClosed) .sidebarToggle::before {
  content: "◀";
}

.sidebar {
  width: 272px;
  flex: 1;
  min-width: 0;
  padding: 20px 16px;
  overflow-y: auto;
}

.sidebarHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}

.sidebarTitle {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.historyEditBtn {
  padding: 4px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
}

.historyEditBtn:hover {
  color: var(--accent-hover);
  background: var(--accent-muted);
}

.historyList {
  list-style: none;
  margin: 0;
  padding: 0;
}

.historyItem {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.historyItemContent {
  flex: 1;
  min-width: 0;
}

.historyItemDelete {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.historyItemDelete:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.historyItem:last-child {
  border-bottom: none;
}

.historyQuery {
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 4px;
}

.historyProcedure {
  color: var(--text-secondary);
  font-size: 11px;
  margin-bottom: 6px;
}

.historyDecision {
  font-size: 11px;
  font-weight: 600;
}

.historyDecision.covered {
  color: var(--success);
}

.historyDecision.notCovered {
  color: var(--danger);
}

.historyEmpty {
  color: var(--text-muted);
  font-style: italic;
}

.main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

.wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* Header */
.header {
  margin-bottom: 40px;
}

.header h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Search — no panel wrapper */
.searchRow {
  display: flex;
  gap: 10px;
  align-items: center;
}

.searchRow input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: box-shadow 150ms ease;
}

.searchRow input::placeholder {
  color: var(--text-muted);
}

.searchRow input:focus {
  box-shadow: 0 0 0 1px var(--border-focus);
}

.searchRow button {
  flex-shrink: 0;
  min-width: 80px;
  height: 46px;
  padding: 0 16px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #111110;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 150ms ease;
}

.searchRow button:hover {
  background: var(--accent-hover);
}

.searchRow button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.error {
  display: none;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--danger-bg);
  border: 1px solid rgba(226, 93, 93, 0.15);
  color: var(--danger);
  font-size: 13.5px;
}

.error:not([hidden]) {
  display: block;
}

.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Results — single column */
.results {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Result card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  cursor: pointer;
  transition: border-color 150ms ease;
}

.card:hover {
  border-color: var(--border-focus);
}

.card.hidden {
  display: none;
}

.cardTop {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.card .title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.card .cardMeta {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card .category {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.matchBadge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
}

.matchBadge--best {
  background: #d1fae5;
  color: #065f46;
}

.matchBadge--good {
  background: #dbeafe;
  color: #1e40af;
}

.matchBadge--possible {
  background: #f3f4f6;
  color: #6b7280;
}

.card .description {
  margin-top: 8px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Expanded flow: top bar — only Change link */
.flowHeader {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 14px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.flowHeader .changeLink {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--accent);
  flex-shrink: 0;
}

.flowHeader .changeLink:hover {
  color: var(--accent-hover);
}

/* Flow body (eligibility content on --bg-base) */
.flowBody {
  padding: 20px 10px;
  background: var(--bg-base);
}

/* Pathways */
.pathwaysLabel {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.pathwaysList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pathwaysList li {
  font-size: 13.5px;
  color: var(--text-secondary);
}

/* Answer history — flat list above current question */
.answerHistory {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.answerHistory:empty {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.answerHistoryRow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  min-height: 24px;
}

.answerHistoryDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.answerHistoryDot.yes {
  background: var(--success);
}

.answerHistoryDot.no {
  background: var(--danger);
}

.answerHistoryQ {
  flex: 1;
  min-width: 0;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.answerHistoryA {
  flex-shrink: 0;
  font-weight: 500;
}

.answerHistoryA.yes {
  color: var(--success);
}

.answerHistoryA.no {
  color: var(--danger);
}

/* Current question — left accent bar */
.currentQuestion {
  margin-top: 16px;
  padding-left: 14px;
  border-left: 3px solid var(--accent);
}

.currentQuestionText {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

/* Yes / No buttons */
.ynRow {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.ynBtn {
  flex: 1;
  height: 42px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.ynBtn.yes {
  border: none;
  background: var(--accent);
  color: #111110;
}

.ynBtn.yes:hover:not(:disabled) {
  background: var(--accent-hover);
}

.ynBtn.no {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.ynBtn.no:hover:not(:disabled) {
  border-color: var(--border-focus);
}

.ynBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Loading state (search) */
.loadingState {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 24px 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.loadingDots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.loadingDots .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: dotBounce 0.9s ease-in-out infinite both;
}

.loadingDots .dot:nth-child(1) { animation-delay: 0s; }
.loadingDots .dot:nth-child(2) { animation-delay: 0.15s; }
.loadingDots .dot:nth-child(3) { animation-delay: 0.3s; }

/* Flow loading (pathways + first question loading) */
.flowLoading .flowLoadingState {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 24px 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.flowLoadingDots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.flowLoadingDots .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: dotBounce 0.9s ease-in-out infinite both;
}

.flowLoadingDots .dot:nth-child(1) { animation-delay: 0s; }
.flowLoadingDots .dot:nth-child(2) { animation-delay: 0.15s; }
.flowLoadingDots .dot:nth-child(3) { animation-delay: 0.3s; }

/* Thinking state (next question) — "Loading" etc + three dots animation */
.thinkingState {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.thinkingDots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.thinkingDots .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: dotBounce 0.9s ease-in-out infinite both;
}

.thinkingDots .dot:nth-child(1) { animation-delay: 0s; }
.thinkingDots .dot:nth-child(2) { animation-delay: 0.15s; }
.thinkingDots .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotBounce {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-4px); }
}

/* Outcome result */
.outcomeBox {
  margin-top: 16px;
  padding: 16px 20px;
  border-radius: 12px;
}

.outcomeBox.covered {
  background: var(--success-bg);
  border: 1px solid rgba(94, 194, 105, 0.15);
}

.outcomeBox.covered .outcomeTitle {
  color: var(--success);
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px 0;
}

.outcomeBox.covered .outcomeText {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0;
}

.outcomeBox.notCovered {
  background: var(--danger-bg);
  border: 1px solid rgba(226, 93, 93, 0.15);
}

.outcomeBox.notCovered .outcomeTitle {
  color: var(--danger);
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px 0;
}

.outcomeBox.notCovered .outcomeText {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0;
}

/* Card details container (replaces card content when expanded) */
.cardDetails {
  margin-top: 0;
}

.cardDetails .treeWrap {
  margin-top: 0;
}
