/* ==========================================================================
   StarSystems Wiki & Documentation Design System
   ========================================================================== */

:root {
  --stars-primary: #2563eb;
  --stars-primary-dark: #1d4ed8;
  --stars-primary-light: #eff6ff;
  --stars-navy: #0f172a;
  --stars-slate: #1e293b;
  --stars-muted: #64748b;
  --stars-border: #e2e8f0;
  --stars-card-bg: #ffffff;
  --stars-sidebar-bg: #f8fafc;
  --stars-code-bg: #0f172a;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, Consolas, monospace;
}

body {
  font-family: var(--font-sans);
  color: #334155;
  background-color: #f8fafc;
  margin-bottom: 0;
  -webkit-font-smoothing: antialiased;
}

/* Navbar */
.navbar-stars {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--stars-border);
  position: sticky;
  top: 0;
  z-index: 1030;
}

.brand-badge {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.brand-badge:hover {
  color: white;
  opacity: 0.92;
}

/* Quick Search Button */
.search-trigger-btn {
  background-color: #f1f5f9;
  border: 1px solid var(--stars-border);
  color: var(--stars-muted);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
  text-decoration: none;
}

.search-trigger-btn:hover {
  background-color: #e2e8f0;
  color: var(--stars-navy);
}

.search-kbd {
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

/* User Avatar */
.avatar-circle {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
}

/* Wiki Container Layout */
:root {
  --wiki-sidebar-width: 290px;
}

.wiki-layout {
  display: flex;
  min-height: calc(100vh - 65px);
  position: relative;
  overflow-x: clip;
}

/* Left Navigation Sidebar */
.wiki-sidebar {
  width: var(--wiki-sidebar-width);
  min-width: var(--wiki-sidebar-width);
  max-width: var(--wiki-sidebar-width);
  background-color: var(--stars-sidebar-bg);
  border-right: 1px solid var(--stars-border);
  padding: 24px 16px;
  height: calc(100vh - 65px);
  position: sticky;
  top: 65px;
  overflow-y: auto;
  transition: margin 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, visibility 0.28s ease;
  z-index: 1010;
}

.wiki-sidebar.collapsed {
  margin-left: calc(-1 * var(--wiki-sidebar-width));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.wiki-sidebar::-webkit-scrollbar {
  width: 5px;
}
.wiki-sidebar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Main Center Content */
.wiki-main-content {
  flex: 1;
  min-width: 0;
  background-color: #ffffff;
  padding: 36px 48px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
}

.wiki-article-container {
  width: 100%;
  max-width: 100%;
  margin: 0;
}

/* Right TOC Sidebar */
.wiki-toc-sidebar {
  width: var(--wiki-sidebar-width);
  min-width: var(--wiki-sidebar-width);
  max-width: var(--wiki-sidebar-width);
  background-color: var(--stars-sidebar-bg);
  border-left: 1px solid var(--stars-border);
  padding: 24px 20px;
  height: calc(100vh - 65px);
  position: sticky;
  top: 65px;
  overflow-y: auto;
  font-size: 0.85rem;
  transition: margin 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, visibility 0.28s ease;
  z-index: 1010;
}

.wiki-toc-sidebar.collapsed {
  margin-right: calc(-1 * var(--wiki-sidebar-width));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.wiki-toc-sidebar::-webkit-scrollbar {
  width: 5px;
}
.wiki-toc-sidebar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Floating Reopen / Expand Buttons */
.sidebar-reopen-btn {
  position: fixed;
  top: 78px;
  z-index: 1020;
  background: #ffffff;
  border: 1px solid var(--stars-border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  color: #475569;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-reopen-btn:hover {
  background: #f8fafc;
  color: var(--stars-primary);
  border-color: #cbd5e1;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

.sidebar-reopen-btn.left-reopen {
  left: 16px;
}

.sidebar-reopen-btn.right-reopen {
  right: 16px;
}

/* Sidebar Project Switcher */
.project-selector-dropdown .dropdown-toggle {
  background: #ffffff;
  border: 1px solid var(--stars-border);
  border-radius: 12px;
  padding: 10px 14px;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  color: var(--stars-navy);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.project-selector-dropdown .dropdown-toggle:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* Sidebar Nav Items */
.wiki-nav-category-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--stars-muted);
  margin-top: 20px;
  margin-bottom: 8px;
  padding-left: 10px;
}

.wiki-nav-link {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  color: #475569;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.wiki-nav-link:hover {
  background-color: #f1f5f9;
  color: var(--stars-primary);
}

.wiki-nav-link.active {
  background-color: #eff6ff;
  color: var(--stars-primary);
  font-weight: 600;
}

/* Article Styling */
.article-header {
  border-bottom: 1px solid var(--stars-border);
  padding-bottom: 24px;
  margin-bottom: 32px;
}

.article-title {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--stars-navy);
  letter-spacing: -0.025em;
  margin-bottom: 12px;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--stars-muted);
}

.article-body {
  font-size: 1.05rem;
  line-height: 1.75;
  color: #334155;
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5,
.article-body h6 {
  scroll-margin-top: 90px;
  color: var(--stars-navy);
}

.article-body h1 {
  font-size: 1.85rem;
  font-weight: 800;
  margin-top: 44px;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.article-body h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 40px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}

.article-body h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 12px;
}

.article-body h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 10px;
}

.article-body h5 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 8px;
}

.article-body h6 {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
  margin-top: 18px;
  margin-bottom: 8px;
}

.article-body p {
  margin-bottom: 1.25rem;
}

.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  margin: 20px 0;
  border: 1px solid var(--stars-border);
}

