/* assets/css/style.css - Skyline Billing Engine Styling */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800;900&family=Outfit:wght@500;600;700;800;900&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --primary-font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --heading-font: 'Outfit', sans-serif;
  --mono-font: 'JetBrains Mono', monospace;
}

/* Global Viewport & Reset - Prevent any horizontal overflow */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden !important;
  margin: 0;
  padding: 0;
  position: relative;
  font-family: var(--primary-font);
  background-color: #f8fafc;
  color: #1e293b;
  -webkit-tap-highlight-color: transparent;
}

.font-heading {
  font-family: var(--heading-font);
}

.font-mono-amount {
  font-family: var(--mono-font);
}

/* A4 Sheet Dimensions & Shadow for On-Screen Display */
.a4-viewport {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px 12px;
  overflow-x: auto;
  box-sizing: border-box;
}

#invoice-sheet-wrapper {
  margin: 0 auto;
  padding: 4px;
  box-sizing: border-box;
  display: inline-block;
}

.a4-sheet {
  width: 210mm;
  min-height: 297mm;
  padding: 6.5mm 8.5mm;
  margin: 0 auto;
  background: #ffffff;
  color: #000000;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
  position: relative;
  border: 1.5px solid #000000 !important; /* Full outer border around the document */
  transform-origin: top center;
  transition: transform 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: normal;
  word-spacing: normal;
}

/* Clean Document Tables with Sharp Borders */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: -1px;
}

.doc-table th, 
.doc-table td {
  border: 1.5px solid #000000;
  padding: 3.5px 5.5px;
  font-size: 11px;
  line-height: 1.25;
}

.doc-table th {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Border Utilities for Precise Formats */
.b-all { border: 1.5px solid #000000 !important; }
.b-t { border-top: 1.5px solid #000000 !important; }
.b-b { border-bottom: 1.5px solid #000000 !important; }
.b-l { border-left: 1.5px solid #000000 !important; }
.b-r { border-right: 1.5px solid #000000 !important; }

/* Direct Inline Editing on the Preview Sheet */
[contenteditable="true"] {
  outline: none;
  border-radius: 2px;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

[contenteditable="true"]:hover {
  background-color: rgba(59, 130, 246, 0.08);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.3);
  cursor: text;
}

[contenteditable="true"]:focus {
  background-color: rgba(59, 130, 246, 0.15);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.5);
}

/* Dynamic UPI QR Code Box */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 4px;
  border: 1.5px dashed #0284c7;
  border-radius: 6px;
}

.qr-container img, 
.qr-container canvas {
  width: 84px !important;
  height: 84px !important;
  display: block;
}

/* Print Rules - Standard Strict A4 Printing */
@media print {
  html, body {
    width: 210mm !important;
    height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body * {
    visibility: hidden;
  }

  .no-print, header, nav, aside, .floating-actions, .modal-backdrop {
    display: none !important;
  }

  #panel-preview, #invoice-sheet-wrapper, .a4-viewport {
    display: block !important;
    visibility: visible !important;
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    transform: none !important;
  }

  #invoice-printable, #invoice-printable * {
    visibility: visible;
  }

  #invoice-printable .no-print,
  #invoice-printable .no-print *,
  #invoice-printable button {
    display: none !important;
    visibility: hidden !important;
  }

  #invoice-printable {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    width: 200mm !important;
    max-width: 200mm !important;
    min-height: 287mm !important;
    margin: 0 auto !important;
    padding: 4.5mm 6.5mm !important;
    box-shadow: none !important;
    border: 1.5px solid #000000 !important;
    box-sizing: border-box !important;
    transform: none !important;
  }

  [contenteditable="true"]:hover, [contenteditable="true"]:focus {
    background: transparent !important;
    box-shadow: none !important;
  }

  @page {
    size: A4 portrait;
    margin: 5mm;
  }
}

/* Mobile Responsiveness & Strict Overflow Boundaries */
@media (max-width: 1024px) {
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
    position: relative;
  }

  main {
    max-width: 100% !important;
    overflow-x: hidden !important;
    padding: 8px 6px !important;
  }

  #panel-form {
    width: 100% !important;
    max-width: 100% !important;
  }

  #panel-preview {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
  }

  .a4-viewport {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0 60px 0 !important;
    display: flex;
    justify-content: center;
  }
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
