/* Global typography and A4 layout styling */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --primary-gold: #d19c1f;
  --dark-black: #141414;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #020617;
  color: #1e293b;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

/* Document Container Wrapper */
.document-viewport {
  width: 100%;
  overflow-x: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px 8px 40px 8px;
  -webkit-overflow-scrolling: touch;
}

.document-scale-wrapper {
  transform-origin: top center;
  transition: transform 0.2s ease, height 0.2s ease;
}

/* Strict Single-Page A4 Sheet (210mm x 297mm) */
.a4-sheet {
  width: 210mm;
  height: 297mm;
  max-height: 297mm;
  margin: 0 auto;
  background-color: #ffffff;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

/* BCS Invoice sheet - uses reliable direct background styling */
.invoice-sheet {
  background-color: #ffffff;
  background-image: url('bcs_template_background.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: top center;
  position: relative;
}

.invoice-content-layer {
  position: relative;
  z-index: 2;
  padding: 232px 65px 40px 65px;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

/* Permission form sheet */
.form-sheet {
  background-color: #ffffff;
  padding: 48px 65px 40px 65px;
  font-family: Arial, Helvetica, sans-serif;
  color: #000000;
  font-size: 14.5px;
  line-height: 1.45;
}

/* Editable text */
[contenteditable="true"] {
  outline: none;
  min-width: 15px;
  display: inline-block;
  cursor: text;
  border-radius: 2px;
}

body:not(.preview-active) [contenteditable="true"]:hover {
  background-color: rgba(209, 156, 31, 0.12);
  outline: 1px dashed rgba(209, 156, 31, 0.6);
}

body:not(.preview-active) [contenteditable="true"]:focus {
  background-color: rgba(209, 156, 31, 0.18);
  outline: 2px solid #d19c1f;
}

/* Form input box */
.doc-box {
  border: 1.5px solid #000000;
  background-color: #ffffff;
  outline: none;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  color: #000000;
  padding: 3px 8px;
  box-sizing: border-box;
}

body:not(.preview-active) .doc-box:focus {
  border-color: #2563eb;
  background-color: #f8fafc;
}

.doc-textarea {
  border: 1.5px solid #000000;
  background-color: #ffffff;
  outline: none;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  color: #000000;
  padding: 4px 8px;
  resize: none;
  box-sizing: border-box;
  line-height: 1.35;
}

body:not(.preview-active) .doc-textarea:focus {
  border-color: #2563eb;
  background-color: #f8fafc;
}

/* When preview is active or in print mode */
body.preview-active [contenteditable="true"]:hover,
body.preview-active [contenteditable="true"]:focus {
  background-color: transparent !important;
  outline: none !important;
}

body.preview-active .no-preview,
body.preview-active .row-action-inline {
  display: none !important;
}

/* Pure vector print CSS */
@media print {
  @page {
    size: A4 portrait;
    margin: 0mm;
  }

  html, body {
    background-color: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 210mm !important;
    height: 297mm !important;
    overflow: hidden !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .no-print, .row-action-inline {
    display: none !important;
  }

  .document-viewport {
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    overflow: visible !important;
  }

  .document-scale-wrapper {
    transform: none !important;
    height: auto !important;
    margin: 0 !important;
  }

  .a4-sheet {
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
    width: 210mm !important;
    height: 297mm !important;
    max-height: 297mm !important;
    page-break-after: avoid !important;
    page-break-before: avoid !important;
    page-break-inside: avoid !important;
    overflow: hidden !important;
  }

  .invoice-sheet {
    background-image: url('bcs_template_background.png') !important;
    background-size: 100% 100% !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  [contenteditable="true"] {
    outline: none !important;
    background: transparent !important;
  }

  .doc-box,
  .doc-textarea {
    border-color: #000000 !important;
  }
}
