/**
 * Web Reader - Help Page Styles
 */

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
  background: #f5f5f5;
}

.help-container {
  max-width: 800px;
  margin: 0 auto;
  background: #fff;
  min-height: 100vh;
}

/* Header */
.help-header {
  background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
  color: #fff;
  padding: 48px 24px;
  text-align: center;
  position: relative;
}

.help-header-content {
  max-width: 600px;
  margin: 0 auto;
}

/* Back Button in Header (privacy page) */
.help-back-button {
  position: absolute;
  top: 16px;
  left: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.help-back-button:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.8);
}

.help-back-button:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Language Toggle (segmented control) */
.help-lang-segmented {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  padding: 3px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
}

.help-lang-option {
  min-width: 40px;
  height: 28px;
  padding: 0 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.help-lang-option:hover {
  color: #fff;
}

.help-lang-option.active {
  background: #fff;
  color: #2E7D32;
}

.help-lang-option:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.help-header h1 {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 8px;
}

.help-subtitle {
  font-size: 18px;
  opacity: 0.9;
}

/* Navigation */
.help-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.help-nav a {
  padding: 8px 16px;
  background: #f0f0f0;
  color: #333;
  text-decoration: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}

.help-nav a:hover {
  background: #4CAF50;
  color: #fff;
}

/* Main Content */
.help-content {
  padding: 24px;
}

/* Sections */
.help-section {
  margin-bottom: 48px;
  padding-bottom: 48px;
  border-bottom: 1px solid #e0e0e0;
}

.help-section:last-child {
  border-bottom: none;
}

.help-section h2 {
  font-size: 28px;
  font-weight: 700;
  color: #2E7D32;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 3px solid #4CAF50;
  display: inline-block;
}

/* Steps */
.help-step {
  display: flex;
  gap: 20px;
  margin-bottom: 32px;
  overflow: hidden;
}

.help-step-number {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  background: #4CAF50;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
}

.help-step-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.help-step-content h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
}

.help-step-content p {
  color: #555;
  margin-bottom: 16px;
}

/* Image Placeholders */
.help-image-placeholder {
  background: #f8f9fa;
  border: 2px dashed #ccc;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  color: #666;
  font-size: 14px;
  margin-top: 16px;
}

.help-image-placeholder.large {
  padding: 64px 24px;
}

.help-image-placeholder span {
  display: block;
}

/* When images are added, use this class */
.help-image {
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  margin-top: 16px;
}

/* Toolbar Preview */
.help-toolbar-preview {
  margin-bottom: 32px;
  padding: 24px;
  background: #f0f0f0;
  border-radius: 12px;
  overflow-x: auto;
}

.help-toolbar-preview .webreader-panel {
  display: inline-flex;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Controls Table */
.help-controls-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.help-controls-table th,
.help-controls-table td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
  vertical-align: middle;
}

.help-controls-table th {
  background: #f5f5f5;
  font-weight: 600;
  font-size: 14px;
  color: #555;
}

.help-controls-table th:first-child {
  width: 120px;
  text-align: center;
}

.help-controls-table th:nth-child(2) {
  width: 140px;
}

.help-controls-table td:first-child {
  text-align: center;
}

.help-controls-table tbody tr:hover {
  background: #f9f9f9;
}

/* The demo control icons reuse the live toolbar's .webreader-panel-* classes,
   but those rely on --panel-* variables only defined on .webreader-panel. In
   the table the buttons/selects have no panel ancestor, so we supply the
   panel's dark backdrop and colours here to keep their backgrounds visible. */
.help-controls-table .webreader-panel-btn {
  background: rgba(33, 33, 33, 0.95);
  color: #ffffff;
}

.help-controls-table .webreader-panel-btn-primary {
  background: #4CAF50;
}

.help-controls-table .webreader-panel-select {
  background-color: rgba(33, 33, 33, 0.95);
  color: #ffffff;
}

.help-controls-table .webreader-panel-btn[disabled],
.help-controls-table .webreader-panel-select[disabled] {
  opacity: 1;
  cursor: default;
}

/* Demo containers for visualizations */
.help-demo-container {
  margin-top: 16px;
  padding: 20px;
  background: #e8e8e8;
  border-radius: 12px;
  overflow: hidden;
  max-width: 100%;
}

