/* Base Variables & Reset */
:root {
  --bg-main: #F8F9FA;
  --bg-surface: #FFFFFF;
  --bg-surface-alt: #F1F5F9;
  --bg-code: #0F172A;
  
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-code: #E0E7FF;
  --text-accent: #1E3A8A;
  
  --border-color: #E2E8F0;
  --border-light: #F1F5F9;
  
  --accent-color: #3B82F6;
  --accent-hover: #EFF6FF;
  
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.search-container {
  margin-top: 16px;
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  padding: 0 12px;
}

.command-list {
  list-style: none;
}

.nav-link {
  display: block;
  padding: 8px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.2s;
}

.nav-link:hover {
  background-color: var(--accent-hover);
  color: var(--accent-color);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0; /* Prevents flex blowout */
}

.mobile-header {
  display: none;
  padding: 16px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  justify-content: space-between;
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  font-size: 20px;
  font-weight: 800;
  transform: scaleX(1.185);
}

.content-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  scroll-behavior: smooth;
}

.content-wrapper {
  max-width: 800px;
  margin: 0 auto;
  padding-bottom: 64px;
}

/* Command Sections */
.command-section {
  margin-bottom: 64px;
  scroll-margin-top: 32px;
}

.command-header {
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}

.command-title {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.command-desc {
  margin-top: 12px;
  font-size: 1.125rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Method Cards */
.methods-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.method-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: box-shadow 0.2s;
}

.method-card:hover {
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.method-header {
  padding: 16px 24px;
  background-color: var(--bg-surface-alt);
  border-bottom: 1px solid var(--border-light);
}

.method-name {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-accent);
}

.method-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.method-usage {
  background-color: var(--bg-code);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
}

.method-usage code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-code);
  white-space: pre;
}

.method-description {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.7;
}

/* Scrollable Description for Long Text */
.method-description.long-text {
  max-height: 240px;
  overflow-y: auto;
  padding-right: 12px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

/* ── Sidebar: Sub-list (methods under a command) ─────────────── */
.nav-item {
  position: relative;
}

.nav-sublist {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.75rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.nav-subitem {
  margin: 0;
  padding: 0;
}

.nav-sublink {
  display: block;
  padding: 0.2rem 0.5rem 0.2rem 0.5rem;
  font-size: 0.78rem;
  opacity: 0.65;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 2px solid transparent;
  transition: opacity 0.15s, border-color 0.15s, color 0.15s;
}

.nav-sublink:hover {
  opacity: 1;
  border-left-color: currentColor;
}

.nav-item.active .nav-sublink {
  opacity: 0.75;
}

.nav-item.active .nav-link {
  font-weight: 600;
}

/* ── Sidebar: Hidden items (filtered by search) ──────────────── */
.nav-item.hidden {
  display: none;
}

/* ── Sidebar: Nav count badge ────────────────────────────────── */
.nav-count {
  font-size: 0.72rem;
  opacity: 0.5;
  font-weight: 400;
  margin-left: 0.25em;
}

/* ── Search clear button ─────────────────────────────────────── */
.search-container {
  position: relative;
}

.search-clear {
  display: none;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 0.75rem;
  opacity: 0.5;
  padding: 0.25rem;
  line-height: 1;
  transition: opacity 0.15s;
  user-select: none;
}

.search-clear:hover {
  opacity: 1;
}

/* ── Search highlight ────────────────────────────────────────── */
mark.search-highlight {
  background: rgba(255, 210, 80, 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* ── Hidden sections / cards ─────────────────────────────────── */
.command-section.hidden,
.method-card.hidden {
  display: none;
}

/* ── No results state ────────────────────────────────────────── */
.no-results {
  padding: 3rem 1.5rem;
  text-align: center;
  opacity: 0.6;
}

.no-results p {
  margin: 0.25rem 0;
}

.no-results-hint {
  font-size: 0.85rem;
}

/* ── Loading state ───────────────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  gap: 1rem;
  opacity: 0.6;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.load-error {
  text-align: center;
  opacity: 0.7;
  line-height: 1.6;
}

/* ── Copy button ─────────────────────────────────────────────── */
.method-usage {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.copy-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 4px;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  color: inherit;
  transition: opacity 0.15s, border-color 0.15s, background 0.15s;
}

.copy-btn svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.method-card:hover .copy-btn,
.method-usage:hover .copy-btn {
  opacity: 0.5;
}

.copy-btn:hover {
  opacity: 1 !important;
  border-color: currentColor;
}

.copy-btn-pre {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  opacity: 0;
}

pre:hover .copy-btn-pre {
  opacity: 0.5;
}

/* ── Copy tooltip ────────────────────────────────────────────── */
.copy-tooltip {
  position: fixed;
  z-index: 9999;
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: 4px;
  background: rgba(30, 30, 30, 0.9);
  color: #fff;
  pointer-events: none;
  transform: translateX(-50%) translateY(0);
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}

.copy-tooltip.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* ── Read More / Show Less ───────────────────────────────────── */
.method-description.long-text {
  position: relative;
  max-height: 5.5em;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

/* Fade-out gradient at bottom when collapsed */
.method-description.long-text:not(.expanded)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2.5em;
  background: linear-gradient(transparent, var(--card-bg, #fff));
  pointer-events: none;
}

.method-description.long-text.expanded {
  max-height: 600px; /* large enough for any description */
  overflow: visible;
}

.method-description.long-text.expanded::after {
  display: none;
}

.read-more-btn {
  display: inline-block;
  margin-top: 0.4rem;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: inherit;
  opacity: 0.6;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 0.15s;
}

.read-more-btn:hover {
  opacity: 1;
}

/* ── Method badges (return type etc.) ────────────────────────── */
.method-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.method-badge {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 3px;
  opacity: 0.7;
  font-family: monospace;
}

.method-return-type {
  border: 1px solid currentColor;
}

/* ── Parameters table ────────────────────────────────────────── */
.method-params {
  margin-top: 0.75rem;
}

.params-title,
.examples-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.5;
  margin-bottom: 0.4rem;
}

.params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.params-table th,
.params-table td {
  text-align: left;
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid rgba(128,128,128,0.15);
}

.params-table th {
  font-weight: 600;
  opacity: 0.6;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.param-type {
  font-family: monospace;
  font-size: 0.82em;
  opacity: 0.8;
}

/* ── Code examples ───────────────────────────────────────────── */
.method-examples {
  margin-top: 0.75rem;
}

.example-block {
  margin-bottom: 0.5rem;
}

.example-label {
  font-size: 0.75rem;
  opacity: 0.55;
  margin-bottom: 0.2rem;
}

.example-block pre {
  position: relative;
  margin: 0;
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
  font-size: 0.83rem;
  overflow-x: auto;
  background: rgba(128,128,128,0.08);
}

/* ── No methods message ──────────────────────────────────────── */
.no-methods-msg {
  font-size: 0.85rem;
  opacity: 0.45;
  font-style: italic;
  padding: 0.25rem 0;
}


/* Responsive Design (Media Queries) */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 40;
    transform: translateX(-100%);
    box-shadow: 4px 0 15px rgba(0,0,0,0.05);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .mobile-header {
    display: flex;
  }

  .content-scroll-area {
    padding: 16px;
  }

  .command-title {
    font-size: 2rem;
  }

  .method-body {
    padding: 16px;
  }
}
