/* ==========================================
   APTL Documentation - Modern UI Styles
   ========================================== */

:root {
  /* Colors */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-secondary: #8b5cf6;
  --color-accent: #06b6d4;

  --color-bg: #ffffff;
  --color-bg-secondary: #0d2135;
  --color-bg-tertiary: #4b3f72;
  --color-surface: #ffffff;

  --color-text-primary: #0f172a;
  --color-text-secondary: #475569;
  --color-text-tertiary: #94a3b8;

  --color-border: #e2e8f0;
  --color-border-hover: #cbd5e1;

  --color-code-bg: #1e293b;
  --color-code-text: #e2e8f0;

  /* Spacing */
  --navbar-height: 64px;
  --content-max-width: 1000px;
  --main-content-width: calc(100% - 280px);
  --toc-width: 280px;
  --sidebar-gap: 2rem;

  /* Typography */
  --font-sans:
    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode variables */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0c0e1d;
    --color-bg-secondary: #323545;
    --color-bg-tertiary: #363457;
    --color-surface: #0c0e1d;

    --color-text-primary: #f1f2f9;
    --color-text-secondary: #cbd5e1;
    --color-text-tertiary: #64748b;

    --color-border: #334155;
    --color-border-hover: #475569;

    --color-code-bg: #0c0e1d;
  }
}

/* ==========================================
   Base Styles
   ========================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--navbar-height) + 2rem);
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================
   Navbar
   ========================================== */

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  background-color: var(--color-surface);
  /* border-bottom: 1px solid var(--color-border); */
  box-shadow: var(--shadow-sm);
  z-index: 1000;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  /* background-color: rgba(255, 255, 255, 0.9); */
}

.navbar-container {
  max-width: var(--content-max-width);
  height: 100%;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  display: flex;
  align-items: center;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--color-text-primary);
  font-weight: 700;
  font-size: 1.25rem;
  transition: opacity var(--transition-fast);
}

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

.brand-icon {
  font-size: 1.75rem;
  line-height: 1;
}

.brand-logo {
  height: 70px;
  width: auto;
}

.brand-name {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.navbar-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-dropdown {
  position: relative;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.dropdown-icon {
  transition: transform var(--transition-fast);
}

.nav-dropdown:hover .dropdown-icon,
.nav-dropdown:focus-within .dropdown-icon {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  min-width: 200px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition-base);
  z-index: 100;
  padding: 0.5rem;
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown:focus-within .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: block;
  padding: 0.625rem 0.875rem;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  border-radius: 0.375rem;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.dropdown-item:hover {
  color: white;
  background-color: var(--color-bg-tertiary);
  text-decoration: none;
}

.dropdown-item.active {
  color: white;
  background-color: var(--color-bg-tertiary);
  font-weight: 600;
}

.nav-link {
  padding: 0.5rem 1rem;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  border-radius: 0.5rem;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link:hover {
  color: white;
  background-color: var(--color-bg-tertiary);
}

.nav-link.active {
  color: white;
  font-weight: 600;
}

.github-link svg {
  width: 18px;
  height: 18px;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}

.hamburger {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--color-text-primary);
  position: relative;
  transition: background-color var(--transition-fast);
}

.hamburger::before,
.hamburger::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 2px;
  background-color: var(--color-text-primary);
  transition: transform var(--transition-base);
}

.hamburger::before {
  transform: translateY(-8px);
}

.hamburger::after {
  transform: translateY(8px);
}

/* ==========================================
   Layout
   ========================================== */

.page-container {
  display: grid;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding-top: var(--navbar-height);
  min-height: 100vh;
  gap: var(--sidebar-gap);
}

.page-container:has(.toc-sidebar) {
  grid-template-columns: var(--main-content-width) var(--toc-width);
}

.main-content {
  flex: 1;
  padding: 3rem 2rem;
}

/* ==========================================
   Table of Contents (TOC)
   ========================================== */

.toc-sidebar {
  position: sticky;
  top: var(--navbar-height);
  width: var(--toc-width);
  height: calc(100vh - var(--navbar-height));
  padding: 3rem 2rem 3rem 0;
  overflow-y: auto;
  flex-shrink: 0;
}

.toc-nav {
  position: relative;
}

.toc-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0;
}

#toc-content {
  font-size: 0.875rem;
}

#toc-content ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#toc-content > ul > li {
  margin-bottom: 0.5rem;
}

#toc-content li {
  margin-left: 0;
}

#toc-content a {
  display: block;
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: 0.25rem 0.75rem;
  border-left: 2px solid transparent;
  transition: all var(--transition-fast);
  line-height: 1.4;
}