.article-body blockquote {
  border-left: 4px solid var(--stars-primary);
  background-color: #f8fafc;
  padding: 16px 20px;
  border-radius: 0 8px 8px 0;
  color: #475569;
  margin: 24px 0;
  font-style: italic;
}

.article-body pre {
  background-color: var(--stars-code-bg);
  color: #f8fafc;
  padding: 16px;
  border-radius: 10px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  margin: 20px 0;
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: #f1f5f9;
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
}

.article-body pre code {
  background-color: transparent;
  color: inherit;
  padding: 0;
}

.article-body table {
  width: 100%;
  margin: 24px 0;
  border-collapse: collapse;
}

.article-body table th,
.article-body table td {
  border: 1px solid var(--stars-border);
  padding: 10px 14px;
}

.article-body table th {
  background-color: #f8fafc;
  font-weight: 600;
}

/* Prev / Next Article Buttons */
.wiki-page-navigation {
  margin-top: 60px;
  padding-top: 32px;
  border-top: 1px solid var(--stars-border);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.wiki-nav-card {
  padding: 16px 20px;
  border: 1px solid var(--stars-border);
  border-radius: 12px;
  text-decoration: none;
  background: white;
  transition: all 0.2s ease;
  min-width: 200px;
}

.wiki-nav-card:hover {
  border-color: var(--stars-primary);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}

/* TOC (Table of Contents) */
.toc-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--stars-muted);
  margin-bottom: 12px;
}

.toc-link {
  display: block;
  color: var(--stars-muted);
  text-decoration: none;
  padding: 4px 0;
  font-size: 0.85rem;
  transition: color 0.15s ease;
  border-left: 2px solid transparent;
  padding-left: 10px;
}

.toc-link:hover, .toc-link.active {
  color: var(--stars-primary);
  border-left-color: var(--stars-primary);
  font-weight: 500;
}

.toc-link.depth-1 {
  padding-left: 10px;
  font-weight: 600;
  color: #1e293b;
}

.toc-link.depth-2 {
  padding-left: 18px;
  font-weight: 500;
  color: #334155;
}

.toc-link.depth-3 {
  padding-left: 26px;
}

