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

:root {
  --primary-color: #c41e3a;
  --primary-light: #e63946;
  --primary-lighter: #f87171;
  --secondary-color: #dc2626;
  --accent-color: #c41e3a;
  --text-color: #1e293b;
  --text-light: #64748b;
  --text-lighter: #94a3b8;
  --border-color: #e5e7eb;
  --light-bg: #f8fafc;
  --bg-sidebar: #fafafa;
  --bg-hover: #f5f5f5;
  --white: #ffffff;
  --code-bg: #1e293b;
  --code-text: #e2e8f0;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--white);
  overflow-x: hidden;
}

.docs-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header */
.docs-header {
  background: white;
  color: var(--text-color);
  padding: 0 32px;
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border-color);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo i {
  font-size: 28px;
}

.logo h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--primary-color);
}

.header-right {
  display: flex;
  gap: 16px;
  align-items: center;
}

.mobile-sidebar-toggle {
  display: none;
}

.version-select {
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  background: var(--white);
  color: var(--text-color);
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.version-select option {
  background: var(--white);
  color: var(--text-color);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box i {
  position: absolute;
  left: 12px;
  color: var(--text-light);
}

.search-box input {
  padding: 8px 16px 8px 36px;
  border: 1px solid var(--border-color);
  background: var(--white);
  color: var(--text-color);
  border-radius: 6px;
  font-size: 14px;
  width: 250px;
  transition: all 0.3s ease;
}

.search-box input::placeholder {
  color: var(--text-light);
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.1);
  width: 300px;
}

/* Horizontal Navigation */
.horizontal-nav {
  background: var(--white);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  gap: 0;
  overflow-x: auto;
  position: sticky;
  top: 60px;
  z-index: 90;
}

.horizontal-nav::-webkit-scrollbar {
  height: 4px;
}

.horizontal-nav::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.nav-item {
  padding: 14px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
  color: var(--text-light);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 14px;
}

.nav-item:hover {
  color: var(--primary-color);
  background-color: rgba(196, 30, 58, 0.05);
}

.nav-item.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  background-color: rgba(196, 30, 58, 0.05);
}

/* Main Layout */
.main-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  flex: 1;
}

/* Sidebar */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  position: sticky;
  top: 118px;
  height: calc(100vh - 118px);
}

.sidebar-content {
  padding: 24px 16px;
}

.sidebar-section {
  margin-bottom: 12px;
}

/* Expandable section header */
.sidebar-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-color);
  user-select: none;
}

.sidebar-section-header:hover {
  background-color: var(--white);
  color: var(--primary-color);
}

.sidebar-section-header.active {
  background-color: rgba(196, 30, 58, 0.1);
  color: var(--primary-color);
}

.sidebar-section-header .section-arrow {
  font-size: 10px;
  transition: transform 0.3s ease;
  color: var(--text-color);
  opacity: 0.6;
}

.sidebar-section-header.expanded .section-arrow {
  transform: rotate(90deg);
}

.sidebar-section-header .section-label {
  flex: 1;
}

.sidebar-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-color);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 8px;
  padding: 0 12px;
}

.sidebar-menu {
  list-style: none;
  overflow: hidden;
  transition: max-height 0.3s ease;
  max-height: 0;
}

.sidebar-menu.expanded {
  max-height: 2000px;
}

.sidebar-menu li {
  margin-bottom: 4px;
}

.sidebar-menu a {
  display: block;
  padding: 10px 12px 10px 32px;
  color: var(--text-color);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.2s ease;
  font-size: 14px;
}

.sidebar-menu a:hover {
  background-color: var(--white);
  color: var(--primary-color);
}

.sidebar-menu a.active {
  background-color: rgba(196, 30, 58, 0.1);
  color: var(--primary-color);
  font-weight: 500;
  border-left: 3px solid var(--primary-color);
  padding-left: 29px;
}

.sidebar-menu .menu-item-self a {
  padding-left: 32px;
  font-weight: 500;
}

.sidebar-menu .submenu {
  padding-left: 12px;
}

.sidebar-menu .submenu a {
  padding-left: 44px;
  font-size: 13.5px;
}

/* Content Area */
.content-area {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  padding: 32px;
  max-width: 100%;
  overflow-x: hidden;
}

/* Breadcrumb */
.breadcrumb {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 16px;
}

