/* LLMWiki Engine Stylesheet
 * Minimal, clean, developer-focused plain colorscheme.
 * No gradients, no glows, no glassmorphism. Just clear spacing and high readability.
 */

:root {
  /* Google Roboto Font Stack */
  --font-header: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: 'Fira Code', SFMono-Regular, Consolas, monospace;
  
  --sidebar-width: 280px;
  --header-height: 56px;
  --transition-fast: 0.15s ease-out;
  --border-radius: 8px; /* Material Design standard corner radius */
}

/* Plain Dark Mode */
body.dark-mode {
  --bg-app: #1e1e1e;
  --bg-sidebar: #181818;
  --bg-content: #1e1e1e;
  --border-color: #2d2d2d;
  --border-focus: #4b4b4b;
  --text-primary: #e0e0e0;
  --text-secondary: #aaaaaa;
  --text-muted: #666666;
  --accent-color: #4a90e2;
  --accent-hover: #357abd;
  --accent-light: #4a90e2;
  --bg-active: #2d2d2d;
  --bg-code: #282828;
  --blockquote-border: #444444;
  --scrollbar-thumb: #333333;
}

/* Plain Light Mode */
body.light-mode {
  --bg-app: #ffffff;
  --bg-sidebar: #f6f8fa;
  --bg-content: #ffffff;
  --border-color: #e1e4e8;
  --border-focus: #b5b5b5;
  --text-primary: #24292e;
  --text-secondary: #586069;
  --text-muted: #959da5;
  --accent-color: #0366d6;
  --accent-hover: #005cc5;
  --accent-light: #0366d6;
  --bg-active: #e1e4e8;
  --bg-code: #f6f8fa;
  --blockquote-border: #dfe2e5;
  --scrollbar-thumb: #e1e4e8;
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--text-primary);
  background-color: var(--bg-app);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 8px;
  height: 8px;
  background-color: var(--text-primary);
  border-radius: 50%;
}

.brand h1 {
  font-family: var(--font-header);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.mobile-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
}

/* Sidebar Search */
.sidebar-search {
  padding: 12px 20px;
}

.sidebar-search input {
  width: 100%;
  padding: 6px 10px;
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
}

.sidebar-search input:focus {
  border-color: var(--border-focus);
}

/* Sidebar Navigation */
.sidebar-nav {
  flex-grow: 1;
  overflow-y: auto;
  padding: 12px 20px;
}

.sidebar-nav h1,
.sidebar-nav h2,
.sidebar-nav h3 {
  font-family: var(--font-header);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 18px;
  margin-bottom: 6px;
}

.sidebar-nav h1:first-of-type,
.sidebar-nav h2:first-of-type,
.sidebar-nav h3:first-of-type {
  margin-top: 0;
}

.sidebar-nav ul,
.sidebar-nav ol {
  list-style: none;
  margin-bottom: 12px;
}

.sidebar-nav li {
  margin-bottom: 2px;
}

.sidebar-nav a {
  display: block;
  padding: 6px 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  border-radius: var(--border-radius);
  transition: all var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav a:hover {
  background-color: var(--bg-active);
  color: var(--text-primary);
}

.sidebar-nav a.active {
  background-color: var(--bg-active);
  color: var(--text-primary);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

/* Theme Toggle Button (Material-inspired pill button) */
.theme-toggle-btn {
  width: 100%;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: transparent;
  border: 1px solid var(--border-color);
  border-radius: 100px; /* Pill outline shape */
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

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

.theme-toggle-btn:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-content);
  overflow: hidden;
}

/* Header */
.content-header {
  height: var(--header-height);
  padding: 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-sidebar);
}

.mobile-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 18px;
  height: 12px;
  background: none;
  border: none;
  cursor: pointer;
}

.mobile-toggle span {
  width: 100%;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 1px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  font-family: var(--font-header);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.crumb-separator {
  margin: 0 6px;
  color: var(--text-muted);
}

.crumb.active {
  color: var(--text-primary);
  font-weight: 600;
}

.raw-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8rem;
  transition: all var(--transition-fast);
}

.raw-btn:hover {
  background-color: var(--bg-active);
  color: var(--text-primary);
}

/* Content Container */
.content-wrapper {
  flex-grow: 1;
  overflow-y: auto;
  padding: 32px 48px;
  display: flex;
  justify-content: center;
}

