/* ===== KSeFeusz.pl - invoice.css - wersja 1.6.18 (2026-06-01) ===== */
/* Style podglądu faktury HTML oraz drukowania */

/* ===== KONTENER FAKTURY ===== */
.invoice-container {
  width: 794px;
  margin: 10px auto;
  background: #fff;
  padding: 15px 15px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid #e0e7ef;
}

.row-details-placeholder {
  display: none;
  padding: 6px 10px;
  background: #f8f9fa;
  border: 1px dashed #bdc3c7;
  border-radius: 4px;
  font-size: 10px;
  color: #95a5a6;
  font-style: italic;
  margin: 4px 0;
}

#pages.hide-row-details .row-details-placeholder {
  display: block;
}

/* ===== STYLE FAKTURY ===== */
.invoice-container header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  border-bottom: 2px solid #3498db;
  padding-bottom: 5px;
}

.invoice-container h1 {
  font-size: 20px;
  margin: 0;
  color: #2c3e50;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.invoice-container h2 {
  font-size: 14px;
  margin: 0 0 4px 0;
  border-bottom: 1px solid #bdc3c7;
  padding-bottom: 4px;
  color: #34495e;
  font-weight: 600;
}

.section {
  font-size: 10px;
  margin-bottom: 5px;
}

.two-cols {
  display: flex;
  gap: 5px;
}

.col {
  flex: 1 1 0;
  min-width: 0; /* bez tego flex item nie zejdzie poniżej szerokości treści (długi e-mail/nazwa) i rozjeżdża 50/50 */
  overflow-wrap: anywhere; /* zawijaj długie nierozdzielne tokeny zamiast rozpychać kolumnę */
}

.invoice-container table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  margin: 5px 0 15px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.invoice-container th,
.invoice-container td {
  border: 1px solid #bdc3c7;
  padding: 2px;
}

.invoice-container th {
  background: #ecf0f1;
  font-weight: 600;
  color: #2c3e50;
  text-align: center;
}

.invoice-container td {
  vertical-align: top;
  color: #000000;
}

.invoice-container td small {
  font-size: 9px;
  color: #666;
  font-style: italic;
}

.right {
  text-align: right;
}

.center {
  text-align: center;
}

.diff-row {
  background: #f9f9f9;
  font-style: italic;
}

.before-row {
  background: #fef5e7;
}

.invoice-container .vat-summary {
  margin-top: 5px;
  width: 50%;
  margin-left: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.invoice-container .vat-summary th {
  background: #d5dbdb;
  text-align: right;
}

.invoice-container .vat-summary th:first-child {
  text-align: left;
}

#pages.hide-row-details .row-details-section {
  display: none !important;
}

.additional-info {
  margin-top: 5px;
  font-size: 9px;
  border-top: 2px dashed #bdc3c7;
  padding-top: 5px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 5px;
}

.info-item {
  border: 1px solid #e0e0e0;
  padding: 2px;
  padding-left: 5px;
  background: #fafafa;
  border-radius: 3px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
}

.info-label {
  font-weight: bold;
  color: #2c3e50;
  font-size: 10px;
  text-transform: uppercase;
  min-width: auto;
  white-space: nowrap;
}

/* Style dla załączników */
.zalacznik-tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  margin: 10px 0;
}

.zalacznik-tabela th {
  border: 1px solid #bdc3c7;
  padding: 4px;
  background: #ecf0f1;
  font-weight: 600;
}

.zalacznik-tabela td {
  border: 1px solid #bdc3c7;
  padding: 4px;
}

.zalacznik-opis {
  font-weight: bold;
  margin: 10px 0 5px 0;
  color: #2c3e50;
}

.zalacznik-akapit {
  margin: 5px 0;
  font-size: 11px;
  line-height: 1.4;
}

.footer-section-invoice {
  margin-top: 5px;
  font-size: 11px;
  border-top: 2px solid #bdc3c7;
  padding-top: 5px;
  background: #f8f9f9;
  border-radius: 0 0 4px 4px;
}

.footer-content-invoice {
  padding: 8px 5px;
  line-height: 1.6;
}

.footer-line {
  padding: 0px 0;
  border-bottom: 1px dotted #ccc;
}

.footer-line:last-child {
  border-bottom: none;
}

.footer-label {
  font-weight: bold;
  color: #34495e;
  display: inline-block;
  min-width: 110px;
}

.znacznik {
  padding: 1px 1px;
  font-size: 8px;
  color: #555555;
  margin: 1px;
}

.current-file-info {
  color: #000000;
  font-weight: 500;
  background: #ecf0f1;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qr-section {
  margin-top: 5px;
  margin-bottom: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-top: 2px solid #3498db;
  padding-top: 5px;
}

