/* Modern SaaS Invoicing System Styling */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;600;700&display=swap');

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --secondary: #0f172a;
  --accent: #06b6d4;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Space Grotesk', monospace;
}

body {
  font-family: var(--font-main);
  background-color: #f8fafc;
  color: #1e293b;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

/* SaaS Hero & Glassmorphism Effects */
.glass-panel {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
}

.hero-gradient {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #2563eb 100%);
}

.badge-sale {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.badge-purchase {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.badge-debt {
  background-color: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-credit {
  background-color: #fae8ff;
  color: #86198f;
  border: 1px solid #f5d0fe;
}

/* Custom Table Controls */
.item-row input {
  transition: all 0.2s ease;
}

.item-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Floating Action Bar */
.action-bar {
  position: sticky;
  top: 1rem;
  z-index: 40;
}

/* =========================================================
   PRINT MEDIA QUERIES (A4 & THERMAL POS FORMATS)
   ========================================================= */

@media print {
  /* Hide interactive web UI controls */
  .no-print, header, footer, .action-bar, nav, button, .btn-print-hide {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 12pt;
    margin: 0 !important;
    padding: 0 !important;
  }

  .print-wrapper {
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  /* -------------------------------------------------------
     1. STANDARD A4 PRINT FORMAT
     ------------------------------------------------------- */
  body.print-mode-a4 {
    margin: 15mm !important;
  }

  body.print-mode-a4 .invoice-container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
  }

  body.print-mode-a4 table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  body.print-mode-a4 th, 
  body.print-mode-a4 td {
    border: 1px solid #cbd5e1 !important;
    padding: 8px 12px !important;
  }

  body.print-mode-a4 th {
    background-color: #f1f5f9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Force exact color rendering for FBR verification banner & USIN text */
  .bg-emerald-100\/80, .bg-emerald-100, .text-rose-600, .text-emerald-900, .text-emerald-950 {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* -------------------------------------------------------
     2. THERMAL POS RECEIPT FORMATS (Strictly Scoped Print Rules)
     ------------------------------------------------------- */
  @page {
    size: auto;
    margin: 0mm !important;
  }

  /* 80mm Printer Specification (Standard Desktop POS) */
  body.print-mode-thermal #printable-invoice,
  body.print-mode-thermal-80 #printable-invoice {
    width: 76mm !important;
    max-width: 76mm !important;
    margin: 0 auto !important;
    padding: 2mm !important;
    font-family: var(--font-mono), 'Courier New', Courier, monospace !important;
    font-size: 8pt !important;
    line-height: 1.2 !important;
    color: #000000 !important;
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  /* 58mm Printer Specification (Full 100% Width Handheld Mini POS) */
  body.print-mode-thermal-58 #printable-invoice {
    width: 100% !important;
    max-width: 54mm !important;
    margin: 0 auto !important;
    padding: 0 !important;
    font-family: var(--font-mono), 'Courier New', Courier, monospace !important;
    font-size: 7pt !important;
    line-height: 1.15 !important;
    color: #000000 !important;
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  /* Thermal Header Layout Scoped to Printable Container */
  body.print-mode-thermal #printable-invoice .sm\:flex-row,
  body.print-mode-thermal-80 #printable-invoice .sm\:flex-row,
  body.print-mode-thermal-58 #printable-invoice .sm\:flex-row {
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    width: 100% !important;
  }

  body.print-mode-thermal #printable-invoice .sm\:text-right,
  body.print-mode-thermal-80 #printable-invoice .sm\:text-right,
  body.print-mode-thermal-58 #printable-invoice .sm\:text-right {
    text-align: right !important;
  }

  /* 80mm Table Styling */
  body.print-mode-thermal #printable-invoice table,
  body.print-mode-thermal-80 #printable-invoice table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 4px 0 !important;
    table-layout: auto !important;
  }

  /* 58mm Table Styling - 100% Full Width Paper Fit */
  body.print-mode-thermal-58 #printable-invoice table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 4px 0 !important;
    table-layout: fixed !important;
  }

  body.print-mode-thermal #printable-invoice th,
  body.print-mode-thermal #printable-invoice td,
  body.print-mode-thermal-80 #printable-invoice th,
  body.print-mode-thermal-80 #printable-invoice td {
    border-bottom: 1px dashed #000000 !important;
    padding: 3px 1px !important;
    font-size: 7.5pt !important;
    word-break: normal !important;
  }

  body.print-mode-thermal-58 #printable-invoice th,
  body.print-mode-thermal-58 #printable-invoice td {
    border-bottom: 1px dashed #000000 !important;
    padding: 2px 0.5px !important;
    font-size: 6.5pt !important;
    word-break: break-word !important;
    overflow: hidden !important;
  }

  body.print-mode-thermal-58 #printable-invoice th.col-desc,
  body.print-mode-thermal-58 #printable-invoice td.col-desc {
    width: 36% !important;
    text-align: left !important;
  }

  body.print-mode-thermal-58 #printable-invoice th.col-qty,
  body.print-mode-thermal-58 #printable-invoice td.col-qty {
    width: 16% !important;
    text-align: center !important;
  }

  body.print-mode-thermal-58 #printable-invoice th.col-price,
  body.print-mode-thermal-58 #printable-invoice td.col-price {
    width: 24% !important;
    text-align: right !important;
  }

  body.print-mode-thermal-58 #printable-invoice th.col-total,
  body.print-mode-thermal-58 #printable-invoice td.col-total {
    width: 24% !important;
    text-align: right !important;
  }

  body.print-mode-thermal #printable-invoice th,
  body.print-mode-thermal-80 #printable-invoice th,
  body.print-mode-thermal-58 #printable-invoice th {
    font-weight: bold !important;
  }

  /* Single-Line Thermal Invoice Number Badge Guarantee */
  body.print-mode-thermal #printable-invoice .inv-number-badge,
  body.print-mode-thermal-80 #printable-invoice .inv-number-badge {
    font-size: 8pt !important;
    padding: 1.5px 5px !important;
    white-space: nowrap !important;
    display: inline-block !important;
    letter-spacing: -0.2px !important;
    background-color: #000000 !important;
    color: #ffffff !important;
    border-radius: 3px !important;
    margin-bottom: 3px !important;
    max-width: 100% !important;
  }

  body.print-mode-thermal-58 #printable-invoice .inv-number-badge {
    font-size: 6.5pt !important;
    padding: 1px 3px !important;
    white-space: nowrap !important;
    display: inline-block !important;
    letter-spacing: -0.3px !important;
    background-color: #000000 !important;
    color: #ffffff !important;
    border-radius: 2px !important;
    margin-bottom: 2px !important;
    max-width: 100% !important;
  }

  body.print-mode-thermal #printable-invoice img,
  body.print-mode-thermal-80 #printable-invoice img,
  body.print-mode-thermal-58 #printable-invoice img {
    max-width: 16mm !important;
    max-height: 16mm !important;
  }
}