.breadcrumb a {
  color: var(--text-light);
  text-decoration: none;
}

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

.breadcrumb i {
  font-size: 10px;
}

/* Content */
.content {
  background: var(--white);
  max-width: 100%;
  width: 100%;
  color: var(--text-color);
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

.content h1 {
  font-size: 36px;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 24px;
  line-height: 1.2;
}

.content h2 {
  font-size: 28px;
  font-weight: 600;
  color: var(--primary-color);
  margin-top: 48px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-color);
}

.content h3 {
  font-size: 22px;
  font-weight: 600;
  margin-top: 36px;
  margin-bottom: 16px;
}

.content h4 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 12px;
}

.content p {
  margin-bottom: 8px;
  line-height: 1.7;
  color: var(--text-color);
}

.content p:empty {
  display: none;
  margin: 0;
}

.content ul,
.content ol {
  margin-bottom: 20px;
  padding-left: 28px;
}

.content li {
  margin-bottom: 8px;
  line-height: 1.6;
  color: var(--text-color);
}

.content code {
  background-color: var(--code-bg);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  color: #e83e8c;
}

.content pre {
  background-color: var(--code-bg);
  color: var(--code-text);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 20px;
  border-left: 4px solid var(--primary-color);
}

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

.content blockquote {
  border-left: 4px solid var(--accent-color);
  padding-left: 20px;
  margin: 24px 0;
  color: var(--text-light);
  font-style: italic;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 14px;
}

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

.content table th {
  background-color: var(--light-bg);
  font-weight: 600;
}

.content table tr:hover {
  background-color: var(--light-bg);
}

.content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 24px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.content a {
  color: var(--primary-color);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-bottom 0.2s ease;
}

.content a:hover {
  border-bottom-color: var(--primary-color);
}

/* Table of Contents */
.toc {
  display: none;
  background: var(--bg-sidebar);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  position: sticky;
  top: 140px;
  height: fit-content;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.toc h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toc ul {
  list-style: none;
}

.toc li {
  margin-bottom: 8px;
}

.toc a {
  color: var(--text-color);
  text-decoration: none;
  font-size: 13px;
  display: block;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.toc a:hover {
  background-color: var(--white);
  color: var(--primary-color);
}

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

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--white);
  border-radius: 12px;
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
}

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

.modal-header h2 {
  font-size: 20px;
  margin: 0;
}

.close {
  font-size: 28px;
  font-weight: bold;
  color: var(--text-light);
  cursor: pointer;
}

.close:hover {
  color: var(--text-color);
}

.modal-body {
  padding: 24px;
}