#toc-content a:hover {
  color: var(--color-primary);
  border-left-color: var(--color-border-hover);
}

#toc-content a.active {
  color: var(--color-primary);
  border-left-color: var(--color-primary);
  font-weight: 500;
}

#toc-content ul ul {
  margin-left: 1rem;
  margin-top: 0.25rem;
}

/* ==========================================
   Typography
   ========================================== */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text-primary);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 2.5rem;
  margin-top: 0;
  margin-bottom: 1.5rem;
}

h2 {
  font-size: 2rem;
  padding-bottom: 0.5rem;
}

h3 {
  font-size: 1.5rem;
}

h4 {
  font-size: 1.25rem;
}

h5 {
  font-size: 1.125rem;
}

h6 {
  font-size: 1rem;
  font-weight: 600;
}

p {
  margin-bottom: 0.75rem;
  color: var(--color-text-secondary);
}

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

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

strong {
  font-weight: 600;
  color: var(--color-text-primary);
}

em {
  font-style: italic;
}

/* ==========================================
   Code Blocks
   ========================================== */

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.2em 0.4em;
  background-color: var(--color-bg-tertiary);
  border-radius: 0.25rem;
  color: var(--color-text-primary);
}

pre {
  background-color: var(--color-code-bg);
  border-radius: 0.5rem;
  padding: 0;
  overflow-x: auto;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-md);
}

pre code {
  background-color: transparent;
  padding: 0;
  color: var(--color-code-text);
  font-size: 0.875rem;
  line-height: 1.7;
}

code[class*='language-'],
pre[class*='language-'] {
  text-shadow: none;
  margin: 0.5rem 0 1.5rem;
}

.token.operator {
  background: none;
}

/* ==========================================
   Lists
   ========================================== */

ul,
ol {
  margin-bottom: 1.25rem;
  padding-left: 1.75rem;
}

li {
  margin-bottom: 0.5rem;
  color: var(--color-text-secondary);
}

li > ul,
li > ol {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* ==========================================
   Blockquotes
   ========================================== */

blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid var(--color-primary);
  background-color: var(--color-bg-secondary);
  border-radius: 0.5rem;
}

blockquote p {
  margin-bottom: 0.5rem;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* ==========================================
   Tables
   ========================================== */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  overflow: hidden;
  border-radius: 0.5rem;
  box-shadow: var(--shadow-sm);
}

thead {
  background-color: var(--color-bg-secondary);
}

th,
td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-weight: 600;
  color: var(--color-text-primary);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  color: var(--color-text-secondary);
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background-color: var(--color-bg-secondary);
}

/* ==========================================
   Responsive Design
   ========================================== */

@media (max-width: 1200px) {
  .toc-sidebar {
    display: none;
  }

  .main-content {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .navbar-container {
    padding: 0 1rem;
  }

  .mobile-menu-toggle {
    display: block;
  }

  .navbar-menu {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    background-color: var(--color-surface);
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-base);
    max-height: calc(100vh - var(--navbar-height));
    overflow-y: auto;
  }

  .navbar-menu.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
  }

  .nav-dropdown {
    width: 100%;
  }

  .dropdown-toggle {
    width: 100%;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
  }

  .dropdown-menu {
    position: static;
    transform: none;
    opacity: 1;
    visibility: visible;
    box-shadow: none;
    border: none;
    padding: 0 0 0 1rem;
    margin-top: 0.25rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-base);
  }

  .nav-dropdown.active .dropdown-menu {
    max-height: 500px;
  }

  .nav-dropdown:hover .dropdown-menu,
  .nav-dropdown:focus-within .dropdown-menu {
    transform: none;
  }

  .nav-dropdown.active .dropdown-icon {
    transform: rotate(180deg);
  }

  .nav-link {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
  }

  .main-content {
    padding: 2rem 1rem;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h3 {
    font-size: 1.25rem;
  }
}

/* ==========================================
   Utilities
   ========================================== */

.text-center {
  text-align: center;
}

.mt-0 {
  margin-top: 0;
}
.mb-0 {
  margin-bottom: 0;
}

/* ==========================================
   Scrollbar Styling
   ========================================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background-color: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background-color: var(--color-border-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-text-tertiary);
}

/* ==========================================
   Print Styles
   ========================================== */

@media print {
  .navbar,
  .toc-sidebar {
    display: none;
  }

  .page-container {
    padding-top: 0;
  }

  .main-content {
    max-width: 100%;
  }
}
