/* ==========================================================================
   ACS IT — Professional Corporate Invoice & Financial Document Stylesheet
   Executive Obsidian & Metallic Gold Branding — High-Resolution A4 & Mobile
   ========================================================================== */

:root {
  --inv-primary: #070c18;
  --inv-accent: #0284c7;
  --inv-accent-dark: #0369a1;
  --inv-accent-cyan: #00f0ff;
  --inv-text-dark: #0f172a;
  --inv-text-muted: #475569;
  --inv-text-light: #64748b;
  --inv-border: #e2e8f0;
  --inv-bg-light: #f8fafc;
  --inv-bg-subtle: #f1f5f9;
  --inv-paid: #059669;
  --inv-unpaid: #dc2626;
  --inv-partial: #d97706;
  --inv-refund: #9333ea;
  --inv-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --inv-font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
}

body.invoice-body {
  background-color: #060a14;
  background-image: radial-gradient(circle at top right, rgba(14, 165, 233, 0.08) 0%, transparent 60%);
  margin: 0;
  padding: 24px 16px 60px 16px;
  font-family: var(--inv-font-sans);
  color: var(--inv-text-dark);
  min-height: 100vh;
}

/* Print Toolbar */
.doc-print-toolbar {
  max-width: 860px;
  margin: 0 auto 20px auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.doc-print-toolbar .btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.doc-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.doc-btn-back {
  background: rgba(30, 41, 59, 0.8);
  color: #cbd5e1;
  border-color: #334155;
}
.doc-btn-back:hover {
  background: #334155;
  color: #ffffff;
}

.doc-btn-pdf {
  background: #0284c7;
  color: #ffffff;
  border-color: #0369a1;
}
.doc-btn-pdf:hover {
  background: #0ea5e9;
  transform: translateY(-1px);
}

.doc-btn-jpg {
  background: #0891b2;
  color: #ffffff;
  border-color: #0e7490;
}
.doc-btn-jpg:hover {
  background: #06b6d4;
  transform: translateY(-1px);
}

/* Master Invoice Wrapper (A4 Dimensions) */
.invoice-wrapper {
  background: #ffffff;
  color: var(--inv-text-dark);
  max-width: 850px;
  margin: 0 auto;
  padding: 44px 48px;
  border-radius: 8px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(212, 175, 55, 0.2);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

/* Subtle Watermark Backdrop */
.invoice-watermark-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 440px;
  height: 440px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
  user-select: none;
  z-index: 1;
  filter: grayscale(20%);
}

.invoice-watermark-text {
  position: absolute;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 5rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 14px;
  pointer-events: none;
  user-select: none;
  z-index: 1;
  opacity: 0.05;
  white-space: nowrap;
}

.watermark-paid { color: var(--inv-paid); }
.watermark-unpaid { color: var(--inv-unpaid); }
.watermark-partially-paid { color: var(--inv-partial); }
.watermark-refunded { color: var(--inv-refund); }

/* Document Content Layer */
.doc-content-layer {
  position: relative;
  z-index: 2;
}

/* Document Header */
.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 24px;
  border-bottom: 2px solid #0f172a;
  margin-bottom: 24px;
}

.doc-brand-block {
  display: flex;
  align-items: center;
  gap: 16px;
}

.doc-logo-img {
  height: 46px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  border-radius: 0;
  border: none;
  padding: 0;
  background: transparent;
}

.doc-brand-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: #0a0e17;
  letter-spacing: -0.5px;
  margin: 0;
  line-height: 1.2;
}

.doc-brand-subtitle {
  font-size: 0.8rem;
  font-weight: 700;
  color: #d4af37;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 2px;
}

.doc-org-meta {
  font-size: 0.8rem;
  color: var(--inv-text-muted);
  line-height: 1.45;
  margin-top: 5px;
}

.doc-type-block {
  text-align: right;
}

.doc-type-badge {
  display: inline-block;
  font-size: 1.25rem;
  font-weight: 900;
  color: #ffffff;
  background: #0a0e17;
  padding: 6px 18px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  border-left: 4px solid #d4af37;
  margin-bottom: 6px;
}

.doc-num-display {
  font-family: var(--inv-font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
}

.doc-num-display span {
  color: #d4af37;
}

/* Metadata Grid */
.doc-meta-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 28px;
  margin-bottom: 24px;
  background: var(--inv-bg-light);
  padding: 16px 20px;
  border-radius: 6px;
  border: 1px solid var(--inv-border);
}

.meta-heading {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--inv-text-light);
  margin-bottom: 6px;
  border-bottom: 1px solid var(--inv-border);
  padding-bottom: 3px;
}