.search-result-item {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

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

.search-result-item h4 {
  color: var(--primary-color);
  margin-bottom: 8px;
}

.search-result-item p {
  color: var(--text-light);
  font-size: 14px;
}

/* Responsive */
@media (max-width: 1024px) {
  .content-area {
    grid-template-columns: 1fr;
  }

  .toc {
    display: none;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    max-height: 0;
    overflow: hidden;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    transition: max-height 0.3s ease;
  }

  .sidebar.mobile-open {
    max-height: 60vh;
    overflow-y: auto;
  }

  .docs-header {
    flex-direction: row;
    flex-wrap: wrap;
    height: auto;
    min-height: 48px;
    padding: 8px 12px;
    gap: 8px;
  }

  .header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-shrink: 1;
    overflow: hidden;
  }

  .mobile-sidebar-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    padding: 0;
    cursor: pointer;
    color: var(--text-color);
    font-size: 16px;
    flex-shrink: 0;
  }

  .logo h1 {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .logo i {
    font-size: 18px;
    flex-shrink: 0;
  }

  .logo {
    gap: 6px;
    min-width: 0;
    overflow: hidden;
  }

  .header-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
  }

  .version-select {
    padding: 6px 8px;
    font-size: 12px;
    max-width: 140px;
  }

  .print-btn {
    padding: 5px 8px;
    font-size: 13px;
    flex-shrink: 0;
  }

  .print-btn span {
    display: none;
  }

  /* Search box - full width on its own row */
  .search-box {
    position: relative;
    order: 10;
    flex-basis: 100%;
    width: 100%;
  }

  .search-box input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    font-size: 13px;
    box-sizing: border-box;
  }

  .search-box input:focus {
    width: 100%;
  }

  /* Horizontal Nav */
  .horizontal-nav {
    padding: 0 8px;
    top: auto;
    position: relative;
    gap: 0;
    -webkit-overflow-scrolling: touch;
  }

  .nav-item {
    padding: 10px 14px;
    font-size: 13px;
    gap: 6px;
  }

  .nav-item i {
    font-size: 14px;
  }

  /* Content */
  .content-area {
    padding: 16px 12px;
    gap: 16px;
    overflow-x: hidden;
  }

  .content {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    min-width: 0;
  }

  .content p,
  .content li,
  .content span,
  .content div {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
  }

  .content h1 {
    font-size: 24px;
    margin-bottom: 16px;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .content h2 {
    font-size: 20px;
    margin-top: 32px;
    margin-bottom: 14px;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .content h3 {
    font-size: 18px;
    margin-top: 24px;
  }

  .content h4 {
    font-size: 16px;
  }

  .content pre {
    padding: 12px;
    font-size: 12px;
    border-radius: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    white-space: pre-wrap;
    word-break: break-all;
  }

  .content code {
    font-size: 12px;
    word-break: break-all;
  }

  .content img {
    max-width: 100%;
    height: auto;
  }

  .content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .content table th,
  .content table td {
    padding: 8px 10px;
    font-size: 13px;
    white-space: normal;
    word-break: break-word;
  }

  .content blockquote {
    padding-left: 14px;
    margin: 16px 0;
  }

  .content ul,
  .content ol {
    padding-left: 20px;
  }

  .breadcrumb {
    font-size: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
  }

  /* Modal */
  .modal-content {
    width: 95%;
    max-height: 85vh;
    border-radius: 8px;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-header h2 {
    font-size: 16px;
  }

  .modal-body {
    padding: 16px;
  }

  .sidebar-content {
    padding: 12px 8px;
  }

  .sidebar-section-header {
    padding: 8px 10px;
    font-size: 12px;
  }

  .sidebar-menu a {
    padding: 8px 10px 8px 28px;
    font-size: 13px;
  }

  .sidebar-menu .submenu a {
    padding-left: 36px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .docs-header {
    padding: 6px 8px;
    gap: 4px;
  }

  .logo h1 {
    font-size: 13px;
    max-width: 100px;
  }

  .logo i {
    font-size: 16px;
  }

  .mobile-sidebar-toggle {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .header-right {
    gap: 4px;
  }

  .version-select {
    max-width: 120px;
    font-size: 11px;
    padding: 5px 6px;
  }

  .print-btn {
    padding: 4px 6px;
    font-size: 12px;
  }

  .search-box input {
    width: 100%;
    font-size: 12px;
    padding: 6px 10px 6px 28px;
  }

  .search-box i {
    left: 8px;
    font-size: 12px;
  }

  .nav-item {
    padding: 8px 10px;
    font-size: 12px;
  }

  .content-area {
    padding: 12px 8px;
  }

  .content h1 {
    font-size: 20px;
  }

  .content h2 {
    font-size: 18px;
  }

  .content h3 {
    font-size: 16px;
  }

  .content p,
  .content li {
    font-size: 14px;
    line-height: 1.6;
  }

  .content pre {
    font-size: 11px;
    padding: 10px;
  }

  .content table th,
  .content table td {
    padding: 6px 8px;
    font-size: 12px;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

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

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

/* Print Button */
.print-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.print-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Print Styles */
@media print {
  /* Hide non-essential elements */
  .docs-header,
  .horizontal-nav,
  .sidebar,
  .breadcrumb,
  .search-box,
  .print-btn,
  .version-select {
    display: none !important;
  }

  /* Reset layout for printing */
  body {
    background: white;
    color: black;
  }

  .docs-container {
    display: block;
  }

  .main-layout {
    display: block;
    grid-template-columns: 1fr;
  }

  .content-area {
    display: block;
    padding: 0;
    max-width: 100%;
  }

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

  /* Ensure content prints correctly */
  .content h1,
  .content h2,
  .content h3,
  .content h4 {
    page-break-after: avoid;
    break-after: avoid;
  }

  .content table,
  .content img,
  .content pre {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .content a {
    text-decoration: none;
    color: black;
  }

  /* Show URLs for links */
  .content a[href]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}
