﻿/* ============================================
   TurboHUD Help System - Dark Theme Styles
   Compatible with IE9+
   ============================================ */

/* Help Section Layout */
/* Prevent page-help from scrolling - completely lock outer scroll */
#page-help {
  overflow: hidden !important;
}
#page-help.active {
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1710px;
  margin: 0 auto;
  height: calc(100vh - 240px);
  min-height: 500px;
  padding: 64px 100px 0 100px;
  box-sizing: border-box;
}
#page-help .content-section {
  overflow: hidden !important;
  padding: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-sizing: border-box;
}
#page-help .section-divider,
#page-help .section-divider + div {
  flex-shrink: 0;
}
#page-help .section-loading { display: none; }
#page-help.active .section-loading { display: none; }

.help-layout {
  display: flex;
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  position: relative;
  background: #0d0d0d;
  border: 1px solid #2a1f0d;
  border-radius: 4px;
  overflow: hidden;
  box-sizing: border-box;
}

/* Help Sidebar */
.help-sidebar {
  width: auto;
  min-width: 240px;
  max-width: 380px;
  flex-shrink: 0;
  background: #111;
  border-right: 1px solid #2a1f0d;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.help-sidebar-header {
  padding: 12px 14px;
  background: linear-gradient(180deg, #1a1208 0%, #111 100%);
  border-bottom: 1px solid #2a1f0d;
  flex-shrink: 0;
}

.help-sidebar-title {
  font-family: "Diablo", "Georgia", serif;
  font-size: 16px;
  color: #C7923E;
  margin: 0 0 8px 0;
}

.help-search-box {
  width: 100%;
  padding: 6px 10px;
  background: #1a1a1a;
  border: 1px solid #3a2a0d;
  border-radius: 3px;
  color: #E8D5B5;
  font-size: 12px;
  outline: none;
  box-sizing: border-box;
}

.help-search-box:focus {
  border-color: #C7923E;
  box-shadow: 0 0 4px rgba(199,146,62,.3);
}

.help-search-box::placeholder {
  color: #666;
}

/* Help Tree */
.help-tree {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: #3a2a0d #111;
}

.help-tree::-webkit-scrollbar {
  width: 6px;
}

.help-tree::-webkit-scrollbar-track {
  background: #111;
}

.help-tree::-webkit-scrollbar-thumb {
  background: #3a2a0d;
  border-radius: 3px;
}

/* Tree Nodes */
.help-tree-node {
  user-select: none;
}

.help-tree-row {
  display: flex;
  align-items: flex-start;
  padding: 4px 8px;
  cursor: pointer;
  transition: background .15s;
  min-height: 22px;
}

.help-tree-row:hover {
  background: rgba(199,146,62,.1);
}

.help-tree-row.active {
  background: rgba(199,146,62,.2);
  border-left: 2px solid #C7923E;
}

.help-tree-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-right: 2px;
}

.help-tree-expand {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #777;
  font-size: 10px;
  transition: transform .2s;
}

.help-tree-expand.expanded {
  transform: rotate(90deg);
}

.help-tree-expand.no-children {
  visibility: hidden;
}

.help-tree-label {
  font-size: 12px;
  color: #ccc;
  margin-left: 2px;
  word-break: break-word;
  line-height: 1.4;
  padding: 2px 0;
}

.help-tree-row:hover .help-tree-label {
  color: #E8D5B5;
}

.help-tree-row.active .help-tree-label {
  color: #C7923E;
  font-weight: bold;
}

.help-tree-children {
  overflow: hidden;
}

.help-tree-children.collapsed {
  display: none;
}

/* Help Content Area */
.help-content {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0d0d0d;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.help-content-header {
  padding: 8px 16px;
  background: linear-gradient(180deg, #1a1208 0%, #0d0d0d 100%);
  border-bottom: 1px solid #2a1f0d;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.help-content-title {
  font-size: 14px;
  color: #C7923E;
  font-weight: bold;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.help-content-nav {
  display: flex;
  gap: 4px;
}

.help-nav-btn {
  background: #1a1a1a;
  border: 1px solid #3a2a0d;
  color: #999;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  transition: all .2s;
}

.help-nav-btn:hover {
  color: #C7923E;
  border-color: #C7923E;
  background: #221a0d;
}

.help-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
  color: #555;
}

/* Help Content Body */
.help-content-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px;
  scrollbar-width: thin;
  scrollbar-color: #3a2a0d #0d0d0d;
  max-width: 100%;
  box-sizing: border-box;
}

.help-content-body::-webkit-scrollbar {
  width: 8px;
}

.help-content-body::-webkit-scrollbar-track {
  background: #0d0d0d;
}

.help-content-body::-webkit-scrollbar-thumb {
  background: #3a2a0d;
  border-radius: 4px;
}

/* Help content typography */
.help-content-body {
  overflow-x: hidden;
  word-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
  box-sizing: border-box;
  color: #E8D5B5;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.7;
}

.help-content-body h1, .help-content-body h2, .help-content-body h3 {
  color: #C7923E;
  margin: 16px 0 8px;
}

.help-content-body h1 { font-size: 20px; }
.help-content-body h2 { font-size: 17px; }
.help-content-body h3 { font-size: 14px; }

.help-content-body a {
  color: #C7923E;
  text-decoration: none;
}

.help-content-body a:hover {
  color: #D4A84B;
  text-decoration: underline;
}

.help-content-body img {
  max-width: 100%;
  height: auto;
  border-radius: 3px;
  border: 1px solid #2a1f0d;
  margin: 8px 0;
}  /* Images auto-scale */

.help-content-body table {
  border-collapse: collapse;
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  margin: 8px 0;
}

.help-content-body td, .help-content-body th {
  border: 1px solid #2a1f0d;
  padding: 6px 10px;
  text-align: left;
}

.help-content-body th {
  background: #1a1208;
  color: #C7923E;
}

/* Themed dividers inside help content */
.help-content-body hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, #C7923E, transparent);
  margin: 20px 0;
}
.help-content-body hr::before {
  content: "\25C6";
  display: block;
  text-align: center;
  color: #C7923E;
  font-size: 10px;
  position: relative;
  top: -8px;
}

