/* ═══════════════════════════════════════════════
   Kotlin stdlib Quick Reference
   Aesthetic: IDE panel — Darcula-heritage dark chrome
   ═══════════════════════════════════════════════ */

:root {
  /* Surface layers */
  --bg-deep: #1a1b1e;
  --bg-base: #1e1f23;
  --bg-raised: #25262b;
  --bg-surface: #2c2d33;
  --bg-hover: #32333a;
  --bg-active: #383944;

  /* Borders */
  --border-subtle: #2e2f36;
  --border-default: #393a42;
  --border-strong: #4a4b55;

  /* Text */
  --text-primary: #e3e4e9;
  --text-secondary: #b4b6c1;
  --text-tertiary: #7c7e92;
  --text-inverse: #1a1b1e;

  /* Syntax — Darcula-inspired */
  --syn-keyword: #cc7832;
  --syn-type: #a9b7c6;
  --syn-string: #6a8759;
  --syn-number: #6897bb;
  --syn-param: #a9b7c6;
  --syn-annotation: #bbb529;
  --syn-function: #ffc66d;
  --syn-generic: #507874;

  /* Accents */
  --accent-kotlin: #7f52ff;
  --accent-kotlin-dim: rgba(127, 82, 255, 0.15);
  --accent-blue: #589df6;
  --accent-orange: #cc7832;
  --accent-green: #6a8759;
  --accent-teal: #4dbfad;

  /* Kind badges */
  --badge-fn: #589df6;
  --badge-ext: #a478e8;
  --badge-prop: #4dbfad;
  --badge-ctor: #e8a84a;

  /* Spacing */
  --toolbar-h: 72px;
  --typebar-h: 58px;

  /* Fonts */
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Light theme — IntelliJ "Light" heritage ───── */

:root[data-theme="light"] {
  /* Surface layers */
  --bg-deep: #f4f5f7;
  --bg-base: #ffffff;
  --bg-raised: #f7f8fa;
  --bg-surface: #eef0f3;
  --bg-hover: #e9ebef;
  --bg-active: #dce4f2;

  /* Borders */
  --border-subtle: #e5e7eb;
  --border-default: #d2d5db;
  --border-strong: #b6bac2;

  /* Text */
  --text-primary: #1a1b1e;
  --text-secondary: #45474f;
  --text-tertiary: #80838f;
  --text-inverse: #ffffff;

  /* Syntax — IntelliJ light-inspired */
  --syn-keyword: #0033b3;
  --syn-type: #00627a;
  --syn-string: #067d17;
  --syn-number: #1750eb;
  --syn-param: #001080;
  --syn-annotation: #9e880d;
  --syn-function: #7a3e9d;
  --syn-generic: #00627a;

  /* Accents */
  --accent-kotlin: #7f52ff;
  --accent-kotlin-dim: rgba(127, 82, 255, 0.12);
  --accent-blue: #1750eb;
  --accent-orange: #c07000;
  --accent-green: #067d17;
  --accent-teal: #00808a;

  /* Kind badges */
  --badge-fn: #1750eb;
  --badge-ext: #7a3e9d;
  --badge-prop: #00808a;
  --badge-ctor: #b06b00;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 19.5px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-deep);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
}

/* ── App shell ───────────────────────────────── */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Toolbar ─────────────────────────────────── */

.toolbar {
  height: var(--toolbar-h);
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 18px;
  gap: 18px;
  flex-shrink: 0;
  z-index: 10;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.logo-icon {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  object-fit: contain;
}

.logo-text {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 18px;
  color: var(--text-secondary);
  letter-spacing: -0.3px;
}

.toolbar-center {
  min-width: 0;
  width: 700px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 44px;
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 0 14px 0 42px;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 400;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.search-input::placeholder {
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  font-size: 16px;
}

.search-input:focus {
  border-color: var(--accent-kotlin);
  background: var(--bg-surface);
}

.search-hint {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--text-tertiary);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.search-input:focus ~ .search-hint {
  opacity: 1;
}

.search-hint kbd {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 20px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.result-count {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

.result-count:empty {
  display: none;
}

.version-label {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.theme-toggle svg {
  display: block;
}

.version-select {
  height: 36px;
  flex-shrink: 0;
  padding: 0 28px 0 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  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='%237c7e92' stroke-width='2.5' 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 9px center;
}

.version-select:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

:root[data-theme="light"] .theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun,
:root:not([data-theme="light"]) .theme-icon-sun { display: none; }

/* ── Type bar ────────────────────────────────── */

.type-bar {
  height: var(--typebar-h);
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 18px;
  display: none;
  align-items: center;
  overflow: hidden;
  flex-shrink: 0;
}

.type-bar.visible {
  display: flex;
}

.type-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 0;
}

.type-chips::-webkit-scrollbar {
  display: none;
}

.type-chip {
  padding: 5px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
  flex-shrink: 0;
}

.type-chip:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.type-chip.active {
  background: var(--accent-kotlin-dim);
  border-color: var(--accent-kotlin);
  color: var(--accent-kotlin);
}

.type-chip.kbd {
  background: var(--bg-active);
  border-color: var(--accent-kotlin);
  color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--accent-kotlin-dim);
}

/* ── Results ─────────────────────────────────── */

.results-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.results-list {
  height: 100%;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.results-list::-webkit-scrollbar {
  width: 6px;
}

.results-list::-webkit-scrollbar-track {
  background: transparent;
}

.results-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

/* ── Result row ──────────────────────────────── */

.result-row {
  display: flex;
  align-items: baseline;
  padding: 8px 24px;
  gap: 10px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.08s;
  min-height: 40px;
  flex-wrap: nowrap;
}

.result-row:hover {
  background: var(--bg-hover);
}

.result-row.selected {
  background: var(--bg-active);
  border-left-color: var(--accent-kotlin);
}

.result-row.deprecated {
  opacity: 0.5;
}

.result-row.deprecated .member-name {
  text-decoration: line-through;
}

/* Kind badge */
.kind-badge {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 22px;
}

.kind-badge.fn {
  background: rgba(88, 157, 246, 0.12);
  color: var(--badge-fn);
}

.kind-badge.ext {
  background: rgba(164, 120, 232, 0.12);
  color: var(--badge-ext);
}

.kind-badge.prop {
  background: rgba(77, 191, 173, 0.12);
  color: var(--badge-prop);
}

.kind-badge.ctor {
  background: rgba(232, 168, 74, 0.12);
  color: var(--badge-ctor);
}

/* Type tag */
.type-tag {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  color: var(--text-tertiary);
  flex-shrink: 0;
  min-width: 0;
}

/* Member name */
.member-name {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--syn-function);
  flex-shrink: 0;
}

/* Operator symbol */
.operator-sym {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* Abbreviated signature */
.sig-abbrev {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}

/* Return type */
.return-type {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--syn-generic);
  flex-shrink: 0;
  white-space: nowrap;
}

/* Separator between return type and summary */
.sig-sep {
  color: var(--border-strong);
  flex-shrink: 0;
  font-size: 13px;
}

/* Summary in result row */
.sig-summary {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
  margin-left: 4px;
}

/* Param doc in detail panel */
.detail-param-doc {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-tertiary);
  padding: 1px 0 4px 0;
  margin-left: 0;
}

/* ── Expanded detail panel ───────────────────── */

.result-detail {
  background: var(--bg-raised);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  padding: 18px 24px 18px 42px;
  display: none;
  animation: detailSlide 0.12s ease-out;
}

.result-detail.open {
  display: block;
}

@keyframes detailSlide {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.detail-signature {
  font-family: var(--font-mono);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-primary);
  padding: 12px 18px;
  background: var(--bg-surface);
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Signature syntax highlighting */
.detail-signature .kw { color: var(--syn-keyword); font-weight: 500; }
.detail-signature .tp { color: var(--syn-generic); }
.detail-signature .fn { color: var(--syn-function); }
.detail-signature .pn { color: var(--syn-param); }
.detail-signature .ty { color: var(--syn-type); }

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 14px;
  font-size: 15px;
}

.detail-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
}

.detail-meta-label {
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.detail-meta-value {
  font-family: var(--font-mono);
  font-size: 15px;
}

.detail-params,
.detail-description {
  margin-top: 10px;
}

.detail-params-title,
.detail-description-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.detail-param-row {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  font-family: var(--font-mono);
  font-size: 16px;
}

.detail-param-name {
  color: var(--syn-param);
  font-weight: 500;
  flex-shrink: 0;
}

.detail-param-type {
  color: var(--syn-generic);
}

.detail-param-default {
  color: var(--text-tertiary);
  font-style: italic;
}

.detail-description-text {
  margin-top: 14px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.detail-description p {
  margin: 0 0 8px 0;
}

.detail-description p:last-child {
  margin-bottom: 0;
}

.kdoc-code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--syn-function);
}

.kdoc-codeblock {
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 10px 14px;
  margin: 8px 0;
  overflow-x: auto;
  line-height: 1.5;
  color: var(--text-primary);
}

.kdoc-codeblock code {
  background: none;
  border: none;
  padding: 0;
}

.kdoc-link {
  color: var(--accent-blue);
  text-decoration: none;
}

.kdoc-link:hover {
  text-decoration: underline;
}

.detail-param-doc .kdoc-code {
  font-size: 0.85em;
}

.modifier-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.modifier-tag.inline-tag { color: var(--syn-keyword); border-color: rgba(204, 120, 50, 0.3); }
.modifier-tag.infix-tag { color: var(--syn-keyword); border-color: rgba(204, 120, 50, 0.3); }
.modifier-tag.operator-tag { color: var(--syn-keyword); border-color: rgba(204, 120, 50, 0.3); }
.modifier-tag.suspend-tag { color: var(--accent-teal); border-color: rgba(77, 191, 173, 0.3); }

/* ── Empty state ─────────────────────────────── */

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
}

.empty-state.hidden {
  display: none;
}

.empty-icon {
  width: 72px;
  height: 72px;
  opacity: 0.5;
}

.empty-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.empty-title {
  font-family: var(--font-sans);
  font-size: 24px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-hint {
  font-size: 16px;
  color: var(--text-tertiary);
}

.empty-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  justify-content: center;
}

.example-btn {
  font-family: var(--font-mono);
  font-size: 16px;
  padding: 6px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s;
}

.example-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-kotlin);
}

/* ── Footer ──────────────────────────────────── */

.footer {
  position: fixed;
  bottom: 12px;
  right: 16px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-tertiary);
  z-index: 5;
  text-align: right;
}

.footer a {
  color: var(--text-tertiary);
}

.footer a:hover {
  color: var(--text-secondary);
  text-decoration: underline;
}

.footer.hidden {
  display: none;
}

/* ── Mobile ──────────────────────────────────── */

@media (max-width: 640px) {
  html { font-size: 15px; }

  .toolbar {
    display: flex;
    align-items: center;
    height: auto;
    padding: 10px;
    gap: 0;
  }

  /* On mobile, drop the logo and the version/theme controls so the search bar
     gets the full width. */
  .toolbar-left { display: none; }
  .toolbar-right { display: none; }

  .toolbar-center { width: 100%; gap: 10px; }

  .search-wrapper { max-width: none; }
  .search-hint { display: none; }

  .result-row {
    padding: 6px 10px;
    gap: 6px;
    flex-wrap: wrap;
  }

  .sig-abbrev { display: none; }
  .type-tag { font-size: 10px; }

  .result-detail {
    padding: 10px 12px;
  }

  .detail-signature {
    font-size: 11px;
  }
}