.schema-warning {
  background: #fdf3f2;
  border: 1px solid #e74c3c;
  border-left: 4px solid #e74c3c;
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 12px;
  color: #5d2e2e;
  max-width: 700px;
  text-align: left;
}

.correction-mismatch {
  background: #fff8e6;
  border: 1px solid #e67e22;
  border-left: 4px solid #e67e22;
  border-radius: 4px;
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 12px;
  color: #5b3a1a;
  max-width: 700px;
}

.correction-mismatch strong {
  display: block;
  color: #b9521a;
  margin-bottom: 4px;
  font-size: 13px;
}

.correction-mismatch p {
  margin: 4px 0 8px;
}

.correction-mismatch table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0;
  box-shadow: none;
  font-size: 12px;
}

.correction-mismatch th,
.correction-mismatch td {
  padding: 4px 8px;
  border: 1px solid #f0c890;
  background: #fffdf6;
}

.correction-mismatch th {
  background: #fff2d9;
  text-align: left;
}

.correction-mismatch .right {
  text-align: right;
}

.correction-mismatch small {
  display: block;
  margin-top: 6px;
  color: #6b4a22;
  opacity: 0.85;
}

.schema-warning strong {
  display: block;
  color: #c0392b;
  margin-bottom: 4px;
  font-size: 13px;
}

.unknown-elements-list {
  margin-top: 8px;
}

.unknown-element-xml {
  background: #fff5f5;
  border: 1px solid #f5c6cb;
  border-radius: 3px;
  padding: 6px 10px;
  font-size: 10px;
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 4px 0 0 0;
  color: #7b241c;
}

/* ===== PAYMENT CONTAINER (dane do przelewu) ===== */
.payment-container {
  width: 794px;
  margin: 6px auto 10px;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid #d5e8f8;
  overflow: hidden;
  font-size: 13px;
}

.payment-toggle-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: #2980b9;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s;
  letter-spacing: 0.01em;
}

.payment-toggle-btn:hover {
  background: #2471a3;
}

.payment-toggle-btn.open {
  background: #1f618d;
  border-bottom-color: #d5e8f8;
}

.payment-toggle-arrow {
  margin-left: auto;
  font-size: 16px;
  opacity: 0.85;
}

.payment-box {
  display: none;
  padding: 14px 15px;
  gap: 20px;
}

.payment-box.open {
  display: flex;
  align-items: flex-start;
}

.payment-fields {
  flex: 1;
}

.payment-field-row {
  display: flex;
  align-items: center;
  margin-bottom: 9px;
  gap: 8px;
}

.payment-field-label {
  font-size: 11px;
  color: #7f8c8d;
  min-width: 90px;
}

.payment-field-value {
  flex: 1;
  color: #2c3e50;
  font-size: 13px;
}

.payment-nrb {
  font-family: monospace;
  letter-spacing: 0.5px;
}

.payment-field-copy {
  background: #3498db;
  color: #fff;
  border: none;
  border-radius: 3px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background 0.15s;
}

.payment-field-copy:hover {
  background: #2980b9;
}

.payment-field-copy.copied {
  background: #27ae60;
}

.payment-bl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 98px;
  margin-top: -4px;
  margin-bottom: 9px;
}

.payment-bl-check {
  background: #1abc9c;
  color: #fff;
  border: none;
  border-radius: 3px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background 0.15s;
}

.payment-bl-check:hover {
  background: #16a085;
}

.payment-bl-check:disabled {
  opacity: 0.5;
  cursor: default;
}