.help-demo-container .webreader-panel {
  display: inline-flex;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: none;
  width: auto;
}

/* Red outline for highlighted buttons */
.help-highlight-btn {
  outline: 3px solid #e53935 !important;
  outline-offset: 2px;
  position: relative;
}

/* Demo text container */
.help-demo-text {
  margin-top: 16px;
  padding: 20px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  font-size: 16px;
  line-height: 1.8;
}

.help-demo-text p {
  margin: 0;
}

/* Yellow highlight for current sentence */
.help-text-highlight {
  background: rgba(255, 235, 59, 0.5);
  padding: 2px 0;
}

/* User selection simulation (blue highlight like browser selection) */
.help-user-selection {
  background: rgba(0, 120, 215, 0.3);
  position: relative;
}

/* Read button positioned above selection */
.help-selection-btn-demo {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  animation: none;
}

/* Tips Grid */
.help-tips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.help-tip {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 12px;
  padding: 20px;
}

.help-tip-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.help-tip h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.help-tip p {
  font-size: 14px;
  color: #666;
  margin: 0;
}

/* Lists */
.help-list {
  list-style: none;
  margin: 16px 0;
}

.help-list li {
  padding: 8px 0;
  padding-left: 24px;
  position: relative;
}

.help-list li::before {
  content: '•';
  position: absolute;
  left: 8px;
  color: #4CAF50;
  font-weight: bold;
}

/* Keyboard shortcuts */
.help-shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.help-shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  color: #333;
}

kbd {
  display: inline-block;
  padding: 4px 8px;
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: monospace;
  font-size: 14px;
  box-shadow: 0 2px 0 #ccc;
  white-space: nowrap;
}

/* Settings tab (extension-only) */
.help-field {
  margin-bottom: 20px;
  max-width: 520px;
}

.help-field:last-child {
  margin-bottom: 0;
}

.help-field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.help-field-help {
  font-size: 13px;
  color: #666;
  line-height: 1.5;
  margin: 8px 0 0;
}

.help-form-select,
.help-form-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: #333;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
}

.help-form-select:focus,
.help-form-input:focus,
.help-form-slider:focus,
.help-form-color:focus {
  outline: 3px solid rgba(76, 175, 80, 0.4);
  outline-offset: 1px;
  border-color: #4CAF50;
}

.help-form-slider {
  width: 100%;
  accent-color: #4CAF50;
}

.help-color-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.help-form-color {
  width: 48px;
  height: 40px;
  padding: 2px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.help-color-group .help-form-select {
  flex: 1;
}

.help-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
}

.help-checkbox {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: #4CAF50;
  cursor: pointer;
  flex-shrink: 0;
}

.help-settings-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid #e0e0e0;
}

.help-btn-primary,
.help-btn-secondary {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
}

.help-btn-primary {
  background: #4CAF50;
  color: #fff;
}

.help-btn-primary:hover {
  background: #43a047;
}

.help-btn-secondary {
  background: #fff;
  color: #333;
  border-color: #ccc;
}

.help-btn-secondary:hover {
  background: #f5f5f5;
}

.help-btn-primary:focus-visible,
.help-btn-secondary:focus-visible {
  outline: 3px solid rgba(76, 175, 80, 0.4);
  outline-offset: 2px;
}

.help-save-status {
  font-size: 13px;
  font-weight: 600;
}

/* FAQ */
.help-faq {
  display: grid;
  gap: 16px;
}

.help-faq-item {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
}

.help-faq-question {
  font-size: 15px;
  font-weight: 600;
  padding: 16px 20px;
  background: #f5f5f5;
  color: #333;
  border-bottom: 1px solid #e0e0e0;
}

.help-faq-answer {
  font-size: 14px;
  color: #555;
  padding: 16px 20px;
  line-height: 1.6;
}

/* Main Footer */
.help-footer-main {
  background: #1a1a1a;
  color: #fff;
  padding: 40px 24px;
  text-align: center;
}

.help-footer-content {
  max-width: 600px;
  margin: 0 auto;
}

.help-footer-logo {
  height: 36px;
  width: auto;
  filter: brightness(0) invert(1);
  margin-bottom: 10px;
}

.help-footer-powered-by {
  display: block;
  color: #4CAF50;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.02em;
  margin-bottom: 16px;
}

