/**
 * Help Dialog styles (M6b)
 * Plan: docs/plans/2026-04-23_refund-m5-m6-api-help-ui-plan.md §4.1
 * 风格对齐 agreement.css；z-index 略低于 agreement modal（help 内不会嵌套 consent）
 */

:root {
  --help-overlay-bg: rgba(0, 0, 0, 0.45);
  --help-modal-bg: #ffffff;
  --help-modal-radius: 14px;
  --help-modal-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  --help-border: #e5e7eb;
  --help-text-primary: #1f2937;
  --help-text-secondary: #6b7280;
  --help-accent: #2563eb;
  --help-accent-hover: #1d4ed8;
  --help-bg-soft: #f9fafb;
  --help-danger: #dc2626;
}

[data-theme="dark"] {
  --help-overlay-bg: rgba(0, 0, 0, 0.6);
  --help-modal-bg: #1f2937;
  --help-border: #374151;
  --help-text-primary: #f3f4f6;
  --help-text-secondary: #9ca3af;
  --help-bg-soft: #111827;
}

/* Overlay */
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 10040;
  background: var(--help-overlay-bg);
}

/* Modal */
.help-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10041;
  width: calc(100% - 32px);
  max-width: 560px;
  max-height: calc(100vh - 48px);
  background: var(--help-modal-bg);
  border-radius: var(--help-modal-radius);
  box-shadow: var(--help-modal-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.help-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--help-border);
  flex-shrink: 0;
  gap: 8px;
}

.help-header-spacer { display: block; }

.help-header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--help-text-primary);
  text-align: center;
}

.help-close-btn,
.help-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--help-text-secondary);
  font-size: 14px;
  transition: background 0.15s;
}

.help-back-btn {
  justify-self: start;
}

.help-close-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 20px;
  justify-content: center;
  justify-self: end;
}

.help-close-btn:hover,
.help-back-btn:hover {
  background: var(--help-bg-soft);
  color: var(--help-text-primary);
}

/* Body */
.help-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Category list (L3) */
.help-cat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.help-cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  background: var(--help-bg-soft);
  border: 1px solid var(--help-border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--help-text-primary);
  transition: background 0.15s, border-color 0.15s;
}

.help-cat-row:hover {
  background: var(--help-modal-bg);
  border-color: var(--help-accent);
}

.help-cat-row-chevron {
  color: var(--help-text-secondary);
  font-size: 18px;
}

/* FAQ (L4) */
.help-faq-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--help-text-primary);
}

.help-faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.help-faq-item {
  background: var(--help-bg-soft);
  border: 1px solid var(--help-border);
  border-radius: 10px;
  padding: 10px 14px;
}

.help-faq-q {
  font-size: 14px;
  font-weight: 500;
  color: var(--help-text-primary);
  cursor: pointer;
  list-style: none;
  padding: 4px 0;
}

.help-faq-q::-webkit-details-marker { display: none; }

.help-faq-item[open] .help-faq-q {
  color: var(--help-accent);
}

.help-faq-a {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--help-text-secondary);
  white-space: pre-wrap;
}

/* Contact footer */
.help-contact {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--help-border);
}

.help-contact-title {
  font-size: 13px;
  color: var(--help-text-secondary);
  margin-bottom: 10px;
}

.help-contact-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.help-contact-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: var(--help-modal-bg);
  border: 1px solid var(--help-border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--help-text-primary);
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}

.help-contact-btn:hover {
  border-color: var(--help-accent);
  background: var(--help-bg-soft);
}

.help-contact-btn.is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--help-bg-soft);
}

.help-contact-btn.is-disabled:hover {
  border-color: var(--help-border);
  background: var(--help-bg-soft);
}

.help-contact-btn-label {
  flex: 1;
}

.help-contact-btn-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--help-accent);
  color: #ffffff;
}

.help-contact-btn.is-disabled .help-contact-btn-badge {
  background: var(--help-text-secondary);
}

/* Mail form (L5) */
.help-mail-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.help-mail-form-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--help-text-primary);
}

.help-mail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.help-mail-field-label {
  font-size: 13px;
  color: var(--help-text-secondary);
}

.help-mail-input {
  padding: 10px 12px;
  border: 1px solid var(--help-border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--help-text-primary);
  background: var(--help-bg-soft);
  font-family: inherit;
}

.help-mail-input:focus {
  outline: none;
  border-color: var(--help-accent);
  background: var(--help-modal-bg);
}

.help-mail-textarea {
  resize: vertical;
  min-height: 100px;
}

.help-mail-counter {
  font-size: 12px;
  color: var(--help-text-secondary);
  text-align: right;
}

.help-mail-hint {
  font-size: 12px;
  color: var(--help-text-secondary);
}

.help-mail-file-input {
  padding: 6px;
  background: transparent;
}

.help-mail-file-list {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.help-mail-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--help-bg-soft);
  border-radius: 6px;
  font-size: 12px;
  color: var(--help-text-primary);
}

.help-mail-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.help-mail-file-size {
  color: var(--help-text-secondary);
}

.help-mail-file-remove {
  border: none;
  background: transparent;
  color: var(--help-text-secondary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
}

.help-mail-file-remove:hover {
  color: var(--help-danger);
}

.help-mail-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

.help-mail-send-btn {
  padding: 10px 24px;
  border: none;
  background: var(--help-accent);
  color: #ffffff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}

.help-mail-send-btn:hover:not([disabled]) {
  background: var(--help-accent-hover);
}

.help-mail-send-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .help-modal {
    max-height: calc(100vh - 16px);
    border-radius: 10px;
  }
  .help-body {
    padding: 12px;
  }
}
