/* ===========================
   Global Layout + Typography
   =========================== */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background-color: #f9fafb;
  color: #111827;
}

h1, h2, h3 {
  font-weight: 600;
}

/* ===========================
   Invoice Preview Container
   =========================== */
.invoice-preview {
  font-size: 12px;
  line-height: 1.25;
  background: white;
  border-radius: 1rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  padding: 1.5rem;
  margin-bottom: 3rem;
  page-break-inside: avoid;
}

.invoice-preview img {
  max-height: 56px;
}

.invoice-preview .text-sm {
  font-size: 14px;
  line-height: 1.3;
}

/* ===========================
   Invoice Header
   =========================== */
.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: nowrap;
  margin-bottom: 1.25rem;
  gap: 0;
}

.invoice-header > div:first-child {
  flex: 1 1 auto;
  max-width: 60%;
}

.invoice-header .invoice-info-box {
  flex: 0 0 35%;
  max-width: 35%;
  margin-left: auto;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.invoice-info-box table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.invoice-info-box td {
  border: 1px solid #ccc;
  padding: 4px;
  text-align: center;
}

.invoice-info-box thead td {
  background: #f3f4f6;
  font-weight: 600;
}

/* ===========================
   Invoice Table
   =========================== */
.invoice-preview table {
  border-collapse: collapse;
  width: 100%;
}

.invoice-preview th,
.invoice-preview td {
  padding: 2px 4px;
  border: 1px solid #ccc;
  font-size: 12px;
}

.invoice-preview thead th {
  background: #f3f4f6;
  font-weight: 600;
}

.invoice-preview td:nth-child(n + 3) {
  text-align: right;
}

.invoice-preview tbody tr:nth-child(odd) {
  background-color: #fafafa;
}

.invoice-preview .bg-blue-50 {
  background-color: #eff6ff;
}
.invoice-preview .text-blue-800 {
  color: #1e3a8a;
}

/* ===========================
   Buttons
   =========================== */
button {
  cursor: pointer;
  transition: background 0.15s;
}

button:hover {
  opacity: 0.9;
}

.add-row-btn {
  font-size: 12px;
  color: #2563eb;
  border: 1px solid #2563eb;
  background: white;
  border-radius: 4px;
  padding: 2px 6px;
}

/* ===========================
   Totals & Payable Section
   =========================== */
.invoice-preview .payable-section {
  margin-top: 10px;
  padding-top: 5px;
  border-top: 1px solid #ccc;
  text-align: center;
  page-break-inside: avoid;
}

.invoice-preview .payable-section p {
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
}

/* ===========================
   HARD LOCK: Landscape Printing (Chrome + Edge, Letter 8.5x11)
   =========================== */
@media print {
  /* ✅ Force Letter 8.5x11 Landscape */
  @page {
    size: Letter landscape;
    margin: 0.25in;
  }

  html, body {
    width: 100% !important;
    height: 100% !important;
    background: #fff !important;
    color: #000 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    display: block !important;
    contain: none !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* --- Invoice Container --- */
  .invoice-preview {
    width: 100% !important;
    margin: 0 auto 0.4in auto !important; /* spacing between invoices */
    padding: 0.25in !important;
    border: none !important;
    box-shadow: none !important;
    background: #fff !important;
    page-break-inside: avoid !important;
    page-break-before: auto !important;
    page-break-after: auto !important;
  }

  .invoice-preview + .invoice-preview {
    page-break-before: always !important;
  }

  /* --- Invoice Header --- */
  .invoice-header {
    flex-wrap: nowrap !important;
    margin-bottom: 0.15in !important;
  }

  /* --- Table Styling --- */
  table {
    border-collapse: collapse !important;
    width: 100% !important;
  }

  .invoice-preview th,
  .invoice-preview td {
    border-color: #000 !important;
    color: #000 !important;
    padding: 2px 3px !important;
    font-size: 9.5px !important;
    line-height: 1.05 !important;
    vertical-align: middle !important;
  }

  /* --- Footer --- */
  .invoice-footer,
  .invoice-preview .payable-section {
    border-top: 1px solid #000 !important;
    text-align: center !important;
    font-size: 9px !important;
    margin-top: 0.1in !important;
    padding-top: 0.1in !important;
    background: #fff !important;
    width: 100% !important;
    display: block !important;
    page-break-inside: avoid !important;
    page-break-before: avoid !important;
  }

  /* --- Hide UI elements --- */
  h2.text-lg.font-semibold.mb-4,
  #toastContainer,
  .no-print,
  .print\:hidden,
  #openPrintSelector,
  #printSelector,
  button {
    display: none !important;
  }

  /* --- Layout fix for header info box --- */
  .invoice-header > div:first-child {
    flex: 1 1 auto !important;
    max-width: 60% !important;
  }

  .invoice-header .invoice-info-box {
    flex: 0 0 35% !important;
    max-width: 35% !important;
    border: 1px solid #000 !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  .invoice-info-box td,
  .invoice-info-box th {
    border-color: #000 !important;
  }
}


/* ===========================
   Utility Helpers
   =========================== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.bg-white { background: white; }
.shadow { box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.rounded { border-radius: 4px; }
.rounded-2xl { border-radius: 1rem; }
.mb-12 { margin-bottom: 3rem; }
.mt-4 { margin-top: 1rem; }
.p-6 { padding: 1.5rem; }

/* ===========================
   Client Manager Styling
   =========================== */
.client-manager {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  padding: 1.5rem;
  margin-bottom: 3rem;
  font-size: 14px;
}

.client-manager h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 1rem;
}

.client-manager table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  margin-bottom: 1rem;
}

.client-manager th,
.client-manager td {
  border: 1px solid #ccc;
  padding: 6px 8px;
  text-align: left;
}

.client-manager thead th {
  background: #f3f4f6;
  font-weight: 600;
  color: #111;
}

.client-manager tbody tr:nth-child(odd) {
  background: #fafafa;
}

.client-manager input,
.client-manager select {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 4px 8px;
  width: 100%;
  font-size: 13px;
}

.client-manager button {
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.client-manager button:hover {
  opacity: 0.9;
}

.client-manager .btn {
  padding: 5px 10px;
}

.client-manager .btn-blue {
  background: #2563eb;
  color: white;
}

.client-manager .btn-gray {
  background: #f3f4f6;
  border: 1px solid #ccc;
}

.client-manager .saving-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  z-index: 10;
}

.client-manager .border-t {
  border-top: 1px solid #ccc;
  margin-top: 1rem;
  padding-top: 1rem;
}