/*
 * Shared styles for document preview across all views.
 * These values must match Template::DOCUMENT_STYLES in app/models/template.rb.
 * Future: per-template styles (#115) will make these dynamic.
 *
 * IMPORTANT: Use pt (points) for font sizes and spacing, not px.
 * PDF generation (Prawn) uses points (1pt = 1/72in). CSS px != pt.
 * At 96dpi: 12pt = 16px. Using pt ensures screen matches print.
 */

/* Preview wrapper to contain document */
#preview-wrapper {
  overflow: auto;
  max-height: 700px;
}

.document-page {
  background: white;
  padding: 1in;             /* 72pt = 1 inch margins, matches Prawn */
  min-height: 11in;
  width: 100%;
  max-width: 8.5in;         /* LETTER width */
  margin: 0 auto;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  font-family: 'Times New Roman', Times, Georgia, serif;  /* :font_family_css */
  font-size: 12pt;          /* :font_size — matches Prawn font_size 12 */
  line-height: 1.5;         /* :line_height */
  color: #000;
  box-sizing: border-box;
}

@media (max-width: 992px) {
  .document-page {
    padding: 0.5in;
  }
}

/* Document typography - unified styles for all document previews */
.document-page h1,
.document-content h1 {
  font-size: 14pt;          /* matches Prawn H1 size: 14 */
  font-weight: bold;
  margin: 15pt 0 12pt;      /* matches Prawn move_down 15/12 */
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5pt;
}

.document-page h2,
.document-content h2 {
  font-size: 13pt;          /* matches Prawn H2 size: 13 */
  font-weight: bold;
  margin: 12pt 0 10pt;      /* matches Prawn move_down 12/10 */
}

.document-page h3,
.document-content h3 {
  font-size: 12pt;          /* matches Prawn H3 size: 12 */
  font-weight: bold;
  margin: 10pt 0 8pt;       /* matches Prawn move_down 10/8 */
}

.document-page h4,
.document-content h4 {
  font-size: 12pt;
  font-style: italic;
  font-weight: normal;
  margin: 10pt 0 8pt;
}

.document-page h5,
.document-content h5 {
  font-size: 11pt;
  font-weight: bold;
  margin: 8pt 0 6pt;
}

.document-page h6,
.document-content h6 {
  font-size: 11pt;
  font-style: italic;
  font-weight: normal;
  margin: 8pt 0 6pt;
}

.document-page p,
.document-content p {
  margin: 10pt 0;           /* matches Prawn paragraph_spacing: 10 */
  line-height: 1.5;
}

.document-page ul,
.document-page ol,
.document-content ul,
.document-content ol {
  margin: 10pt 0;
  padding-left: 30pt;
}

.document-page li,
.document-content li {
  margin: 5pt 0;
}

.document-page blockquote,
.document-content blockquote {
  margin: 15pt 0;
  padding: 10pt 20pt;
  border-left: 4px solid #ddd;
  background: #f9f9f9;
  color: #666;
}

.document-page code,
.document-content code {
  background: #f5f5f5;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 11pt;
}

.document-page pre,
.document-content pre {
  background: #f5f5f5;
  padding: 10pt;
  border-radius: 5px;
  overflow-x: auto;
}

.document-page pre code,
.document-content pre code {
  background: none;
  padding: 0;
}

.document-page table,
.document-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 15pt 0;
}

.document-page th,
.document-page td,
.document-content th,
.document-content td {
  border: 1px solid #ddd;
  padding: 8pt;
  text-align: left;
}

.document-page th,
.document-content th {
  background: #f5f5f5;
  font-weight: bold;
}

.document-page hr,
.document-content hr {
  border: none;
  border-top: 1px solid #ddd;
  margin: 20pt 0;
}

.document-page strong,
.document-content strong {
  font-weight: bold;
}

.document-page em,
.document-content em {
  font-style: italic;
}

.document-page del,
.document-content del {
  text-decoration: line-through;
}

/* Template field highlighting */
.template-field {
  background: rgba(0, 123, 255, 0.1);
  padding: 2px 4px;
  border-radius: 3px;
  border-bottom: 2px solid transparent;
  transition: all 0.3s;
  position: relative;
  font-weight: 600;
  color: #0056b3;
}

.template-field:hover {
  background: rgba(0, 123, 255, 0.2);
  border-bottom: 2px solid #007bff;
  cursor: pointer;
}

.template-field.no-highlight {
  background: transparent;
  border-bottom: none;
  padding: 0;
  font-weight: normal;
  color: inherit;
}

.template-field.highlight {
  background: rgba(255, 193, 7, 0.3);
  border-bottom: 2px solid #ffc107;
}

/* Signature line style */
.signature-line {
  border-bottom: 1px solid #000;
  display: inline-block;
  min-width: 200pt;
  text-align: center;
  margin: 0 4pt;
}

/* Field list interaction styles */
.field-list-item {
  cursor: pointer;
  transition: background 0.2s;
}

.field-list-item:hover {
  background: #f8f9fa;
}

.field-list-item.active {
  background: #fff3cd;
  border-left: 3px solid #ffc107;
}

/* SimpleMDE editor preview overrides */
.editor-preview,
.editor-preview-side,
.editor-preview-active {
  background: white !important;
  font-family: 'Times New Roman', Times, Georgia, serif !important;
  font-size: 12pt !important;
  color: #000 !important;
}

.editor-preview pre,
.editor-preview-side pre,
.editor-preview-active pre {
  background: #f5f5f5 !important;
  padding: 10pt !important;
  border-radius: 5px !important;
}

.editor-preview code,
.editor-preview-side code,
.editor-preview-active code {
  background: #f5f5f5 !important;
  padding: 2px 4px !important;
  border-radius: 3px !important;
  font-family: 'Courier New', monospace !important;
  font-size: 11pt !important;
}

/* Print styles */
@media print {
  .document-page {
    padding: 1in;
    width: 8.5in;
    height: 11in;
    box-shadow: none;
    page-break-after: always;
  }

  .template-field {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    font-weight: normal !important;
    color: inherit !important;
  }
}