.markdown-body {
  max-width: 760px;
  width: 100%;
  line-height: 1.6;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* Markdown Elements Styling */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  font-family: var(--font-header);
  color: var(--text-primary);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.markdown-body h1 {
  font-size: 1.8rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  margin-top: 0;
}

.markdown-body h2 {
  font-size: 1.4rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
}

.markdown-body h3 { font-size: 1.15rem; }
.markdown-body h4 { font-size: 1rem; }

.markdown-body p {
  margin-bottom: 1rem;
}

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

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

/* Lists */
.markdown-body ul,
.markdown-body ol {
  margin-bottom: 1rem;
  padding-left: 20px;
}

.markdown-body li {
  margin-bottom: 4px;
}

/* Blockquotes */
.markdown-body blockquote {
  padding: 8px 16px;
  background-color: var(--bg-sidebar);
  border-left: 3px solid var(--blockquote-border);
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.markdown-body blockquote p {
  margin-bottom: 0;
}

/* Code & Preformatted */
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 2px 4px;
  background-color: var(--bg-code);
  color: var(--text-primary);
  border-radius: 3px;
  border: 1px solid var(--border-color);
}

.markdown-body pre {
  margin-bottom: 1rem;
  padding: 16px;
  background-color: var(--bg-code);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  overflow-x: auto;
}

.markdown-body pre code {
  padding: 0;
  background-color: transparent;
  color: inherit;
  font-size: 0.9em;
  border: none;
}

/* Tables */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

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

.markdown-body th {
  background-color: var(--bg-sidebar);
  font-weight: 600;
  color: var(--text-primary);
}

/* Horizontal Rules */
.markdown-body hr {
  border: 0;
  height: 1px;
  background-color: var(--border-color);
  margin: 2rem 0;
}

/* Images */
.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  margin: 1rem 0;
  border: 1px solid var(--border-color);
}

/* Placeholders & Loaders */
.loading-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Error Container */
.error-container {
  text-align: center;
  padding: 40px;
  background-color: var(--bg-sidebar);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  max-width: 400px;
  margin: 40px auto;
}

.error-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.error-container h2 {
  font-size: 1.4rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.error-container p {
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.error-details {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  background-color: var(--bg-app);
  padding: 6px 10px;
  border-radius: var(--border-radius);
  display: inline-block;
  margin-bottom: 16px;
}

.back-home-btn {
  display: inline-block;
  padding: 8px 16px;
  background-color: var(--accent-color);
  color: #fff !important;
  text-decoration: none !important;
  font-weight: 600;
  border-radius: var(--border-radius);
}

.back-home-btn:hover {
  background-color: var(--accent-hover);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 90;
}

/* Responsive Breakpoints */
@media (max-width: 992px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform var(--transition-fast) ease-out;
  }
  
  .mobile-close {
    display: block;
  }
  
  .mobile-toggle {
    display: flex;
  }
  
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  
  body.sidebar-open .sidebar-overlay {
    display: block;
  }
  
  .content-header {
    padding: 0 20px;
  }
  
  .content-wrapper {
    padding: 24px 20px;
  }
}

/* ==========================================================================
   LLMWiki Polish: Search Bar, Dropdowns, Tags, Folder Cards
   ========================================================================== */

/* Header Search Container */
.header-search-container {
  position: relative;
  width: 100%;
  max-width: 380px;
  margin: 0 20px;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 100px; /* Pill styled Material input */
  color: var(--text-secondary);
  transition: border-color var(--transition-fast);
}

.search-input-wrapper:focus-within {
  border-color: var(--border-focus);
}

.search-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-input-wrapper input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
}

.clear-search-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px;
}

.clear-search-btn:hover {
  color: var(--text-primary);
}

/* Floating Search Dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  max-height: 320px;
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow-y: auto;
  z-index: 1000;
}

.search-result-item {
  display: block;
  padding: 10px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-color);
  transition: background-color var(--transition-fast);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background-color: var(--bg-active);
  color: var(--text-primary);
}

.search-result-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.search-result-snippet {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-no-results {
  padding: 14px;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.85rem;
}

/* Exploration Page Dashboards (Tags & Groups) */
.dashboard-section {
  margin-bottom: 2.5rem;
}

.dashboard-section-title {
  font-family: var(--font-header);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Grid Layouts */
.folder-grid,
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.page-grid {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

/* Cards */
.folder-card,
.page-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  text-decoration: none;
  color: var(--text-secondary);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.folder-card:hover,
.page-card:hover {
  border-color: var(--border-focus);
  background-color: var(--bg-active);
  color: var(--text-primary);
}

.folder-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.folder-icon {
  color: var(--accent-color);
  flex-shrink: 0;
}

.folder-title {
  font-family: var(--font-header);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
}

.folder-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Page Card Spec */
.page-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.page-card-title {
  font-family: var(--font-header);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
}

.group-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  background-color: var(--bg-active);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.page-card-summary {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
  flex-grow: 1;
}

/* Tags Badge & List */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.tag-badge:hover {
  background-color: var(--bg-active);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.tag-badge.active {
  background-color: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}

/* Sidebar Sections Layout */
.sidebar-section-divider {
  margin: 16px 0 8px 0;
  border: 0;
  height: 1px;
  background-color: var(--border-color);
}

/* Sidebar List Styling */
.sidebar-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-count-indicator {
  font-size: 0.7rem;
  padding: 2px 6px;
  background-color: var(--bg-active);
  border-radius: 10px;
  color: var(--text-muted);
}

/* Code Block Copy Wrapper and Button */
.code-block-wrapper {
  position: relative;
  margin: 16px 0;
}

.code-block-wrapper pre {
  margin: 0 !important;
}

.copy-code-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  z-index: 10;
}

.code-block-wrapper:hover .copy-code-btn {
  opacity: 1;
}

.copy-code-btn:hover {
  background-color: var(--bg-active);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.copy-code-btn.copied {
  color: #2da44e; /* Tick Green */
  border-color: #2da44e;
  opacity: 1;
}


