:root {
  --bg: #0e0f13;
  --panel: #12141a;
  --text: #e5e7eb;
  --text-secondary: #9ca3af;
  --muted: #6b7280;
  --border: #232838;
  --accent: #4900C2;
  --accent-2: #7a4df1;
  --sidebar-width: 280px;
}

* { box-sizing: border-box; }

html, body { 
  height: 100%; 
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

.docs-app { 
  display: grid; 
  grid-template-columns: var(--sidebar-width) 1fr; 
  height: 100vh; 
  overflow: hidden;
}

/* ============ SIDEBAR ============ */
.sidebar {
  background: radial-gradient(800px 600px at -100px -100px, rgba(73,0,194,0.15), transparent 50%), var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.brand img {
  width: 160px;
  filter: drop-shadow(0 0 20px rgba(73,0,194,0.2));
}

.search {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(13, 15, 22, 0.8);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(73,0,194,0.2);
}

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

.search-results {
  margin-top: 8px;
  background: #0f1320;
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 260px;
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(73, 0, 194, 0.5) #0a0b10;
}

.search-results::-webkit-scrollbar {
  width: 8px;
  background: #0a0b10;
}

.search-results::-webkit-scrollbar-track {
  background: #0a0b10;
  border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb {
  background: rgba(73, 0, 194, 0.5);
  border-radius: 4px;
  border: 2px solid #0a0b10;
}

.search-results::-webkit-scrollbar-thumb:hover {
  background: #4900C2;
}

.search-results a {
  display: block;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid rgba(35, 40, 56, 0.5);
  font-size: 14px;
}

.search-results a:last-child { border-bottom: none; }
.search-results a:hover { background: rgba(73, 0, 194, 0.1); }

.search-results .search-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-results .search-result-title {
  font-weight: 700;
  color: #a855f7 !important;
}

.search-results .search-result-title mark {
  background: rgba(168, 85, 247, 0.3);
  color: #c084fc;
}

.search-results .platform-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 6px;
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.search-results .platform-tag.windows {
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.4);
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.18), rgba(59, 130, 246, 0.1));
  box-shadow: 0 0 10px rgba(96, 165, 250, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.search-results .platform-tag.android {
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.4);
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.18), rgba(34, 197, 94, 0.1));
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.search-results .platform-tag.browse {
  color: #c084fc;
  border: 1px solid rgba(192, 132, 252, 0.4);
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.18), rgba(124, 77, 255, 0.1));
  box-shadow: 0 0 10px rgba(192, 132, 252, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Platform Tabs */
.platform-tabs {
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 6px;
}

.platform-tabs-row {
  display: flex;
  gap: 6px;
}

.platform-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  padding: 8px 6px;
  background: rgba(15, 18, 26, 0.6);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  min-width: 0;
}

.platform-tab.browse {
  flex: 1;
}

.platform-tab:hover {
  color: var(--text);
  background: rgba(73, 0, 194, 0.15);
  border-color: rgba(73, 0, 194, 0.4);
}

.platform-tab.active {
  background: rgba(73, 0, 194, 0.2);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(73, 0, 194, 0.3);
}

.platform-tab.browse.active {
  background: rgba(124, 77, 255, 0.25);
  border-color: #7C4DFF;
  box-shadow: 0 0 12px rgba(124, 77, 255, 0.4);
}

.platform-tab svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.nav {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

/* Sidebar scrollbar */
.nav::-webkit-scrollbar {
  width: 6px;
}

.nav::-webkit-scrollbar-track {
  background: transparent;
}

.nav::-webkit-scrollbar-thumb {
  background: rgba(73, 0, 194, 0.3);
  border-radius: 3px;
}

.nav::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.nav details {
  margin: 8px 0;
  background: rgba(15, 18, 26, 0.6);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.nav summary { 
  list-style: none; 
  padding: 12px 14px; 
  cursor: pointer; 
  font-weight: 600; 
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent), #7a4df1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
  user-select: none;
}

.nav summary::-webkit-details-marker { display: none; }

.nav summary::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--accent);
  transition: transform 0.2s;
}

.nav details[open] summary::after {
  transform: translateY(-50%) rotate(180deg);
}

.nav a {
  display: block;
  padding: 10px 14px 10px 18px;
  color: var(--text-secondary);
  text-decoration: none;
  border-top: 1px solid rgba(35, 40, 56, 0.4);
  font-size: 14px;
  transition: all 0.15s;
}

.nav a:hover {
  background: rgba(73, 0, 194, 0.08);
  color: #fff;
  padding-left: 22px;
}

.nav a.active {
  background: rgba(73, 0, 194, 0.15);
  color: #fff;
  border-left: 2px solid var(--accent);
  padding-left: 16px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  text-align: center;
  white-space: nowrap;
}

/* ============ MAIN CONTENT ============ */
.content { 
  display: flex; 
  flex-direction: column; 
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg), #0b0c12);
}

.topbar {
  display: flex;
  align-items: center;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 11, 17, 0.8);
  backdrop-filter: blur(10px);
  height: 52px;
  flex-shrink: 0;
}

.breadcrumb {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.spacer { flex: 1; }

/* Top bar buttons */
.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  transition: all 0.2s;
  margin-left: 8px;
}

.topbar-btn:hover {
  color: #fff;
  border-color: var(--accent);
  background: rgba(73, 0, 194, 0.1);
}

.topbar-btn svg {
  flex-shrink: 0;
}

.topbar-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.topbar-btn-primary:hover {
  background: #5c00e6;
  border-color: #5c00e6;
}

/* Document content area - THE ONLY SCROLLING ELEMENT */
#docContent {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

/* Main content scrollbar */
#docContent::-webkit-scrollbar {
  width: 10px;
}

#docContent::-webkit-scrollbar-track {
  background: #0a0b0f;
}

#docContent::-webkit-scrollbar-thumb {
  background: rgba(73, 0, 194, 0.4);
  border-radius: 5px;
  border: 2px solid #0a0b0f;
}

#docContent::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Iframe styling */
#docContent iframe {
  width: 100%;
  border: none;
  display: block;
}

/* Selection */
::selection {
  background: rgba(73, 0, 194, 0.4);
  color: #fff;
}

/* Hide sidebar toggle on desktop */
.sidebar-toggle {
  display: none;
}

/* Responsive */
@media (max-width: 900px) {
  .docs-app {
    grid-template-columns: 1fr;
    position: relative;
  }
  
  .docs-app::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  
  .docs-app.sidebar-open::before {
    opacity: 1;
    pointer-events: all;
  }
  
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    width: 280px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
  }
  
  .sidebar.open {
    left: 0;
  }
  
  .sidebar-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: rgba(73, 0, 194, 0.2) !important;
    border: 1px solid rgba(73, 0, 194, 0.4) !important;
    border-radius: 8px;
    padding: 10px !important;
    cursor: pointer;
    color: #c084fc !important;
    margin-right: 12px;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
  }
  
  .sidebar-toggle:hover,
  .sidebar-toggle:active {
    background: rgba(73, 0, 194, 0.4) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
  }
  
  .breadcrumb {
    cursor: pointer;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .content {
    width: 100%;
  }
  
  .topbar {
    padding: 12px 16px;
    gap: 8px;
  }
  
  /* Hide text on topbar buttons on mobile, keep icons */
  .topbar-btn {
    padding: 8px !important;
    font-size: 0 !important;
    min-width: 36px;
    width: 36px;
    height: 36px;
  }
  
  .topbar-btn svg {
    width: 18px;
    height: 18px;
  }
}
