/* DialectRanger — Multi-Dialect Database Testing */
:root {
  --bg: #FFFFFF;
  --bg-secondary: #F8FAFC;
  --border: #E5E7EB;
  --text: #111827;
  --text-secondary: #6B7280;
  --accent: #2563EB;
  --accent-light: #EFF6FF;
  --badge-bg: #F3F4F6;
  --code-bg: #F1F5F9;
  --sidebar-w: 260px;
  --header-h: 68px;
  --tabs-h: 43px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 12px;
  z-index: 1000;
  padding: 8px 12px;
  border-radius: 6px;
  color: #FFFFFF;
  background: var(--accent);
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform .15s;
}
.skip-link:focus { transform: translateY(0); }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── DBMS badge colors ──────────────────── */
.badge-dbms { background: var(--badge-bg); }
.dbms-0 .badge-dbms { background: #DBEAFE; color: #1E40AF; }
.dbms-1 .badge-dbms { background: #D1FAE5; color: #065F46; }
.dbms-2 .badge-dbms { background: #FEF3C7; color: #92400E; }
.dbms-3 .badge-dbms { background: #EDE9FE; color: #5B21B6; }
.dbms-4 .badge-dbms { background: #FCE7F3; color: #9D174D; }
.dbms-5 .badge-dbms { background: #CCFBF1; color: #115E59; }
.dbms-6 .badge-dbms { background: #E0E7FF; color: #3730A3; }
.dbms-7 .badge-dbms { background: #FEE2E2; color: #991B1B; }
.dbms-8 .badge-dbms { background: #F3E8FF; color: #6B21A8; }
.dbms-9 .badge-dbms { background: #ECFEFF; color: #155E75; }

/* ── Header ──────────────────────────────── */
#header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-h);
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: baseline; gap: 16px; min-width: 0; }
.header-left h1 { flex-shrink: 0; font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.project-intro { color: var(--text-secondary); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right { flex-shrink: 0; font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; margin-left: 20px; }
.header-right .sep { color: var(--border); }
.gh-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.gh-link:hover { text-decoration: underline; }
.gh-link:focus-visible { outline: 3px solid rgba(37,99,235,.2); outline-offset: 3px; border-radius: 2px; }

/* ── Top Tabs ─────────────────────────────── */
#top-tabs { position: sticky; top: var(--header-h); z-index: 90; display: flex; gap: 0; justify-content: center; height: var(--tabs-h); background: rgba(255,255,255,.96); border-bottom: 1px solid var(--border); padding: 0 24px; backdrop-filter: blur(10px); }
.tab-btn { padding: 10px 24px; border: none; border-bottom: 2px solid transparent; background: none; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-secondary); font-family: inherit; transition: color .12s, border-color .12s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-btn:focus-visible { outline: 3px solid rgba(37,99,235,.16); outline-offset: -4px; border-radius: 5px; }
.tab-status { margin-left: 5px; padding: 1px 6px; border-radius: 999px; color: #92400E; background: #FEF3C7; font-size: 10px; font-weight: 600; vertical-align: 1px; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Bug KB empty placeholder ────────────── */
#bug-empty { max-width: 620px; margin: 72px auto; padding: 42px; text-align: center; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-secondary); }
#bug-empty h2 { margin: 12px 0 8px; font-size: 22px; letter-spacing: -0.01em; }
#bug-empty p { color: var(--text-secondary); }
#bug-empty .bug-note { margin-top: 8px; font-size: 14px; }
.status-pill { display: inline-block; padding: 3px 9px; border-radius: 999px; color: #92400E; background: #FEF3C7; font-size: 12px; font-weight: 600; }

/* ── Layout ──────────────────────────────── */
#layout { display: flex; min-height: calc(100vh - var(--header-h) - var(--tabs-h)); }
#sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--bg-secondary); border-right: 1px solid var(--border); overflow-y: auto; position: sticky; top: calc(var(--header-h) + var(--tabs-h)); height: calc(100vh - var(--header-h) - var(--tabs-h)); padding: 16px 0; }
#main { flex: 1; min-width: 0; padding: 28px 44px 56px; }

/* ── Sidebar ─────────────────────────────── */
.sidebar-title { font-size: 11px; font-weight: 600; color: var(--text-secondary); letter-spacing: 0.08em; padding: 0 16px 12px; }
.dbms-group { margin-bottom: 1px; }
.dbms-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 9px 16px; background: none; border: none; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text); text-align: left; border-radius: 0; }
.dbms-toggle:hover { background: #E2E8F0; }
.dbms-toggle .count { color: var(--text-secondary); font-weight: 400; font-size: 13px; }
.dbms-toggle .arrow { font-size: 10px; color: var(--text-secondary); margin-right: 4px; transition: transform .15s; }
.dbms-toggle.open .arrow { transform: rotate(90deg); }
.dbms-children { display: none; }
.dbms-children.open { display: block; }
.ft-item { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 7px 16px 7px 34px; background: none; border: none; cursor: pointer; font-size: 14px; color: var(--text-secondary); text-align: left; }
.ft-item:hover { color: var(--text); background: #E2E8F0; }
.ft-item.active { color: var(--accent); background: var(--accent-light); font-weight: 500; border-left: 3px solid var(--accent); padding-left: 31px; }
.ft-item .ft-count { font-size: 13px; }

/* ── Stats Bar ───────────────────────────── */
#stats-bar { display: flex; flex-wrap: wrap; gap: 10px 28px; padding: 2px 0 16px; margin-bottom: 18px; font-size: 14px; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
.stat-item { display: flex; align-items: center; gap: 7px; }
.stat-val { font-weight: 700; color: var(--text); font-size: 15px; }

/* ── Search ──────────────────────────────── */
#search-area { margin-bottom: 18px; }
#search-input { width: 100%; height: 46px; padding: 0 18px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; outline: none; font-family: inherit; transition: border-color .15s, box-shadow .15s; }
#search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
#search-input::placeholder { color: #9CA3AF; }
#filters { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
#filters select { height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit; background: var(--bg); color: var(--text); outline: none; cursor: pointer; min-width: 160px; }
#filters select:focus { border-color: var(--accent); }

/* ── Results Header ──────────────────────── */
#results-header { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
#results-header .count { color: var(--text-secondary); font-weight: 400; font-size: 14px; margin-left: 8px; }

/* ── Review Card ─────────────────────────── */
.review-card { border-left: 3px solid #F59E0B; background: #FFFBEB; }
.badge-review { background: #FEF3C7; color: #92400E; }
.card-review-reason { margin-top: 6px; font-size: 13px; color: #92400E; line-height: 1.5; }

/* ── Feature Card ────────────────────────── */
.feature-card { min-width: 0; border: 1px solid var(--border); border-radius: 8px; padding: 14px 20px; margin-bottom: 8px; transition: border-color .12s, box-shadow .12s; }
.feature-card:hover { border-color: #CBD5E1; box-shadow: 0 2px 6px rgba(0,0,0,.05); }
.feature-card.expanded { border-color: var(--accent); box-shadow: 0 2px 8px rgba(37,99,235,.08); }
.card-header { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 0; background: none; cursor: pointer; font: inherit; text-align: left; }
.card-header:focus-visible { outline: 3px solid rgba(37,99,235,.16); outline-offset: 4px; border-radius: 3px; }
.card-name { min-width: 0; overflow-wrap: anywhere; font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.card-expand { font-size: 14px; color: var(--text-secondary); transition: transform .15s; }
.feature-card.expanded .card-expand { transform: rotate(180deg); }
.card-badges { display: flex; gap: 6px; margin-top: 8px; }
.badge { display: inline-block; padding: 3px 9px; font-size: 12px; font-weight: 500; border-radius: 4px; }
.badge-type { background: var(--badge-bg); color: var(--text-secondary); }
.card-desc { margin-top: 8px; font-size: 14px; color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.feature-card.expanded .card-desc { display: block; }
.card-syntax { margin-top: 10px; padding: 9px 14px; overflow-wrap: anywhere; white-space: pre-wrap; background: var(--code-bg); border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; color: var(--text); border-left: 3px solid #CBD5E1; }
.card-footer { display: flex; justify-content: space-between; align-items: center; min-width: 0; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 13px; }
.card-sources { min-width: 0; color: var(--text-secondary); }
.card-links { display: flex; flex-shrink: 0; gap: 12px; }
.card-links a { color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 500; }
.card-links a:hover { text-decoration: underline; }

/* ── Expanded Detail ────────────────────── */
.detail-section { display: none; }
.feature-card.expanded .detail-section { display: block; }
.detail-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.detail-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.detail-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; line-height: 1.6; }
.detail-code { display: block; padding: 7px 12px; margin-bottom: 5px; overflow-wrap: anywhere; white-space: pre-wrap; background: var(--code-bg); border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; color: var(--text); }
.detail-metadata { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; font-size: 14px; margin-top: 10px; }
.detail-metadata dt { color: var(--text-secondary); font-weight: 500; }
.detail-metadata dd { min-width: 0; overflow-wrap: anywhere; color: var(--text); }
.detail-sections { display: flex; flex-wrap: wrap; gap: 5px; }
.detail-sections span { padding: 3px 8px; background: var(--badge-bg); border-radius: 3px; font-size: 12px; color: var(--text-secondary); }

/* ── Progressive results ─────────────────── */
#load-more { display: block; min-width: 210px; margin: 22px auto 0; padding: 10px 18px; border: 1px solid #BFDBFE; border-radius: 8px; color: #1D4ED8; background: var(--accent-light); cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.4; transition: background .12s, border-color .12s; }
#load-more:hover { background: #DBEAFE; border-color: #93C5FD; }
#load-more:focus-visible { outline: 3px solid rgba(37,99,235,.18); outline-offset: 2px; }

/* ── Empty State ─────────────────────────── */
#empty-state { text-align: center; padding: 48px 0; color: var(--text-secondary); }
#empty-state .hint { font-size: 14px; margin-top: 4px; }

/* ── Responsive ──────────────────────────── */
@media (max-width: 900px) {
  #sidebar { width: 200px; }
  .project-intro { max-width: 390px; }
  #main { padding-right: 28px; padding-left: 28px; }
}
@media (max-width: 640px) {
  :root { --header-h: 64px; }
  #header { padding: 0 16px; }
  .header-left { display: block; }
  .header-left h1 { font-size: 18px; }
  .project-intro { max-width: 260px; font-size: 11px; }
  .header-right span { display: none; }
  .header-right { margin-left: 10px; }
  #top-tabs { justify-content: stretch; padding: 0; }
  .tab-btn { flex: 1; padding: 10px 8px; font-size: 13px; }
  .tab-status { display: none; }
  #layout { flex-direction: column; }
  #sidebar { display: none; }
  #main { padding: 16px; }
  #stats-bar { gap: 8px 18px; }
  #filters select { flex: 1; min-width: 140px; }
  .feature-card { padding: 14px 15px; }
  .card-footer { align-items: flex-start; gap: 10px; }
  .card-sources { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #bug-empty { margin: 32px 16px; padding: 32px 20px; }
}