.help-footer-powered-by:hover {
  text-decoration: underline;
}

.help-footer-desc {
  color: #ccc;
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 20px 0;
}

.help-footer-desc a {
  color: #4CAF50;
  text-decoration: none;
  font-weight: 500;
}

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

.help-footer-links {
  color: #888;
  font-size: 13px;
  margin: 0 0 16px 0;
}

.help-footer-links a {
  color: #4CAF50;
  text-decoration: none;
  font-weight: 500;
}

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

.help-footer-copyright {
  color: #888;
  font-size: 13px;
  margin: 0;
  padding-top: 20px;
  border-top: 1px solid #333;
}

/* Sponsors Section */
.help-sponsors {
  background: #f5f5f5;
  padding: 32px 24px;
  border-top: 1px solid #e0e0e0;
  overflow-x: auto;
}

.help-sponsors-grid {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 32px;
  min-width: max-content;
}

.help-sponsor-logo {
  height: 50px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

/* Responsive footer */
@media (max-width: 600px) {
  .help-sponsors-grid {
    gap: 24px;
  }

  .help-sponsor-logo {
    height: 48px;
  }
}

/* Responsive */
@media (max-width: 600px) {
  .help-header {
    padding: 32px 16px;
  }

  .help-header h1 {
    font-size: 28px;
  }

  .help-nav {
    padding: 12px 16px;
  }

  .help-nav a {
    padding: 6px 12px;
    font-size: 13px;
  }

  .help-content {
    padding: 16px;
  }

  .help-step {
    flex-direction: column;
    gap: 12px;
  }

  .help-step-number {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .help-section h2 {
    font-size: 22px;
  }

  .help-tips-grid {
    grid-template-columns: 1fr;
  }
}

/* Tabs */
.help-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 16px 0;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 100;
  overflow-x: auto;
}

.help-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: transparent;
  color: #666;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  white-space: nowrap;
  margin-bottom: -1px;
}

.help-tab:hover {
  color: #2E7D32;
  background: #f5f5f5;
}

.help-tab:focus-visible {
  outline: 2px solid #4CAF50;
  outline-offset: -2px;
}

.help-tab-active {
  color: #2E7D32;
  border-bottom-color: #4CAF50;
}

.help-tab-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.help-content-hidden {
  display: none;
}

.help-section-lead {
  color: #555;
  margin-bottom: 20px;
  max-width: 640px;
}

/* Code blocks */
.help-code-block {
  position: relative;
  margin: 16px 0;
  background: #1e1e1e;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.help-code-block pre {
  margin: 0;
  padding: 20px 24px;
  overflow-x: auto;
  font-family: 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  color: #e6e6e6;
}

.help-code-block code {
  font-family: inherit;
  color: inherit;
  background: transparent;
  padding: 0;
}

.help-code-highlight {
  background: rgba(76, 175, 80, 0.25);
  border-left: 3px solid #4CAF50;
  padding-left: 8px;
  margin-left: -11px;
  display: inline-block;
  color: #c8e6c9;
}

.help-code-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  z-index: 1;
}

.help-code-copy:hover {
  background: rgba(76, 175, 80, 0.4);
  border-color: #4CAF50;
}

.help-code-copy:focus-visible {
  outline: 2px solid #4CAF50;
  outline-offset: 2px;
}

.help-code-copy-success {
  background: #4CAF50;
  border-color: #4CAF50;
}

.help-inline-code {
  background: #f0f0f0;
  color: #c62828;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 0.9em;
}

/* Options grid */
.help-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.help-option-card {
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 18px 20px;
}

.help-option-name {
  margin-bottom: 8px;
}

.help-option-name code {
  background: #2E7D32;
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
}

.help-option-desc {
  font-size: 14px;
  color: #555;
  line-height: 1.6;
}

.help-option-desc code {
  background: #f0f0f0;
  color: #c62828;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
}

/* Responsive tabs */
@media (max-width: 600px) {
  .help-tab {
    padding: 10px 14px;
    font-size: 14px;
  }

  .help-tab-icon {
    width: 16px;
    height: 16px;
  }

  .help-code-block pre {
    padding: 16px 18px;
    font-size: 13px;
  }
}

/* Print styles */
@media print {
  .help-nav {
    display: none;
  }

  .help-image-placeholder {
    border-style: solid;
  }
}
