/* wwwroot/css/shared/document-preview.css */

/* ============================================================
   A4 Paper Shell
   ============================================================ */

.document-preview.a4 {
  width: var(--preview-paper-width);
  min-height: var(--preview-paper-min-height);
  max-width: 100%;
  margin: 0 auto;
  padding: var(--preview-paper-padding);
  background-color: var(--preview-paper-bg);
  box-shadow: var(--preview-paper-shadow);
  border-radius: var(--preview-paper-radius);
  color: var(--color-text-primary);
  font-size: var(--font-size-small);
  line-height: var(--line-height-base);
}

/* ============================================================
   Document Content — shared by every template; only the accent
   color and a few structural touches vary per template class.
   ============================================================ */

.doc-header {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-3);
  padding-bottom: var(--spacing-3);
  margin-bottom: var(--spacing-3);
  border-bottom: 2px solid var(--doc-accent, var(--color-primary));
}

.doc-logo {
  margin-bottom: var(--spacing-1);
}

.doc-seller-name {
  font-size: var(--font-size-h4);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

.doc-header-meta {
  text-align: right;
}

.doc-title {
  font-size: var(--font-size-h2);
  font-weight: var(--font-weight-bold);
  color: var(--doc-accent, var(--color-primary));
  margin-bottom: var(--spacing-1);
}

.doc-meta-line {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-1);
  font-size: var(--font-size-small);
}

.doc-meta-line span:first-child {
  color: var(--color-text-muted);
}

.doc-section {
  margin-bottom: var(--spacing-3);
}

.doc-section h3 {
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--spacing-1);
}

.doc-bill-to h3 {
  color: var(--color-text-muted);
  text-transform: uppercase;
  font-size: var(--font-size-caption);
  letter-spacing: 0.04em;
}

.doc-customer-name {
  font-weight: var(--font-weight-semibold);
}

.doc-items-table {
  width: 100%;
  border-collapse: collapse;
}

.doc-items-table th {
  background-color: var(--table-header-bg);
  color: var(--table-header-text);
  font-size: var(--table-header-font-size);
  font-weight: var(--table-header-weight);
  text-align: left;
  padding: var(--table-cell-padding);
}

.doc-items-table td {
  border-bottom: var(--table-row-border);
  padding: var(--table-cell-padding);
  font-size: var(--font-size-small);
}

.doc-item-description {
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
}

.doc-summary {
  max-width: 280px;
  margin-left: auto;
}

.doc-summary-line {
  display: flex;
  justify-content: space-between;
  padding: var(--spacing-1) 0;
}

.doc-summary-grand-total {
  border-top: var(--table-row-border);
  margin-top: var(--spacing-1);
  padding-top: var(--spacing-2);
  font-weight: var(--table-total-weight);
  color: var(--doc-accent, var(--color-primary));
  font-size: var(--font-size-body);
}

.doc-payment-line {
  display: flex;
  gap: var(--spacing-1);
  font-size: var(--font-size-small);
}

.doc-payment-line span:first-child {
  color: var(--color-text-muted);
  min-width: 120px;
}

.doc-payment-instructions,
.doc-notes p,
.doc-terms p {
  font-size: var(--font-size-small);
  color: var(--color-text-secondary);
  white-space: pre-wrap;
}

.doc-signature-line {
  margin-top: var(--spacing-4);
  padding-top: var(--spacing-1);
  border-top: 1px solid var(--color-border-default);
  font-family: var(--font-family-mono);
  display: inline-block;
}

/* ============================================================
   Template Variants
   Accent colors reuse the existing brand/neutral palette only
   (see document-theme.js) — no new colors are introduced here.
   ============================================================ */

.document-template-classic .doc-header {
  border-bottom-color: var(--color-gray-900);
}

.document-template-classic .doc-title {
  color: var(--color-gray-900);
}

.document-template-minimal .doc-header {
  border-bottom: 1px solid var(--color-border-default);
}

.document-template-minimal .doc-title {
  color: var(--color-text-primary);
  font-weight: var(--font-weight-semibold);
}

.document-template-minimal .doc-items-table th {
  background-color: transparent;
  border-bottom: 2px solid var(--color-border-default);
}

.document-template-blue .doc-header {
  background-color: var(--color-primary-soft);
  padding: var(--spacing-3);
  border-radius: var(--radius-md);
  border-bottom: none;
}

.document-preview.document-preview-dark {
  background-color: var(--color-gray-900);
  color: var(--color-white);
}

.document-template-dark .doc-seller-name,
.document-template-dark .doc-customer-name {
  color: var(--color-white);
}

.document-template-dark .doc-items-table th {
  background-color: var(--color-gray-700);
  color: var(--color-white);
}

.document-template-dark .doc-items-table td,
.document-template-dark .doc-summary-grand-total,
.document-template-dark .doc-signature-line {
  border-color: var(--color-gray-700);
}

.document-template-dark .doc-payment-instructions,
.document-template-dark .doc-notes p,
.document-template-dark .doc-terms p,
.document-template-dark .doc-item-description,
.document-template-dark .doc-payment-line span:first-child,
.document-template-dark .doc-meta-line span:first-child {
  color: var(--color-gray-300);
}

.document-template-creative .doc-header {
  border-bottom: none;
  border-left: 6px solid var(--doc-accent, var(--color-primary));
  padding-left: var(--spacing-3);
}

.document-template-creative .doc-title {
  font-size: var(--font-size-hero);
}

/* ============================================================
   Print
   ============================================================ */

@media print {
  body * {
    visibility: hidden;
  }

  #document-preview,
  #document-preview * {
    visibility: visible;
  }

  #document-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    box-shadow: none;
    margin: 0;
  }
}
