@import url('highlight-theme.css');

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #fff;
  transition: background-color 0.3s, color 0.3s;
}

body.dark-mode {
  background-color: #1a1a1a;
  color: #e0e0e0;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Ensure container is responsive on mobile */
@media (max-width: 768px) {
  .container {
    padding: 0 15px;
    max-width: 100%;
  }
}

/* Header styles */
.site-header {
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.3s, box-shadow 0.3s;
}

body.dark-mode .site-header {
  background-color: #2d2d2d;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
}

.nav-brand a {
  font-size: 1.5rem;
  font-weight: bold;
  text-decoration: none;
  color: #2c3e50;
}

body.dark-mode .nav-brand a {
  color: #ecf0f1;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.dropdown { position: relative; }
.dropdown::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 10px; }

.dropdown-toggle { background: none; border: 1px solid #ddd; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; font-size: 1rem; color: #333; display: flex; align-items: center; gap: 0.5rem; min-width: 250px; justify-content: space-between; }

body.dark-mode .dropdown-toggle {
  border-color: #555;
  color: #e0e0e0;
  background-color: #3d3d3d;
}

.dropdown-toggle::after {
  content: "▼";
  font-size: 0.7rem;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  .dropdown-menu { position: absolute; top: 100%; right: 0; background: white; min-width: 250px; box-shadow: 0 10px 30px rgba(0,0,0,0.12); border-radius: 12px; padding: 0.5rem 0; display: none; z-index: 1000; border: 1px solid #eef0f4; transition: opacity .15s ease, transform .15s ease; opacity: 0; transform: translateY(6px); pointer-events: auto; }
}

body.dark-mode .dropdown-menu { background-color: #3d3d3d; box-shadow: 0 10px 30px rgba(0,0,0,0.35); min-width: 250px; }

.dropdown:hover .dropdown-menu, .dropdown:has(.dropdown-menu:hover) .dropdown-menu { display: block; opacity: 1; transform: translateY(0); }

.dropdown-menu li {
  list-style: none;
}

.dropdown-menu a {
  display: block;
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: #333;
  transition: background-color 0.2s;
}

body.dark-mode .dropdown-menu a {
  color: #e0e0e0;
}

.dropdown-menu a:hover {
  background-color: #f5f5f5;
}

body.dark-mode .dropdown-menu a:hover {
  background-color: #4d4d4d;
}

.theme-toggle, .search-toggle { background: linear-gradient(180deg, #ffffff, #f8f9fb); border: 1px solid #e6e8ec; cursor: pointer; font-size: 1.1rem; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; transition: transform 0.15s ease, box-shadow 0.2s; box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
.theme-toggle:hover, .search-toggle:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,0.12); }
body.dark-mode .theme-toggle, body.dark-mode .search-toggle { background: linear-gradient(180deg, #3b3b3b, #2e2e2e); border-color: #484848; }

/* Accessible dropdown */
.navbar { position: relative; }
.dropdown { position: relative; }
.dropdown-toggle { inline-size: 260px; min-width: 260px; }
.dropdown[aria-expanded="true"] .dropdown-menu { display: block; opacity: 1; transform: translateY(0); }
.dropdown-menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 260px; background: #fff; border: 1px solid #eef0f4; border-radius: 12px; padding: 8px 0; box-shadow: 0 10px 30px rgba(0,0,0,0.12); display: none; opacity: 0; transform: translateY(6px); transition: opacity .15s ease, transform .15s ease; }
body.dark-mode .dropdown-menu { background: #2f2f2f; border-color: #434343; box-shadow: 0 10px 30px rgba(0,0,0,0.35); }
.dropdown:focus-within .dropdown-menu { display: block; opacity: 1; transform: translateY(0); }
@media (hover: hover) {
  .dropdown:hover .dropdown-menu { display: block; opacity: 1; transform: translateY(0); }
}
.dropdown-menu a { padding: 10px 14px; border-radius: 8px; margin: 0 6px; }
.dropdown-menu a:focus-visible { outline: 2px solid #4aa3df; outline-offset: 2px; }

.main-content {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  padding: 2rem 0;
}

/* Ensure main content doesn't overflow on mobile */
@media (max-width: 768px) {
  .main-content {
    padding: 1rem 0;
    gap: 1rem;
    overflow-x: hidden;
  }
}

.content-wrapper {
  flex: 1;
  min-width: 0;
}

/* Table of contents */
.toc-container {
  width: 250px;
  position: sticky;
  top: 80px;
  align-self: flex-start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.toc-title {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
}

body.dark-mode .toc-title {
  border-bottom-color: #444;
}

.toc-list {
  list-style: none;
  padding-left: 0;
}

.toc-list ul {
  list-style: none;
  padding-left: 1rem;
}

.toc-list li {
  margin-bottom: 0.5rem;
}

.toc-list a {
  text-decoration: none;
  color: #555;
  font-size: 0.9rem;
  transition: color 0.2s;
  display: block;
  padding: 0.2rem 0;
}

body.dark-mode .toc-list a {
  color: #e0e0e0;
}

.toc-list a:hover {
  color: #2c3e50;
}

body.dark-mode .toc-list a:hover {
  color: #ecf0f1;
}

.toc-list a.active {
  color: #3498db;
  font-weight: bold;
}

body.dark-mode .toc-list a.active {
  color: #5dade2;
}

/* Content styles */
.content {
  max-width: 800px;
}

.content h1, .content h2, .content h3 {
  margin: 1.5rem 0 1rem;
  line-height: 1.3;
}

.content h1 {
  font-size: 2rem;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.5rem;
}

body.dark-mode .content h1 {
  border-bottom-color: #444;
}

.content h2 {
  font-size: 1.5rem;
  margin-top: 2rem;
}

.content h3 {
  font-size: 1.2rem;
}

.content p {
  margin-bottom: 1rem;
}

.content ul, .content ol {
  margin: 1rem 0;
  padding-left: 2rem;
}

.content li {
  margin-bottom: 0.5rem;
}

.content a {
  color: #3498db;
  text-decoration: none;
}

.content a:hover {
  text-decoration: underline;
}

body.dark-mode .content a {
  color: #5dade2;
}

/* Code blocks */
.content pre {
  background-color: #f8f8f8;
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid #eee;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  line-height: 1.5;
}

/* Ensure code blocks don't cause horizontal overflow on mobile */
@media (max-width: 768px) {
  .content pre {
    padding: 0.75rem;
    font-size: 0.85rem;
  }
}

body.dark-mode .content pre {
  background-color: #2d2d2d;
  border-color: #444;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.content code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.9rem;
  background-color: #f8f8f8;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

body.dark-mode .content code {
  background-color: #3d3d3d;
}

.content pre code {
  background: none;
  padding: 0;
}

/* Tables */
.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.content th, .content td {
  padding: 0.75rem;
  text-align: left;
  border: 1px solid #ddd;
}

.content th {
  background-color: #f8f9fa;
  font-weight: bold;
}

body.dark-mode .content th {
  background-color: #3d3d3d;
}

body.dark-mode .content th, 
body.dark-mode .content td {
  border-color: #444;
}

/* Callouts */
.callout {
  padding: 1rem;
  border-left: 4px solid #3498db;
  margin: 1.5rem 0;
  background-color: #f8f9fa;
  border-radius: 0 4px 4px 0;
}

body.dark-mode .callout {
  background-color: #2d2d2d;
}

.callout-title {
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.callout.note {
  border-left-color: #3498db;
}

.callout.warning {
  border-left-color: #f39c12;
}

.callout.error {
  border-left-color: #e74c3c;
}

.callout.success {
  border-left-color: #2ecc71;
}

/* Navigation */
.page-navigation {
  display: flex;
  justify-content: space-between;
  margin: 2rem 0;
  padding: 1rem 0;
  border-top: 1px solid #eee;
  border-bottom: 1px solid #eee;
}

body.dark-mode .page-navigation {
  border-top-color: #444;
  border-bottom-color: #444;
}

.nav-button {
  padding: 0.5rem 1rem;
  text-decoration: none;
  border: 1px solid #ddd;
  border-radius: 4px;
  color: #333;
  background-color: #fff;
  transition: all 0.2s;
}

body.dark-mode .nav-button {
  border-color: #555;
  color: #e0e0e0;
  background-color: #2d2d2d;
}

.nav-button:hover {
  background-color: #f5f5f5;
  border-color: #ccc;
}

body.dark-mode .nav-button:hover {
  background-color: #3d3d3d;
  border-color: #777;
}

.nav-button.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

.breadcrumb {
  margin: 1rem 0;
  font-size: 0.9rem;
  color: #777;
}

body.dark-mode .breadcrumb {
  color: #e0e0e0;
}

.breadcrumb a {
  color: #3498db;
  text-decoration: none;
}

body.dark-mode .breadcrumb a {
  color: #5dade2;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb span {
  margin: 0 0.5rem;
}

/* Search */
.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 100px;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.search-overlay.active {
  opacity: 1;
  visibility: visible;
}

.search-container {
  background: white;
  width: 90%;
  max-width: 600px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  overflow: hidden;
}

body.dark-mode .search-container {
  background-color: #2d2d2d;
}

.search-input-container {
  padding: 1rem;
  border-bottom: 1px solid #eee;
}

body.dark-mode .search-input-container {
  border-bottom-color: #444;
}

.search-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

body.dark-mode .search-input {
  background-color: #3d3d3d;
  border-color: #555;
  color: #e0e0e0;
}

.search-results {
  max-height: 400px;
  overflow-y: auto;
}

.search-result {
  padding: 1rem;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background-color 0.2s;
}

body.dark-mode .search-result {
  border-bottom-color: #444;
}

.search-result:hover {
  background-color: #f5f5f5;
}

body.dark-mode .search-result:hover {
  background-color: #3d3d3d;
}

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

.search-result-title {
  font-weight: bold;
  margin-bottom: 0.25rem;
}

.search-result-heading {
  font-size: 0.9rem;
  color: #777;
  margin-bottom: 0.25rem;
}

body.dark-mode .search-result-heading {
  color: #e0e0e0;
}

.search-result-preview {
  font-size: 0.9rem;
  color: #555;
}

body.dark-mode .search-result-preview {
  color: #e0e0e0;
}

.stage-progress { position: absolute; top: 0; left: 0; width: 100%; height: 6px; background: linear-gradient(90deg, #e3f2fd, #f3e5f5); }
.stage-progress span { display: block; height: 100%; width: var(--p, 0%); background: linear-gradient(90deg, #3b82f6, #8b5cf6, #10b981); transition: width 0.6s ease; position: relative; }
.stage-progress span::after { content: attr(data-percent); position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 700; color: #ffffff; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.index-header {
  text-align: center;
  padding: 3rem 0;
  margin-bottom: 2rem;
  background: linear-gradient(180deg, #f8f9fa, #eef2f6);
  border-radius: 16px;
}

body.dark-mode .index-header {
  background: linear-gradient(180deg, #2e2e2e, #252525);
}

.index-title {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  color: #2c3e50;
}

body.dark-mode .index-title {
  color: #ecf0f1;
}

.index-subtitle {
  font-size: 1.2rem;
  color: #7f8c8d;
  max-width: 600px;
  margin: 0 auto;
}

body.dark-mode .index-subtitle {
  color: #bdc3c7;
}

.stages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

/* Download section */
.download-section {
  margin-top: 3rem;
  padding: 2rem;
  background: linear-gradient(180deg, #f8f9fa, #eef2f6);
  border-radius: 16px;
  text-align: center;
}

body.dark-mode .download-section {
  background: linear-gradient(180deg, #2e2e2e, #252525);
}

.download-section h2 {
  margin-bottom: 1.5rem;
  color: #2c3e50;
  font-size: 1.5rem;
}

body.dark-mode .download-section h2 {
  color: #ecf0f1;
}

.download-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  background: linear-gradient(180deg, #4aa3df, #2f80c8);
  color: white;
  text-decoration: none;
  border-radius: 12px;
  font-weight: bold;
  transition: transform 0.15s ease, box-shadow 0.2s;
  box-shadow: 0 8px 20px rgba(52,152,219,0.25);
}

body.dark-mode .download-button {
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.download-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(52,152,219,0.35);
}

body.dark-mode .download-button:hover {
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.download-icon {
  font-size: 1.2rem;
}

.stage-card { border: 1px solid #eef0f4; border-radius: 16px; padding: 1.25rem 1.25rem 1.5rem; transition: transform 0.2s, box-shadow 0.2s, background 0.3s ease, background-color 0.3s ease; text-decoration: none; color: inherit; display: block; background: linear-gradient(180deg, #ffffff, #fbfcff); position: relative; overflow: hidden; }
.stage-card:hover { transform: translateY(-6px); box-shadow: 0 16px 32px rgba(0,0,0,0.12); background: linear-gradient(180deg, #e9f3ff, #f7fbff); }
body.dark-mode .stage-card { border-color: #3a3a3a; background: linear-gradient(180deg, #2f2f2f, #2a2a2a); }
body.dark-mode .stage-card:hover { box-shadow: 0 16px 32px rgba(0,0,0,0.35); background: linear-gradient(180deg, #243043, #1f2937); }

.stage-number {
  font-size: 0.95rem;
  font-weight: 700;
  color: #5b7c99;
  margin: 0.75rem 0 0.35rem;
}

.stage-title {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  color: #1f2d3d;
}

body.dark-mode .stage-title {
  color: #ecf0f1;
}

.stage-description {
  color: #6b7c8f;
  margin-bottom: 1rem;
}

body.dark-mode .stage-description {
  color: #bdc3c7;
}

.cta-button { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.7rem 1.25rem; background: linear-gradient(180deg, #4aa3df, #2f80c8); color: #fff; text-decoration: none; border-radius: 12px; font-weight: 700; letter-spacing: .2px; transition: transform .12s ease, box-shadow .2s, background .2s; box-shadow: 0 6px 16px rgba(47,128,200,.28); border: 1px solid rgba(255,255,255,.12); outline: none; position: relative; }
.cta-button::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: radial-gradient(120% 120% at 50% -20%, rgba(255,255,255,.25), transparent 60%); pointer-events: none; }
.cta-button:hover { transform: translateY(-1px); background: linear-gradient(180deg, #3a93cf, #256fb8); box-shadow: 0 10px 24px rgba(47,128,200,.35); }
.cta-button:active { transform: translateY(0); filter: saturate(1.1); }
.cta-button:focus-visible { box-shadow: 0 0 0 3px rgba(47,128,200,.35), 0 6px 16px rgba(47,128,200,.28); }
.cta-button .icon { display: inline-block; width: 14px; height: 14px; background: currentColor; mask: url('#'); mask-size: cover; }


.site-footer {
  background-color: #f8f9fa;
  padding: 2rem 0;
  margin-top: 3rem;
  border-top: 1px solid #eee;
}

body.dark-mode .site-footer {
  background-color: #2d2d2d;
  border-top-color: #444;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-links {
  display: flex;
  gap: 1rem;
}

.footer-links a {
  color: #7f8c8d;
  text-decoration: none;
}

body.dark-mode .footer-links a {
  color: #bdc3c7;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* Responsive styles */
@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }
  
  .toc-container {
    width: 100%;
    position: relative;
    top: 0;
    max-height: none;
    margin-bottom: 2rem;
  }
  
  .toc-toggle {
    display: block;
    background: none;
    border: 1px solid #ddd;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    color: #333;
    margin-bottom: 1rem;
    width: 100%;
    text-align: left;
  }
  
  body.dark-mode .toc-toggle {
    border-color: #555;
    color: #e0e0e0;
    background-color: #3d3d3d;
  }
  
  .toc-content {
    display: none;
  }
  
  .toc-content.active {
    display: block;
  }
  
  .stages-grid {
    grid-template-columns: 1fr;
  }
  
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
  
  .nav-menu {
    gap: 0.5rem;
  }
  
  .dropdown-menu {
    right: auto;
    left: 0;
    min-width: 200px;
  }
  
  /* Fixes for subpages */
  .container {
    max-width: 100% !important;
    padding: 15px !important;
  }
  
  /* Fix for code blocks that overflow on mobile */
  .code-container {
    margin: 15px -15px !important;
    border-radius: 0 !important;
  }
  
  .code-content.expanded {
    max-height: 1500px !important;
  }
  
  pre {
    padding: 15px !important;
    font-size: 0.8rem !important;
  }
  
  .stage-title {
    padding-left: 15px !important;
  }
  
  .code-header {
    font-size: 0.8rem !important;
  }
  
  .expand-icon {
    font-size: 1rem !important;
  }
  
  /* Fix for main title on mobile */
  .main-title {
    font-size: 2rem !important;
  }
  
  /* Fix for section titles on mobile */
  .section-title {
    font-size: 1.5rem !important;
  }
  
  /* Ensure proper width for all elements */
  * {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  
  /* Fix for dropdown menu on mobile */
  .dropdown-toggle {
    min-width: 150px !important;
    inline-size: 150px !important;
  }
}