/* ============================================
   Docs Viewer - Professional Dark Theme
   ============================================ */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a25;
  --glass-bg: rgba(255, 255, 255, 0.02);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-hover: rgba(255, 255, 255, 0.04);

  --text-primary: #f0f0f5;
  --text-secondary: #b0b0c0;
  --text-muted: #707085;

  --accent-primary: #3b82f6;
  --accent-secondary: #60a5fa;

  --sidebar-width: 320px;
  --header-height: 56px;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Hide menu button by default (desktop) - shown only on mobile */
.menu-btn {
  display: none;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family:
    'Inter',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
}

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

/* Header */
#header {
  height: var(--header-height);
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.logo {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-primary);
}

.logo-link {
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.logo-link:hover {
  opacity: 0.8;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar {
  display: flex;
  gap: 12px;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toolbar-btn:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.toolbar-btn.active {
  background: var(--accent-primary);
  border-color: transparent;
  color: white;
}

.toolbar-btn .icon {
  width: 16px;
  height: 16px;
}

/* Viewer Layout */
#viewer {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.pane {
  display: flex;
  flex: 1;
  min-width: 0;
}

.pane.secondary {
  display: none;
  border-left: 1px solid var(--glass-border);
}

#viewer.compare-mode .pane.secondary {
  display: flex;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
}

.sidebar-header h2 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.external-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.external-link:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}

/* Scrollbars */
.sidebar-content::-webkit-scrollbar,
.content-body::-webkit-scrollbar {
  width: 8px;
}

.sidebar-content::-webkit-scrollbar-thumb,
.content-body::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 4px;
}

/* File Tree */
.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.file-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.file-link:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}

.file-link.active {
  background: var(--accent-primary);
  color: white;
}

.icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
}

.file-link .icon {
  color: var(--accent-primary);
}

.file-link.active .icon {
  color: white;
}

/* Folder Tree Styles */
.folder-item {
  margin-bottom: 4px;
}

.folder-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
}

.folder-link:hover {
  background: var(--glass-hover);
}

.folder-link .icon {
  color: #f59e0b;
  opacity: 1;
}

.folder-children {
  list-style: none;
  padding-left: 20px;
  margin: 4px 0 8px 0;
  border-left: 1px solid var(--glass-border);
  margin-left: 8px;
}

.folder-item.open > .folder-link {
  color: var(--accent-secondary);
}

/* Content Area */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
}

.content-header {
  height: 48px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass-bg);
  flex-shrink: 0;
}

.file-path-slot {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px 48px;
}

/* Markdown Content */
.markdown-body {
  max-width: 900px;
  color: var(--text-primary);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  color: var(--text-primary);
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
}

.markdown-body h1 {
  font-size: 2rem;
  margin-top: 0;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0.3em;
}

.markdown-body p {
  margin: 1em 0;
  color: var(--text-secondary);
}

.markdown-body a {
  color: var(--accent-secondary);
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
  color: var(--accent-primary);
}

.markdown-body pre {
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  border: 1px solid var(--glass-border);
}

.markdown-body blockquote {
  border-left: 3px solid var(--accent-primary);
  background: var(--glass-bg);
  padding: 12px 20px;
  color: var(--text-secondary);
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
}

.markdown-body th,
.markdown-body td {
  padding: 10px;
  border: 1px solid var(--glass-border);
  text-align: left;
}

.markdown-body img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
}

/* Intro */
.intro h1 {
  font-size: 2.5rem;
  color: var(--accent-primary);
  margin-bottom: 16px;
}

.stats {
  display: flex;
  gap: 32px;
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid var(--glass-border);
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
}

.sidebar-overlay.visible {
  display: block;
}

/* Mobile Navigation Buttons */
.pane-nav-btn {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 85vw;
  }

  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content-body {
    padding: 20px 16px;
  }

  .pane-nav-btn {
    display: flex;
  }

  .menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
  }

  .menu-btn .icon {
    width: 20px;
    height: 20px;
  }

  .toolbar-btn span {
    display: none;
  }

  #viewer.compare-mode {
    flex-direction: column;
  }

  #viewer.compare-mode .pane {
    height: 50vh;
    min-height: 300px;
  }

  #viewer.compare-mode .pane.secondary {
    border-left: none;
    border-top: 2px solid var(--accent-primary);
  }
}
