/* ── Help System Modal ──────────────────────────────────────────────── */

.help-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.help-overlay.help-visible {
  opacity: 1;
  visibility: visible;
}

.help-modal {
  background: #fff;
  border-radius: 12px;
  width: 90vw;
  max-width: 960px;
  height: 80vh;
  max-height: 700px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.help-visible .help-modal {
  transform: scale(1);
}

/* ── Header ──────────────────────────────────────────────── */

.help-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(135deg, #9c6644 0%, #7d5035 100%);
  color: white;
  border-radius: 12px 12px 0 0;
  gap: 12px;
  flex-shrink: 0;
}

.help-modal-title {
  margin: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.help-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.help-search-box i {
  position: absolute;
  left: 10px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
  pointer-events: none;
}

.help-search-box input {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  color: white;
  padding: 5px 12px 5px 30px;
  font-size: 0.85rem;
  width: 180px;
  outline: none;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.help-search-box input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.help-search-box input:focus {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

.help-close-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  color: white;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  line-height: 1;
  transition: background 0.2s ease;
}

.help-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ── Body layout ─────────────────────────────────────────── */

.help-modal-body {
  display: flex;
  flex: 1;
  min-height: 0;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */

.help-sidebar {
  width: 220px;
  background: #f5f5f5;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.help-page-selector {
  padding: 10px 12px;
  border-bottom: 1px solid #ddd;
}

.help-page-selector label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 4px;
  font-weight: 600;
}

.help-page-selector select {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
  background: white;
}

.help-toc {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  flex: 1;
  overflow-y: auto;
}

.help-toc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #444;
  transition: background 0.15s ease;
  border-left: 3px solid transparent;
}

.help-toc-item i {
  width: 16px;
  text-align: center;
  font-size: 0.8rem;
  color: #888;
  flex-shrink: 0;
}

.help-toc-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.help-toc-item:hover {
  background: #e9ecef;
}

.help-toc-item.active {
  background: #ddd;
  font-weight: 600;
  border-left-color: #9c6644;
  color: #333;
}

.help-toc-item.active i {
  color: #9c6644;
}

.help-toc-admin {
  border-left-color: #e74c3c !important;
}

.help-toc-admin.active {
  border-left-color: #e74c3c !important;
}

/* ── Content area ────────────────────────────────────────── */

.help-content-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  min-width: 0;
}

.help-content-inner {
  max-width: 680px;
}

.help-section-title {
  margin: 0 0 16px;
  font-size: 1.2rem;
  color: #9c6644;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid #9c6644;
  padding-bottom: 8px;
}

.help-section-body {
  font-size: 0.92rem;
  line-height: 1.65;
  color: #333;
}

.help-section-body h4 {
  margin: 1.4rem 0 0.6rem;
  font-size: 1rem;
  color: #5a3a28;
}

.help-section-body p {
  margin: 0 0 0.8rem;
}

.help-section-body ul,
.help-section-body ol {
  margin: 0 0 0.8rem;
  padding-left: 1.5rem;
}

.help-section-body li {
  margin-bottom: 0.35rem;
}

.help-section-body code {
  background: #f0ece8;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.88em;
  color: #7d5035;
}

.help-placeholder {
  color: #999;
  font-style: italic;
  text-align: center;
  margin-top: 3rem;
}

/* ── Help table ──────────────────────────────────────────── */

.help-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8rem 0 1.2rem;
  font-size: 0.88rem;
}

.help-table th,
.help-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #e9ecef;
}

.help-table th {
  background: #f8f5f0;
  font-weight: 600;
  color: #5a3a28;
}

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

/* ── Tip and Note callouts ───────────────────────────────── */

.help-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #f0f7ff;
  border: 1px solid #b8d4f0;
  border-radius: 6px;
  padding: 10px 14px;
  margin: 1rem 0;
  font-size: 0.88rem;
}

.help-tip > i {
  color: #2874a6;
  margin-top: 2px;
  flex-shrink: 0;
}