/* Neutralize WinCHM template structure (English help) */
.help-content-body #winchm_template_top,
.help-content-body #winchm_template_navigation,
.help-content-body #winchm_template_title,
.help-content-body #winchm_template_container,
.help-content-body #winchm_template_content {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  width: auto !important;
  height: auto !important;
  float: none !important;
  position: static !important;
}
.help-content-body #winchm_template_navigation {
  display: none;
}
.help-content-body #winchm_template_title {
  display: none;
}

.help-content-body ul, .help-content-body ol {
  padding-left: 24px;
}

.help-content-body code, .help-content-body pre {
  background: #1a1a1a;
  border: 1px solid #2a1f0d;
  border-radius: 3px;
  padding: 2px 6px;
  font-family: Consolas, monospace;
  font-size: 12px;
}

/* Help Welcome / Placeholder */
.help-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #666;
  text-align: center;
}

.help-welcome-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.help-welcome-text {
  font-size: 16px;
  color: #888;
  max-width: 400px;
  line-height: 1.6;
}

/* Lazy Load Image Spinner */
.help-img-wrapper {
  display: inline-block;
  position: relative;
  min-width: 40px;
  min-height: 40px;
  background: #1a1a1a;
  border: 1px solid #2a1f0d;
  border-radius: 3px;
  margin: 8px 0;
}

.help-img-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 2px solid rgba(199,146,62,.2);
  border-top-color: #C7923E;
  border-radius: 50%;
  animation: helpSpin .8s linear infinite;
}

@keyframes helpSpin {
  to { transform: rotate(360deg); }
}

.help-img-loaded {
  display: block;
  max-width: 100%;
  border: none;
  border-radius: 3px;
}

/* Loading Overlay for Content */
.help-content-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  flex-direction: column;
  gap: 12px;
}

.help-content-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(199,146,62,.2);
  border-top-color: #C7923E;
  border-radius: 50%;
  animation: helpSpin .8s linear infinite;
}

.help-content-loading-text {
  color: #777;
  font-size: 12px;
}

/* Help Toolbar Actions */
.help-toolbar-actions {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
  border-bottom: 1px solid #2a1f0d;
  background: #111;
}

.help-toolbar-btn {
  background: none;
  border: 1px solid transparent;
  color: #888;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  transition: all .2s;
}

.help-toolbar-btn:hover {
  color: #C7923E;
  border-color: #3a2a0d;
  background: #1a1a1a;
}

/* Error state */
.help-error {
  text-align: center;
  padding: 40px;
  color: #cc4444;
  font-size: 14px;
}

/* Lock body scroll when help is active */
body.help-active {
  overflow: hidden !important;
  height: 100vh;
  width: 100%;
  max-width: 100vw;
}
/* IE Compatibility */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
  /* Flex containers */
  #page-help.active,
  #page-help .content-section,
  .help-layout,
  .help-sidebar,
  .help-content,
  .help-content-header {
    display: -ms-flexbox;
    display: flex;
  }
  #page-help.active,
  #page-help .content-section,
  .help-sidebar {
    -ms-flex-direction: column;
    flex-direction: column;
  }
  .help-layout {
    -ms-flex-direction: row;
    flex-direction: row;
  }
  .help-content-header {
    -ms-flex-direction: row;
    flex-direction: row;
  }

  /* Flex items */
  #page-help .content-section {
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
  }
  .help-layout {
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
  }
  .help-sidebar {
    -ms-flex: 0 0 280px;
    flex: 0 0 280px;
  }
  .help-content {
    -ms-flex: 1 1 0%;
    flex: 1 1 0%;
  }

  /* Alignment */
  .help-content-header {
    -ms-flex-align: center;
    align-items: center;
  }

  /* Min-height fix for IE flex children */
  .help-layout,
  #page-help .content-section {
    min-height: 0;
  }

  /* No rotation animation in IE */
  .help-tree-expand.expanded {
    transform: none;
  }

  /* Sidebar width fallback */
  .help-sidebar {
    width: 280px;
    max-width: 280px;
  }
}