.payment-bl-result {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.payment-bl-result.loading { color: #7f8c8d; }
.payment-bl-result.ok      { color: #27ae60; }
.payment-bl-result.fail    { color: #e74c3c; }
.payment-bl-result.error   { color: #e67e22; }

.payment-qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-left: 20px;
  border-left: 1px solid #eaf4fd;
  min-width: 175px;
}

.payment-qr-label {
  margin-top: 6px;
  font-size: 10px;
  color: #7f8c8d;
  text-align: center;
  line-height: 1.5;
}

@media print {
  .payment-container { display: none; }
}

@media (max-width: 768px) {
  .payment-container { width: 100%; border-radius: 0; margin: 4px 0 8px; }
  .payment-box.open { flex-direction: column; }
  .payment-qr-section { border-left: none; border-top: 1px solid #eaf4fd; padding-left: 0; padding-top: 12px; margin-top: 4px; min-width: unset; }
}

.qr-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  background: white;
  padding: 5px 5x;
  border-radius: 10px;
  border: 1px solid #bdc3c7;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  width: fit-content;
  margin: 0 auto;
  max-width: 100%;
}

.qr-code {
  width: 180px !important;
  height: 180px !important;
  background: white;
  padding: 5px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  flex-shrink: 0;
}

.qr-info {
  font-size: 10px;
  color: #2c3e50;
  text-align: left;
  max-width: 400px;
}

.qr-info strong {
  font-size: 12px;
  display: block;
  color: #2c3e50;
  margin-bottom: 5px;
}

.qr-info small {
  color: #7f8c8d;
  font-size: 10px;
  display: block;
  margin-top: 5px;
}

.qr-hash {
  font-family: monospace;
  background: #f0f0f0;
  padding: 6px 5px;
  border-radius: 4px;
  font-size: 10px;
  word-break: break-all;
  margin: 5px 0;
}

.qr-link {
  margin-top: 5px;
}

.qr-link a {
  color: #3498db;
  text-decoration: none;
  font-weight: bold;
  word-break: break-all;
  font-size: 10px;
}

.qr-link a:hover {
  text-decoration: underline;
}

/* ===== WIDOK UPROSZCZONY / PEŁNY ===== */
.invoice-container.simplified .hide-in-simplified {
  display: none !important;
}

/* Poprawka dla ikon kontaktowych - wyrównanie w linii */
.panel .col div[style*="display: flex"] i,
.invoice-container .col div[style*="display: flex"] i {
  line-height: 1;
  vertical-align: middle;
  margin-right: 2px;
}

.panel .col div[style*="display: flex"] span,
.invoice-container .col div[style*="display: flex"] span {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.no-break {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
}

/* Dla mniejszych ekranów pozwól na zawijanie */
@media (max-width: 768px) {
  .panel .col div[style*="display: flex"],
  .invoice-container .col div[style*="display: flex"] {
    flex-wrap: wrap;
  }

  .panel .col div[style*="display: flex"] span,
  .invoice-container .col div[style*="display: flex"] span {
    white-space: normal;
  }
}

/* ===== STYLE DRUKOWANIA - TYLKO FAKTURA! ===== */
@page {
  size: A4;
  margin-top: 10mm;
  margin-bottom: 10mm;
  margin-left: 0mm;
  margin-right: 0mm;
}

@page :first {
  margin-top: 0mm;
}

@media print {
  /* UKRYJ WSZYSTKO */
  body * {
    visibility: hidden !important;
  }

  /* POKAŻ TYLKO FAKTURĘ I JEJ ELEMENTY */
  .invoice-container,
  .invoice-container * {
    visibility: visible !important;
  }

  /* ZAWSZE DRUKUJ PEŁNĄ FAKTURĘ — niezależnie od trybu widoku uproszczonego */
  .invoice-container.simplified .hide-in-simplified {
    display: block !important;
  }
  /* Dodatkowe info dla wierszy: respektuj wybór użytkownika — jeśli ukryte, nie drukuj */

  /* USTAWIENIA DLA FAKTURY */
  .invoice-container {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 25px !important;
    box-shadow: none !important;
    background: white !important;
    border: none !important;
    border-radius: 0 !important;
  }

  /* USUŃ TŁO Z NAGŁÓWKA FAKTURY */
  .invoice-container header {
    border-bottom: 2px solid #3498db !important;
  }

  /* ZACHOWAJ KOLORY WIERSZY KOREKT */
  .diff-row,
  .before-row {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .qr-container {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 25px !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 10px 15px !important;
    box-sizing: border-box !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .qr-code {
    width: 180px !important;
    height: 180px !important;
    flex-shrink: 0 !important;
  }

  .qr-info {
    flex: 1 !important;
    max-width: none !important;
    text-align: left !important;
  }

  tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* Nagłówki tabel na górze strony */
  thead {
    display: table-header-group !important;
  }

  /* Stopki tabel na dole strony */
  tfoot {
    display: table-footer-group !important;
  }

  /* Zapobiega osieroconym nagłówkom */
  h2, h3 {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  /* ZACHOWAJ CZARNY KOLOR TEKSTU */
  td,
  th,
  .info-item,
  .footer-content-invoice,
  .qr-info,
  .qr-link a,
  .invoice-container h1,
  .invoice-container h2,
  .invoice-container .section,
  .invoice-container .col,
  .invoice-container strong,
  .invoice-container small {
    color: #000000 !important;
    background: transparent !important;
  }

  /* USUŃ PODKREŚLENIA Z LINKÓW */
  .qr-link a {
    text-decoration: none !important;
  }

  /* CZCIONKA */
  body,
  .invoice-container,
  .section,
  table,
  th,
  td {
    font-family: Arial, sans-serif !important;
  }

  /* DODATKOWE ZABEZPIECZENIE - UKRYJ RESZTĘ */
  .main-header,
  .tabs-container,
  .main-footer,
  .upload-area,
  .file-info,
  .panel:not(.active),
  .panel.active:not(:has(.invoice-container)),
  .error-message,
  .security-badge,
  .logo-area,
  .site-title,
  .tabs,
  .tab,
  .info-card,
  .feature-list,
  .steps,
  .footer-content,
  .footer-section,
  .copyright,
  .icon:not(.invoice-container .icon) {
    display: none !important;
  }

  .vat-summary,
  .info-grid,
  .qr-section,
  .qr-container,
  .footer-section-invoice {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .two-cols {
    display: flex !important;
    flex-direction: row !important;
    gap: 5px !important;
  }

  .col {
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 0 !important; /* twarde 50/50 także na druku */
    overflow-wrap: anywhere !important;
  }

  .vat-summary {
    width: 50% !important;
    margin-left: auto !important;
    margin-right: 0 !important;
  }

  .vat-summary table {
    width: 100% !important;
  }

  .info-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 5px !important;
    margin-top: 5px !important;
  }

  .info-item {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: baseline !important;
    gap: 4px !important;
    border: 1px solid #e0e0e0 !important;
    padding: 2px 2px 2px 5px !important;
    background: #fafafa !important;
    border-radius: 3px !important;
    page-break-inside: avoid !important;
  }

  .info-label {
    font-weight: bold !important;
    color: #2c3e50 !important;
    font-size: 10px !important;
    text-transform: uppercase !important;
    white-space: nowrap !important;
  }

  .info-item small {
    display: block !important;
    color: #666 !important;
    font-size: 10px !important;
    margin-top: 3px !important;
  }

  .additional-info h2,
  .additional-info h3 {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  table {
    page-break-inside: auto !important;
  }

  tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .info-grid {
    page-break-inside: avoid !important;
  }
}

/* ============================================================
   UPO — wizualizacja dokumentu HTML
   ============================================================ */

.upo-container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 0 40px;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 13px;
  color: #222;
}

.upo-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 2px solid #1A3E5F;
}
.upo-header h1 {
  font-size: 19px; font-weight: 700; color: #1A3E5F;
  margin: 0 0 4px; letter-spacing: 0.3px;
}
.upo-subtitle { font-size: 11px; color: #666; }

.upo-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.upo-card {
  border: 1px solid #D0DFE8; border-radius: 6px;
  padding: 10px 14px; background: #FAFCFE;
}
.upo-card-full { grid-column: 1 / -1; }
.upo-card-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.8px;
  color: #2B6CB0; margin-bottom: 5px; text-transform: uppercase;
}
.upo-card-value { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.upo-card-row {
  display: flex; gap: 8px; margin-top: 4px;
  font-size: 12px; color: #444; align-items: baseline;
}
.upo-card-row span:first-child { color: #666; white-space: nowrap; flex-shrink: 0; }
.upo-nr-sesji { font-family: 'Courier New', monospace; font-size: 11px; color: #333; word-break: break-all; flex: 1; min-width: 0; }
.upo-hash { font-family: 'Courier New', monospace; font-size: 10px; color: #555; word-break: break-all; flex: 1; min-width: 0; }

.upo-docs-section { margin-top: 18px; }
.upo-section-header {
  font-size: 13px; font-weight: 700; color: #1A3E5F;
  background: #EBF2FA; padding: 8px 14px;
  border-radius: 6px 6px 0 0; border: 1px solid #C5D8EA; border-bottom: none;
  display: flex; align-items: center; gap: 10px;
}
.upo-count-badge {
  font-size: 11px; background: #2B6CB0; color: #fff;
  padding: 1px 8px; border-radius: 20px; font-weight: 600;
}
.upo-table-wrap {
  overflow-x: auto;
  border: 1px solid #C5D8EA;
  border-radius: 0 0 6px 6px;
}
.upo-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.upo-table th {
  background: #F4F8FC; padding: 7px 10px; text-align: left;
  font-size: 11px; font-weight: 700; color: #444;
  border-bottom: 1px solid #C5D8EA; white-space: nowrap;
}
.upo-table td { padding: 7px 10px; border-bottom: 1px solid #EEF2F6; vertical-align: top; }
.upo-table tr:last-child td { border-bottom: none; }
.upo-table tr:hover td { background: #F8FBFE; }
.upo-nr-ksef { font-family: 'Courier New', monospace; font-size: 10px; color: #333; }
.upo-hash-cell {
  font-family: 'Courier New', monospace; font-size: 10px; color: #666;
  word-break: break-all;
}
.upo-badge {
  display: inline-block; padding: 1px 7px; border-radius: 3px;
  font-size: 10px; font-weight: 600;
}
.upo-badge-online  { background: #EBF8F2; color: #27AE60; }
.upo-badge-offline { background: #F5F5F5; color: #777; }

.upo-footer-note { margin-top: 22px; text-align: center; font-size: 10px; color: #aaa; }

@media (max-width: 768px) {
  .upo-info-grid { grid-template-columns: 1fr; }
  .upo-header { flex-direction: column; gap: 6px; }
}
