/* General Body and Page Setup */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

body {
  background-color: #f3f4f6;
  font-family: 'Poppins', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@page {
  size: A4;
  margin: 20mm; /* Add margins for printing */
}

.print-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem;
  box-sizing: border-box;
}

.document-container {
  width: 210mm;
  min-height: 297mm;
  padding: 25mm 20mm;
  box-sizing: border-box;
  background: white;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  position: relative;
  display: flex;
  flex-direction: column;
}

.bookmark-icon {
  position: absolute;
  top: 0;
  right: 30mm;
  color: #1a73e8;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.1));
}


/* Header */
.document-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  border-bottom: 2px solid #1a73e8;
  padding-bottom: 1.5rem;
  page-break-after: auto;
}

.logo-container {
  flex: 1;
}

.logo {
  max-width: 150px;
  max-height: 70px;
  object-fit: contain;
}

.company-name-fallback {
  font-size: 1.5rem;
  font-weight: 700;
  color: #333;
}

.document-info {
  text-align: right;
  flex-shrink: 0;
}

.document-type {
  font-size: 2.2rem;
  font-weight: 700;
  color: #1a73e8;
  margin: 0;
  text-transform: uppercase;
}

.document-number, .document-date {
  font-size: 0.9rem;
  color: #555;
  margin: 2px 0;
}

/* Addresses Section */
.addresses-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2.5rem;
  page-break-inside: avoid;
}

.address-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #1a73e8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 0.25rem;
}

.address-card {
  font-size: 0.85rem;
  color: #444;
  line-height: 1.6;
}

.address-card .contact-name {
  font-weight: 600;
  font-size: 1rem;
  color: #000;
}
.address-card p {
  margin: 2px 0;
}

/* Main Body - Items Table */
.document-body {
  flex-grow: 1;
}

.line-items-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 1rem;
}

.line-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2rem;
  page-break-inside: auto; /* Allow table to break */
}

.line-items-table th, .line-items-table td {
  padding: 0.75rem;
  text-align: left;
  font-size: 0.9rem;
  border-bottom: 1px solid #e0e0e0;
}

.line-items-table th {
  font-weight: 600;
  color: #fff;
  background-color: #333;
}

.line-items-table thead {
  display: table-header-group; /* Repeat header on each page */
}

.line-items-table tr {
  page-break-inside: avoid; /* Avoid breaking rows */
  page-break-after: auto;
}

.line-items-table .table-header-bg {
    background-color: #2c3e50;
}

.line-items-table .text-right {
  text-align: right;
}
.line-items-table .text-center {
  text-align: center;
}

.line-items-table tbody tr:last-child td {
  border-bottom: none;
}

.line-items-table tbody tr:nth-child(even) {
  background-color: #f9f9f9;
}

/* Summary Section (Totals & Notes) */
.summary-section {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-top: auto;
  padding-top: 1rem;
  page-break-before: auto;
  page-break-inside: avoid;
}

.summary-details {
  flex-grow: 1;
}

.total-in-words-container {
  font-size: 0.85rem;
  color: #555;
  padding: 0.75rem;
  background: #f9f9f9;
  border-left: 3px solid #1a73e8;
}

.total-in-words-container p {
  font-style: italic;
  margin: 0;
  margin-top: 4px;
}

.totals-wrapper {
  width: 45%;
  flex-shrink: 0;
}

.totals-table {
  width: 100%;
  font-size: 0.95rem;
}
.totals-table td {
  padding: 0.5rem 0.75rem;
}
.totals-table td:last-child {
  text-align: right;
  font-weight: 600;
}
.totals-table tr.totals-highlight-row td {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  background-color: #1a73e8;
  border-top: 2px solid #1a73e8;
  border-bottom: 2px solid #1a73e8;
}

.totals-table tr.font-bold td {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    background-color: #2c3e50;
}

.notes-and-payment {
  margin-top: 2rem;
}

.notes-title {
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 0.5rem;
}
.notes-and-payment p {
  font-size: 0.85rem;
  color: #555;
}

/* Signature Section */
.signature-section-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e0e0e0;
  page-break-inside: avoid;
}

.signature-block .title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.signature-box {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.signature-line {
  border-top: 1px solid #555;
  margin-top: 0.5rem;
}
.signature-details {
  font-size: 0.8rem;
  color: #444;
}
.signature-details p {
    margin: 3px 0;
}


/* Footer & Page Number */
.document-footer {
  position: absolute;
  bottom: 10mm;
  left: 20mm;
  right: 20mm;
  text-align: center;
  font-size: 0.75rem;
  color: #888;
  border-top: 1px solid #e0e0e0;
  padding-top: 0.5rem;
}
.document-footer p {
  margin: 0;
}

.page-number {
  position: absolute;
  bottom: 10mm;
  right: 20mm;
  font-size: 0.8rem;
  color: #888;
}

/* Service Offer Specific */
.service-offer-content {
    line-height: 1.7;
    font-size: 0.95rem;
    page-break-inside: auto;
}
.service-offer-content h1, .service-offer-content h2, .service-offer-content p, .service-offer-content ul {
    page-break-after: avoid;
    page-break-inside: avoid;
}
.service-offer-content h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1a73e8;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.5rem;
}
.service-offer-content h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}
.service-offer-content p {
    margin-bottom: 1rem;
}
.service-offer-content ul {
    list-style-type: disc;
    padding-left: 20px;
    margin-bottom: 1rem;
}
.service-offer-content strong {
    font-weight: 600;
}

/* Print-specific Styles */
@media print {
  html, body {
    width: 210mm;
    height: 297mm;
    background-color: white;
  }
  .print-container {
    padding: 0;
    margin: 0;
  }
  .document-container {
    box-shadow: none;
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 0;
    height: auto;
  }
  .bookmark-icon {
    display: none;
  }
}