/* Professional Quote PDF Print Stylesheet */

/* Page setup */
@page {
  margin: 20mm 15mm;
  size: A4;
}

/* Hide UI elements not needed in PDF */
.sidebar,
.sidebar-toggle,
.page-top-bar,
.page-header,
header,
.ingest,
.ingest-header,
.ingest-controls,
.existing,
.table-actions,
.save,
#btn-add-item,
#btn-save,
#btn-print,
#btn-show-form,
.hint,
.logo-upload,
.logo-preview {
  display: none !important;
}

/* Reset page layout for print */
body {
  color: #000;
  background: #fff;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 11pt;
  line-height: 1.5;
  margin: 0;
  padding: 0;
}

.layout {
  display: block;
  min-height: auto;
}

.page {
  display: block;
}

.page-inner {
  max-width: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}

/* Always show quote form */
.quote-form {
  display: block !important;
  margin: 0;
  padding: 0;
}

/* Quote header with logo */
.quote-header {
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 30px;
  margin-bottom: 30px;
  page-break-after: avoid;
  page-break-inside: avoid;
}

.quote-logo {
  display: block !important;
  max-width: 150px;
  max-height: 100px;
  object-fit: contain;
}

.quote-logo[hidden] {
  display: none !important;
}

/* Quote title for print */
.quote-title {
  display: block !important;
  font-size: 24pt;
  font-weight: 700;
  color: #000;
  margin: 0;
  padding: 0 0 15px 0;
  border-bottom: 4px solid #000;
  text-transform: uppercase;
  letter-spacing: 2px;
  page-break-after: avoid;
  flex: 1;
}

/* Professional header with company and customer info */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 30px;
  page-break-inside: avoid;
}

.grid > div {
  padding: 0;
}

.subtle {
  color: #333;
  font-size: 10pt;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  border-bottom: 2px solid #000;
  padding-bottom: 4px;
}

.grid input,
.grid textarea {
  border: none;
  padding: 0;
  margin: 4px 0;
  font-size: 10pt;
  line-height: 1.6;
  color: #000;
  background: transparent;
  display: block;
  width: 100%;
  font-family: inherit;
}

.grid input {
  font-weight: 500;
}

.grid textarea {
  min-height: auto;
  resize: none;
  white-space: pre-wrap;
  overflow: hidden;
}

/* Block titles */
.block-title {
  font-size: 14pt;
  font-weight: 700;
  color: #000;
  margin: 30px 0 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 3px solid #000;
  padding-bottom: 8px;
  page-break-after: avoid;
}

.block-title:first-child {
  margin-top: 0;
}

/* Hide "Informations générales" and "Lignes" titles in print */
.quote-form > :nth-child(2),
.quote-form > :nth-child(5) {
  display: none;
}

/* Metadata section */
.meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin: 20px 0 30px;
  padding: 15px;
  background: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 4px;
  page-break-inside: avoid;
}

.meta label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 9pt;
  color: #666;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.meta input {
  border: none;
  padding: 6px 0;
  font-size: 10pt;
  color: #000;
  background: transparent;
  font-weight: 500;
  font-family: inherit;
}

/* Table styling */
.table-container {
  margin: 20px 0;
  page-break-inside: auto;
  overflow: visible;
  border-radius: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  background: #fff;
  page-break-inside: auto;
}

thead {
  background: #000;
  color: #fff;
}

thead th {
  background: #000;
  color: #fff;
  font-weight: 700;
  font-size: 10pt;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 10px;
  text-align: left;
  border: none;
}

thead th:first-child {
  width: 50%;
}

thead th:nth-child(2) {
  width: 10%;
  text-align: center;
}

thead th:nth-child(3) {
  width: 15%;
  text-align: right;
}

thead th:nth-child(4) {
  width: 15%;
  text-align: right;
}

thead th:last-child {
  width: 10%;
  text-align: right;
}

tbody tr {
  page-break-inside: avoid;
  page-break-after: auto;
  border-bottom: 1px solid #e0e0e0;
}

tbody tr:last-child {
  border-bottom: 2px solid #000;
}

th, td {
  border: none;
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

td {
  font-size: 10pt;
  color: #000;
}

td:first-child {
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

td:nth-child(2) {
  text-align: center;
}

td:nth-child(3),
td:nth-child(4),
td:last-child {
  text-align: right;
}

td input {
  border: none;
  padding: 0;
  width: 100%;
  font-size: 10pt;
  color: #000;
  background: transparent;
  font-family: inherit;
}

td textarea.desc {
  display: none;
}

td .desc-print {
  display: block;
  font-weight: 400;
  font-size: 10pt;
  line-height: 1.5;
  color: #000;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

td input.qty {
  text-align: center;
  font-weight: 500;
  width: 100%;
}

td input.pu {
  text-align: right;
  font-weight: 500;
  width: 100%;
}

td .total {
  font-weight: 600;
  color: #000;
}

td .rm {
  display: none;
}

/* Totals section */
.totals {
  margin: 25px 0 20px auto;
  max-width: 300px;
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  page-break-inside: avoid;
}

.totals div {
  display: flex;
  justify-content: space-between;
  padding: 8px 15px;
  margin: 0;
  font-size: 11pt;
  color: #000;
  border-bottom: 1px solid #e0e0e0;
}

.totals div:first-child {
  border-top: 2px solid #000;
}

.totals .grand {
  background: #000;
  color: #fff;
  font-weight: 700;
  font-size: 14pt;
  padding: 12px 15px;
  margin-top: 5px;
  border: none;
  border-radius: 2px;
}

.totals span {
  font-weight: 600;
}

/* Notes section */
.notes {
  margin-top: 30px;
  page-break-inside: avoid;
}

.notes textarea {
  border: 1px solid #ddd;
  padding: 15px;
  width: 100%;
  min-height: auto;
  font-size: 10pt;
  line-height: 1.6;
  color: #000;
  background: #f8f8f8;
  font-family: inherit;
  resize: none;
  border-radius: 4px;
}

/* Print optimization */
* {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  color-adjust: exact;
}

/* Prevent page breaks in critical sections */
.grid,
.meta,
.totals,
.notes {
  page-break-inside: avoid;
}

/* Ensure proper page breaks */
table tbody tr {
  page-break-inside: avoid;
}

/* Remove button styles for any remaining buttons */
button {
  display: none !important;
}
