/* ============================================================
   PathPro Knowledge Base — Stylesheet
   ============================================================ */

/* ----------------------------------------------------------
   1. Design Tokens (Custom Properties)
   ---------------------------------------------------------- */
:root {
  /* Brand */
  --accent: #3376A3;
  --accent-light: #d6e8f3;
  --accent-dark: #2a6189;
  --accent-bg: #edf4f9;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;

  /* Gray scale */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  /* Spacing */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;

  /* Layout */
  --sidebar-width: 260px;
  --content-max-width: 780px;
  --toc-width: 200px;
}

/* ----------------------------------------------------------
   2. Reset & Base
   ---------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-dark);
}

img {
  max-width: 100%;
  display: block;
}

/* ----------------------------------------------------------
   3. Layout (CSS Grid)
   ---------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* ----------------------------------------------------------
   4. Sidebar
   ---------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid var(--gray-200);
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar__header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--gray-900);
  font-weight: 700;
  font-size: var(--text-lg);
  margin-bottom: 14px;
}

.sidebar__logo-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

/* Search */
.sidebar__search {
  position: relative;
}

.sidebar__search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-family);
  background: var(--gray-50);
  color: var(--gray-800);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.sidebar__search-input::placeholder {
  color: var(--gray-400);
}

.sidebar__search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51, 118, 163, 0.15);
  background: #fff;
}

.sidebar__search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--gray-400);
  pointer-events: none;
}

.sidebar__search-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--gray-400);
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font-family);
  pointer-events: none;
}

/* Search Results */
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 360px;
  overflow-y: auto;
  z-index: 200;
  display: none;
}

.search-results.is-open {
  display: block;
}

.search-results__item {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-800);
  transition: background var(--transition-fast);
  text-decoration: none;
}

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

.search-results__item:hover,
.search-results__item.is-active {
  background: var(--accent-bg);
  color: var(--accent-dark);
}

.search-results__title {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 2px;
}

.search-results__category {
  font-size: var(--text-xs);
  color: var(--gray-500);
}

.search-results__empty {
  padding: 16px 14px;
  font-size: var(--text-sm);
  color: var(--gray-500);
  text-align: center;
}

/* Navigation */
.sidebar__nav {
  flex: 1;
  padding: 12px 0 24px;
  overflow-y: auto;
}

.sidebar__section {
  margin-bottom: 4px;
}

.sidebar__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.sidebar__section-header:hover {
  color: var(--gray-700);
}

.sidebar__section-arrow {
  width: 14px;
  height: 14px;
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.sidebar__section.is-collapsed .sidebar__section-arrow {
  transform: rotate(-90deg);
}

.sidebar__section-links {
  list-style: none;
  overflow: hidden;
  transition: max-height var(--transition-normal);
}

.sidebar__section.is-collapsed .sidebar__section-links {
  max-height: 0 !important;
}

.sidebar__link {
  display: block;
  padding: 6px 16px 6px 24px;
  font-size: var(--text-sm);
  color: var(--gray-600);
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.sidebar__link:hover {
  color: var(--accent);
  background: var(--gray-50);
}

.sidebar__link.is-active {
  color: var(--accent);
  background: var(--accent-bg);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* Mobile hamburger */
.sidebar__hamburger {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 40px;
  height: 40px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.sidebar__hamburger svg {
  width: 20px;
  height: 20px;
  color: var(--gray-700);
}

.sidebar__overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 90;
}

/* ----------------------------------------------------------
   5. Main Content Area
   ---------------------------------------------------------- */
.content {
  grid-column: 2;
  padding: 40px 32px 80px 40px;
  min-width: 0;
}

.content__inner {
  max-width: var(--content-max-width);
  margin: 0;
  position: relative;
}

/* ----------------------------------------------------------
   6. Breadcrumbs
   ---------------------------------------------------------- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--gray-500);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--gray-500);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb__sep {
  color: var(--gray-300);
  font-size: var(--text-xs);
}

.breadcrumb__current {
  color: var(--gray-700);
  font-weight: 500;
}

/* ----------------------------------------------------------
   7. Article Content
   ---------------------------------------------------------- */
.article h1 {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.25;
  margin-bottom: 12px;
}

.article__intro {
  font-size: var(--text-lg);
  color: var(--gray-600);
  line-height: 1.7;
  margin-bottom: 32px;
}

.article h2 {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--gray-900);
  margin-top: 48px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
}

.article h3 {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--gray-800);
  margin-top: 32px;
  margin-bottom: 12px;
}

.article p {
  margin-bottom: 16px;
  color: var(--gray-700);
  line-height: 1.7;
}

.article ul, .article ol {
  margin-bottom: 16px;
  padding-left: 24px;
  color: var(--gray-700);
}

.article li {
  margin-bottom: 6px;
  line-height: 1.6;
}

.article li ul, .article li ol {
  margin-top: 6px;
  margin-bottom: 0;
}

.article strong {
  font-weight: 600;
  color: var(--gray-800);
}

.article code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--accent-dark);
}

.article a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.article a:hover {
  color: var(--accent-dark);
}

/* ----------------------------------------------------------
   8. Table of Contents (Right Side)
   ---------------------------------------------------------- */