.help-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fff8e6;
  border: 1px solid #f0d060;
  border-radius: 6px;
  padding: 10px 14px;
  margin: 1rem 0;
  font-size: 0.88rem;
}

.help-note > i {
  color: #b8860b;
  margin-top: 2px;
  flex-shrink: 0;
}

.help-admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fce4e4;
  color: #c0392b;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
  .help-modal {
    width: 96vw;
    height: 90vh;
    max-height: none;
    border-radius: 8px;
  }

  .help-modal-header {
    border-radius: 8px 8px 0 0;
    flex-wrap: wrap;
    padding: 10px 14px;
  }

  .help-modal-title {
    font-size: 1rem;
  }

  .help-search-box input {
    width: 140px;
  }

  .help-modal-body {
    flex-direction: column;
    border-radius: 0 0 8px 8px;
  }

  .help-sidebar {
    width: 100%;
    max-height: 160px;
    border-right: none;
    border-bottom: 1px solid #ddd;
  }

  .help-toc {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 8px;
    gap: 4px;
  }

  .help-toc-item {
    white-space: nowrap;
    padding: 6px 10px;
    border-left: none;
    border-bottom: 3px solid transparent;
    border-radius: 4px 4px 0 0;
    font-size: 0.8rem;
  }

  .help-toc-item.active {
    border-left-color: transparent;
    border-bottom-color: #9c6644;
  }

  .help-toc-admin.active {
    border-bottom-color: #e74c3c !important;
  }

  .help-content-area {
    padding: 14px 16px;
  }
}

@media (max-width: 480px) {
  .help-modal-title {
    font-size: 0.9rem;
  }

  .help-search-box input {
    width: 110px;
    font-size: 0.8rem;
  }

  .help-section-body {
    font-size: 0.87rem;
  }
}

/* ── Print: hide help modal ──────────────────────────────── */

@media print {
  .help-overlay {
    display: none !important;
  }
}

/* ── Dark theme ──────────────────────────────────────────── */

body.theme-dark .help-modal {
  background: #2d2d2d;
}

body.theme-dark .help-modal-header {
  background: linear-gradient(135deg, #5a3a28 0%, #3d2518 100%);
}

body.theme-dark .help-sidebar {
  background: #252525;
  border-right-color: #444;
}

body.theme-dark .help-page-selector {
  border-bottom-color: #444;
}

body.theme-dark .help-page-selector label {
  color: #888;
}

body.theme-dark .help-page-selector select {
  background: #3a3a3a;
  border-color: #555;
  color: #e0e0e0;
}

body.theme-dark .help-toc-item {
  color: #ccc;
}

body.theme-dark .help-toc-item:hover {
  background: #3a3a3a;
}

body.theme-dark .help-toc-item.active {
  background: #3a3a3a;
  color: #fff;
}

body.theme-dark .help-toc-item i {
  color: #888;
}

body.theme-dark .help-toc-item.active i {
  color: #d4a574;
}

body.theme-dark .help-content-area {
  background: #2d2d2d;
}

body.theme-dark .help-section-title {
  color: #d4a574;
  border-bottom-color: #d4a574;
}

body.theme-dark .help-section-body {
  color: #ddd;
}

body.theme-dark .help-section-body h4 {
  color: #d4a574;
}

body.theme-dark .help-section-body code {
  background: #3a3530;
  color: #d4a574;
}

body.theme-dark .help-table th {
  background: #3a3530;
  color: #d4a574;
}

body.theme-dark .help-table td {
  border-bottom-color: #444;
  color: #ddd;
}

body.theme-dark .help-tip {
  background: #1a2a3a;
  border-color: #2a4060;
  color: #c0d0e8;
}

body.theme-dark .help-tip > i {
  color: #6aaaee;
}

body.theme-dark .help-note {
  background: #3a2f00;
  border-color: #6a5500;
  color: #e0c040;
}

body.theme-dark .help-note > i {
  color: #e0c040;
}

body.theme-dark .help-admin-badge {
  background: #3a1a1a;
  color: #e08080;
}

body.theme-dark .help-placeholder {
  color: #666;
}