.meta-client-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: #0a0e17;
  margin-bottom: 4px;
}

.meta-client-info {
  font-size: 0.84rem;
  color: var(--inv-text-muted);
  line-height: 1.5;
}

.meta-table {
  width: 100%;
  font-size: 0.84rem;
  border-collapse: collapse;
}

.meta-table td {
  padding: 3px 0;
}

.meta-label {
  color: var(--inv-text-light);
  font-weight: 600;
}

.meta-val {
  text-align: right;
  font-weight: 700;
  color: #0f172a;
}

/* Document Items Table */
.doc-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.doc-items-table th {
  background: #0a0e17;
  color: #ffffff;
  text-align: left;
  padding: 10px 14px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-top: 2px solid #d4af37;
}

.doc-items-table th:last-child {
  text-align: right;
}

.doc-items-table td {
  padding: 11px 14px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--inv-border);
  color: var(--inv-text-dark);
}

.doc-items-table tr:nth-child(even) {
  background: var(--inv-bg-light);
}

.doc-items-table td:last-child {
  text-align: right;
  font-family: var(--inv-font-mono);
  font-weight: 700;
}

/* Summary Grid */
.doc-summary-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  margin-bottom: 28px;
}

.doc-payment-box {
  background: var(--inv-bg-light);
  padding: 14px 16px;
  border-radius: 6px;
  border: 1px solid var(--inv-border);
  font-size: 0.82rem;
  color: var(--inv-text-muted);
}

.doc-payment-box strong {
  color: #0a0e17;
}

.calc-table {
  width: 100%;
  font-size: 0.86rem;
  border-collapse: collapse;
}

.calc-table td {
  padding: 5px 8px;
}

.calc-label {
  color: var(--inv-text-muted);
  font-weight: 600;
}

.calc-val {
  text-align: right;
  font-weight: 700;
  font-family: var(--inv-font-mono);
}

.calc-total-row {
  border-top: 2px solid #0f172a;
  border-bottom: 2px solid #0f172a;
  font-size: 1rem;
  font-weight: 900;
  color: #0a0e17;
}

.calc-total-row td {
  padding: 8px 8px;
}

.calc-paid-row td {
  color: var(--inv-paid);
  font-weight: 800;
}

.calc-due-row {
  background: #fef2f2;
  border-radius: 4px;
}

.calc-due-row td {
  color: var(--inv-unpaid);
  font-weight: 900;
  font-size: 0.95rem;
  padding: 7px 8px;
}

/* Footer & Signatures */
.doc-footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: flex-end;
  padding-top: 20px;
  border-top: 1px dashed var(--inv-border);
  margin-top: 10px;
}

.doc-verify-stamp {
  display: flex;
  align-items: center;
  gap: 12px;
}

.qr-box {
  width: 62px;
  height: 62px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  padding: 2px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.verify-text {
  font-size: 0.74rem;
  color: var(--inv-text-light);
  line-height: 1.4;
}

.verify-text strong {
  color: #0a0e17;
  font-size: 0.8rem;
}

.signature-block {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  margin-left: auto;
  min-width: 190px;
}

.signature-img {
  max-height: 54px;
  max-width: 175px;
  width: auto;
  object-fit: contain;
  margin-bottom: -3px;
  display: block;
  filter: contrast(1.1);
}

.signature-line {
  width: 190px;
  height: 1.5px;
  background: #0f172a;
  margin: 2px 0 6px auto;
}

.signatory-name {
  font-size: 0.92rem;
  font-weight: 800;
  color: #0a0e17;
  letter-spacing: 0.2px;
}

.signatory-title {
  font-size: 0.74rem;
  color: #475569;
  font-weight: 600;
}

.doc-bottom-note {
  margin-top: 22px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--inv-text-light);
  border-top: 1px solid var(--inv-border);
  padding-top: 10px;
}

/* Mobile & Print Optimization */
@media screen and (max-width: 680px) {
  .invoice-wrapper {
    padding: 24px 18px;
  }
  .doc-header {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }
  .doc-type-block {
    text-align: left;
  }
  .doc-meta-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .doc-summary-grid {
    grid-template-columns: 1fr;
  }
  .doc-footer-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .signature-block {
    text-align: left;
  }
  .signature-line {
    margin: 4px 0 6px 0;
  }
}

/* High-Resolution A4 Print Styles */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }
  body.invoice-body {
    background: #ffffff !important;
    padding: 0 !important;
  }
  .doc-print-toolbar {
    display: none !important;
  }
  .invoice-wrapper {
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
  }
}