.toc-link.depth-4 {
  padding-left: 34px;
  font-size: 0.82rem;
}

.toc-link.depth-5 {
  padding-left: 42px;
  font-size: 0.8rem;
}

.toc-link.depth-6 {
  padding-left: 50px;
  font-size: 0.78rem;
}

/* Modals & Dialogs */
.modal-content {
  border: none;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* Utilities */
.smallest {
  font-size: 0.75rem;
}
.smaller {
  font-size: 0.8rem;
}

@media (max-width: 992px) {
  .wiki-toc-sidebar {
    display: none;
  }
  .wiki-main-content {
    padding: 24px;
  }
}

@media (max-width: 768px) {
  .wiki-sidebar {
    position: static;
    width: 100%;
    min-width: 100%;
    height: auto;
  }
  .wiki-layout {
    flex-direction: column;
  }
}

/* ==========================================================================
   Project Logo System (Uniform sizing, Cropper & Display)
   ========================================================================== */
.project-logo-badge {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background-color: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.project-logo-badge-xs {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

.project-logo-table-badge {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  padding: 4px;
  background-color: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.project-logo-card-badge {
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  overflow: hidden;
  flex-shrink: 0;
  padding: 6px;
  background-color: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.project-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Logo Upload & Adjust Widget in Admin Forms */
.project-logo-uploader {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem;
  background-color: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.project-logo-uploader:hover {
  border-color: #94a3b8;
  background-color: #f1f5f9;
}

.project-logo-preview-box {
  width: 80px;
  height: 80px;
  min-width: 80px;
  border-radius: 16px;
  border: 2px solid #e2e8f0;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  position: relative;
}

.project-logo-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

/* Cropper Modal */
.cropper-container-wrapper {
  max-height: 440px;
  width: 100%;
  background-color: #0f172a;
  border-radius: 8px;
  overflow: hidden;
}

.cropper-container-wrapper img {
  max-width: 100%;
  display: block;
}

.cropper-preview-container {
  width: 80px;
  height: 80px;
  overflow: hidden;
  border: 2px solid #e2e8f0;
  background: #ffffff;
}

.cropper-preview-container.rounded-circle {
  border-radius: 50%;
}

.cropper-preview-container.rounded-3 {
  border-radius: 12px;
}

/* ==========================================================================
   PRINT / PDF EXPORT STYLES (@media print)
   ========================================================================== */
@media print {
  @page {
    margin: 18mm 15mm;
  }

  body {
    background: #ffffff !important;
    color: #0f172a !important;
    font-size: 11pt;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide non-article navigation, sidebars, buttons, and modals */
  header,
  .navbar,
  .wiki-sidebar,
  #wikiLeftSidebar,
  .wiki-toc-sidebar,
  #wikiTocSidebar,
  .sidebar-reopen-btn,
  .wiki-page-navigation,
  .modal,
  .alert,
  .d-print-none {
    display: none !important;
  }

  /* Expand article layout to full printable page width */
  .wiki-layout {
    display: block !important;
    min-height: auto !important;
    overflow: visible !important;
  }

  .wiki-main-content {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .wiki-article-container {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
  }

  .article-header {
    margin-bottom: 20px !important;
    padding-bottom: 14px !important;
  }

  .article-title {
    font-size: 22pt !important;
  }

  /* Keep headings attached to following content */
  .article-body h1,
  .article-body h2,
  .article-body h3,
  .article-body h4,
  .article-body h5,
  .article-body h6 {
    page-break-after: avoid;
    break-after: avoid;
  }

  /* Prevent splitting images, code blocks, tables, and blockquotes across pages */
  .article-body img,
  .article-body pre,
  .article-body blockquote,
  .article-body table,
  .article-body tr {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .article-body pre {
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    border: 1px solid #cbd5e1;
  }

  .article-body a {
    text-decoration: underline;
    color: var(--stars-primary) !important;
  }
}
