/* UI v2 STEP 5 — document detail + preview modal */

.detail-wrap {
  max-width: 1160px;
  margin: 0 auto;
}

.breadcrumb {
  margin: 22px 0 -6px;
  color: var(--color-text-secondary, #475569);
  font-weight: 600;
}

.breadcrumb a {
  color: var(--color-primary, #0f766e);
  text-decoration: none;
}

.detail-card {
  background: #fff;
  border: 1px solid var(--color-border, #dbe5ef);
  border-radius: var(--radius-card, 12px);
  padding: 28px;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.08));
  margin: 24px 0;
}

.detail-hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 26px;
  align-items: start;
}

.detail-cover {
  min-height: 320px;
  border-radius: var(--radius-card, 12px);
  background: linear-gradient(135deg, #eef6ff, #f0fdfa);
  border: 1px solid var(--color-border, #dbe5ef);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.detail-cover img {
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: cover;
}

.detail-icon-large {
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  background: #fff;
  border: 1px solid #dbeafe;
  font-size: 52px;
  overflow: hidden;
}

.detail-icon-large img {
  width: 68px;
  height: 68px;
  object-fit: contain;
}

.gallery-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.gallery-row button,
.gallery-row a {
  display: block;
  height: 80px;
  border-radius: var(--radius-button, 8px);
  border: 1px solid var(--color-border, #dbe5ef);
  overflow: hidden;
  background: var(--color-bg, #f8fafc);
  padding: 0;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.gallery-row button:hover,
.gallery-row a:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
}

.gallery-row img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-title {
  font-size: 28px;
  font-weight: 700;
  margin: 8px 0 12px;
  color: var(--color-text-primary, #0f172a);
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.detail-muted {
  color: var(--color-text-secondary, #475569);
  line-height: 1.7;
  font-size: 16px;
}

.detail-price {
  font-size: 32px;
  font-weight: 800;
  color: var(--color-primary, #0f766e);
  margin: 16px 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 24px;
  align-items: start;
}

.buy-box {
  background: var(--color-bg, #f8fafc);
  border: 1px solid var(--color-border, #dbe5ef);
  border-radius: var(--radius-card, 12px);
  padding: 20px;
  position: sticky;
  top: 92px;
}

.buy-box label {
  display: block;
  font-weight: 600;
  margin: 12px 0 6px;
  color: var(--color-text-secondary, #475569);
}

.doc-buy-form .bqs-form-group {
  margin-bottom: 12px;
}

.buy-box .buy-box-price {
  font-size: 26px;
  margin-top: 0;
}

.buy-box input:not([type="checkbox"]),
.buy-box textarea,
.buy-box select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-input, 8px);
  padding: 11px 12px;
}

.buy-box input:not([type="checkbox"]) {
  display: block;
}

.invoice-checkout-box {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-card, 12px);
  background: var(--color-bg, #f8fafc);
}

.invoice-checkout-box.is-active {
  border-color: #007f73;
  background: #ecfdf5;
  box-shadow: 0 0 0 3px rgba(0, 127, 115, 0.12);
}

.invoice-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #94a3b8;
  border-radius: var(--radius-button, 8px);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  color: var(--color-text, #0f172a);
  line-height: 1.4;
}

.invoice-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 0;
  padding: 0;
  flex: 0 0 18px;
  accent-color: #007f73;
  cursor: pointer;
}

.invoice-checkbox span {
  flex: 1;
}

.invoice-help {
  margin: 10px 0 0;
  color: #64748b;
  font-size: 14px;
  line-height: 1.6;
}

.invoice-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed #cbd5e1;
}

.invoice-fields label {
  display: block;
  font-weight: 600;
  margin: 12px 0 6px;
  color: #334155;
}

.invoice-warning {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-button, 8px);
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 14px;
  line-height: 1.55;
}

.buy-btn {
  width: 100%;
  margin-top: 14px;
  border: 0;
  border-radius: var(--radius-button, 8px);
  padding: 14px 16px;
  background: #007f73;
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.35;
  font-weight: 600;
  cursor: pointer;
}

.buy-btn-cart {
  background: #fff;
  color: #08796f !important;
  border: 2px solid #14b8a6;
  margin-top: 0;
  margin-bottom: 10px;
}

.buy-btn-cart:hover {
  background: #ecfdf5;
}

.buy-btn:hover {
  filter: brightness(1.03);
}

.doc-cart-add-form {
  margin: 0 0 8px;
}

.doc-cart-note {
  margin: 0 0 14px;
  font-size: 14px;
}

.meta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.meta-pill {
  background: #e0f2fe;
  color: #075985;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.badge-hot {
  background: #fee2e2;
  color: #991b1b;
}

.badge-green {
  background: #dcfce7;
  color: #166534;
}

.content-card {
  background: #fff;
  border: 1px solid var(--color-border, #dbe5ef);
  border-radius: var(--radius-card, 12px);
  padding: 22px;
  margin-top: 20px;
}

.secure-note {
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #166534;
  border-radius: var(--radius-card, 12px);
  padding: 14px;
  line-height: 1.6;
}

.trust-box {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.trust-box div {
  background: var(--color-bg, #f8fafc);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius-button, 8px);
  padding: 12px;
  font-weight: 600;
  color: #334155;
  font-size: 13px;
}

.markdown-like {
  white-space: pre-line;
  line-height: 1.75;
  color: #334155;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.related-card {
  border: 1px solid var(--color-border, #dbe5ef);
  border-radius: var(--radius-card, 12px);
  padding: 14px;
  background: #fff;
  text-decoration: none;
  color: var(--color-text, #0f172a);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.related-card:hover {
  border-color: #b7d4df;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.06);
}

.related-card strong {
  display: block;
  margin-bottom: 6px;
}

.related-meta {
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

.buy-summary {
  border-top: 1px solid var(--color-border, #e2e8f0);
  margin-top: 14px;
  padding-top: 14px;
  color: #475569;
  line-height: 1.55;
  font-size: 14px;
}

.back-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.back-list-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-button, 8px);
  padding: 12px 16px;
  background: #007f73;
  color: #fff !important;
  text-decoration: none;
  font-family: inherit;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.35;
}

.back-list-btn.secondary {
  background: #e0f2fe;
  color: #075985 !important;
}

.doc-preview-btn {
  margin-top: 10px;
  border: 0;
  border-radius: var(--radius-button, 8px);
  padding: 10px 14px;
  background: #e2e8f0;
  color: var(--color-text, #0f172a);
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.doc-preview-btn:hover {
  background: #cbd5e1;
}

/* Preview modal */
.doc-preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.72);
}

.doc-preview-backdrop.is-open {
  display: flex;
}

.doc-preview-dialog {
  position: relative;
  max-width: min(920px, 96vw);
  max-height: 92vh;
  background: #fff;
  border-radius: var(--radius-card, 12px);
  padding: 16px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.28);
}

.doc-preview-caption {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text, #0f172a);
}

.doc-preview-image {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 80px);
  margin: 0 auto;
  border-radius: var(--radius-button, 8px);
  object-fit: contain;
}

.doc-preview-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.doc-preview-close:hover {
  background: rgba(15, 23, 42, 0.14);
}

@media (max-width: 960px) {
  .detail-hero,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .buy-box {
    position: static;
  }

  .detail-cover {
    min-height: 240px;
  }

  .detail-cover img {
    min-height: 240px;
  }

  .trust-box {
    grid-template-columns: 1fr;
  }

  .detail-title {
    font-size: 26px;
  }
}