.toc {
  position: fixed;
  right: 32px;
  top: 100px;
  width: var(--toc-width);
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  font-size: var(--text-xs);
  display: none;
}

.toc__title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 8px;
  font-size: 11px;
}

.toc__list {
  list-style: none;
  border-left: 2px solid var(--gray-200);
}

.toc__item {
  padding: 4px 0 4px 12px;
  border-left: 2px solid transparent;
  margin-left: -2px;
}

.toc__item--h3 {
  padding-left: 24px;
}

.toc__link {
  color: var(--gray-500);
  text-decoration: none;
  transition: color var(--transition-fast);
  display: block;
  line-height: 1.4;
}

.toc__link:hover {
  color: var(--accent);
}

.toc__item.is-active {
  border-left-color: var(--accent);
}

.toc__item.is-active .toc__link {
  color: var(--accent);
  font-weight: 600;
}

/* Show ToC on wide screens */
@media (min-width: 1200px) {
  .toc {
    display: block;
  }

  .content {
    padding-right: calc(var(--toc-width) + 64px);
  }
}

/* ----------------------------------------------------------
   9. Callout Boxes
   ---------------------------------------------------------- */
.callout {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  background: var(--accent-bg);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 24px 0;
}

.callout__icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  color: var(--accent);
  margin-top: 1px;
}

.callout__content {
  flex: 1;
}

.callout__label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 4px;
}

.callout__text {
  font-size: var(--text-sm);
  color: var(--gray-700);
  line-height: 1.6;
}

/* ----------------------------------------------------------
   10. Image Placeholders
   ---------------------------------------------------------- */
.image-placeholder {
  border: 2px dashed var(--gray-300);
  background: var(--gray-100);
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  margin: 24px 0;
}

.image-placeholder__icon {
  width: 40px;
  height: 40px;
  color: var(--gray-400);
  margin: 0 auto 12px;
}

.image-placeholder__caption {
  font-size: var(--text-sm);
  color: var(--gray-500);
  font-style: italic;
}

/* ----------------------------------------------------------
   11. Prev/Next Navigation
   ---------------------------------------------------------- */
.article__nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--gray-200);
}

.article__nav-link {
  display: block;
  padding: 16px 20px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.article__nav-link:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.article__nav-link--prev {
  grid-column: 1;
}

.article__nav-link--next {
  grid-column: 2;
  text-align: right;
}

.article__nav-label {
  font-size: var(--text-xs);
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  display: block;
}

.article__nav-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
}

/* ----------------------------------------------------------
   12. Code Blocks
   ---------------------------------------------------------- */
.code-block {
  background: var(--gray-900);
  color: #e5e7eb;
  border-radius: var(--radius-md);
  margin: 24px 0;
  overflow: hidden;
}

.code-block__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: var(--text-xs);
  color: var(--gray-400);
}

.code-block__body {
  padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.code-block__body code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
  border-radius: 0;
}

/* Syntax highlights */
.code-block .token-key { color: #93c5fd; }
.code-block .token-string { color: #86efac; }
.code-block .token-number { color: #fde68a; }
.code-block .token-comment { color: #6b7280; font-style: italic; }
.code-block .token-method { color: #c4b5fd; }
.code-block .token-url { color: #fca5a5; }

/* ----------------------------------------------------------
   13. Permission Matrix Table
   ---------------------------------------------------------- */
.permission-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: var(--text-sm);
}

.permission-table th {
  background: var(--gray-100);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--gray-200);
  color: var(--gray-700);
}

.permission-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

.permission-table tr:hover {
  background: var(--gray-50);
}

.permission-table .check {
  color: var(--success);
  font-weight: 600;
}

.permission-table .cross {
  color: var(--gray-300);
}

/* ----------------------------------------------------------
   14. Landing Page Specifics
   ---------------------------------------------------------- */
.landing-hero {
  text-align: center;
  padding: 48px 0 40px;
}

.landing-hero h1 {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 16px;
  line-height: 1.2;
}

.landing-hero p {
  font-size: var(--text-lg);
  color: var(--gray-600);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.7;
}

.landing-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 40px 0;
}

.landing-card {
  display: block;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.landing-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.landing-card__icon {
  width: 36px;
  height: 36px;
  background: var(--accent-bg);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 12px;
}

.landing-card__title {
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
}

.landing-card__desc {
  font-size: var(--text-sm);
  color: var(--gray-600);
  line-height: 1.5;
}

/* ----------------------------------------------------------
   15. Responsive Design
   ---------------------------------------------------------- */
@media (max-width: 1199px) {
  .content {
    padding-right: 32px;
  }
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    box-shadow: none;
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar__hamburger {
    display: flex;
  }

  .sidebar__overlay.is-visible {
    display: block;
  }

  .content {
    grid-column: 1;
    padding: 60px 20px 60px;
  }

  .article h1 {
    font-size: var(--text-2xl);
  }

  .article h2 {
    font-size: var(--text-xl);
  }

  .article__nav {
    grid-template-columns: 1fr;
  }

  .article__nav-link--next {
    grid-column: 1;
    text-align: left;
  }

  .landing-cards {
    grid-template-columns: 1fr;
  }

  .landing-hero h1 {
    font-size: var(--text-2xl);
  }
}
