/* ===================== Invoice Overlay Component =====================
   All styles are prefixed with .invoice-... to avoid collisions.
   Adjust color tokens to match your design system.
====================================================================== */

.invoice-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1080;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1rem;
}

.invoice-overlay[hidden] {
  display: none !important;
}

.invoice-panel {
  width: 100%;
  max-width: 1150px;
  max-height: 90vh;
  background: #ffffff;
  border-radius: .5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  box-shadow: 0 6px 28px -4px rgba(0,0,0,.35);
  animation: invoiceFadeSlide .25s ease;
}

@keyframes invoiceFadeSlide {
  from { opacity:0; transform: translateY(12px); }
  to   { opacity:1; transform: translateY(0); }
}

.invoice-panel-header {
  background: #004E9D; /* Primary header brand color */
  color: #fff;
  padding: .75rem 1rem;
  display:flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink:0;
}

.invoice-panel-header h5 {
  font-size: 1rem;
  line-height: 1.25rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: .4rem;
}

.invoice-panel-body {
  position: relative;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem 1rem .75rem;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: #5f6f84 #d6dfea;
}

.invoice-panel-body::-webkit-scrollbar {
  width: 10px;
}
.invoice-panel-body::-webkit-scrollbar-track {
  background: #e9eef4;
  border-radius: 8px;
}
.invoice-panel-body::-webkit-scrollbar-thumb {
  background: #97a9be;
  border-radius: 8px;
}
.invoice-panel-body::-webkit-scrollbar-thumb:hover {
  background: #7d8fa3;
}

.invoice-panel-footer {
  position: sticky;
  bottom: 0;
  background: #f8f9fa;
  padding: .75rem 1rem;
  border-top: 1px solid #e0e0e0;
  box-shadow: 0 -2px 6px -3px rgba(0,0,0,.15);
  z-index: 5;
}

.invoice-panel-footer .btn {
  min-width: 118px;
}

.invoice-panel .table-wrapper {
  max-height: 320px;
  overflow: auto;
  border: 1px solid #e1e1e1;
  background: #fff;
  border-radius: .25rem;
}

.invoice-panel .table-wrapper::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}
.invoice-panel .table-wrapper::-webkit-scrollbar-thumb {
  background: #b5c2cf;
  border-radius: 6px;
}
.invoice-panel .table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #98a6b3;
}

#manualItemsTable input.form-control-sm,
#manualItemsTable select.form-select-sm {
  min-height: 30px;
  line-height: 1.2;
  font-size: .75rem;
  padding: .25rem .4rem;
}

#manualItemsTable th,
#manualItemsTable td {
  vertical-align: middle;
  font-size: .78rem;
  white-space: nowrap;
}

#manualItemsTable thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8f9fa;
}

.invoice-panel .form-control.bg-light,
.invoice-panel #manualSubtotal,
.invoice-panel #manualSubtotalCell {
  font-weight: 600;
  font-size: 0.85rem;
}

/* Icon alignment tweaks */
.invoice-panel-header i.fa {
  font-size: 1rem;
}

/* Buttons in header */
.invoice-panel-header .btn {
  font-size: .7rem;
  line-height: 1;
  padding: .35rem .6rem;
}

/* Mobile tweaks */
@media (max-width: 576px) {
  .invoice-overlay {
    padding: 1rem .5rem;
  }
  .invoice-panel {
    max-height: 95vh;
    border-radius: .4rem;
  }
  .invoice-panel-body {
    padding: .75rem .6rem .5rem;
  }
  .invoice-panel-footer {
    padding: .55rem .6rem;
  }
  #manualItemsTable th, #manualItemsTable td {
    font-size: .68rem;
  }
  .invoice-panel-header h5 {
    font-size: .9rem;
  }
  .invoice-panel-footer .btn {
    min-width: unset;
  }
}

/* Utility (optional) */
.invoice-hidden {
  display: none!important;
}

.invoice-overlay{position:fixed;inset:0;background:rgba(0,0,0,.55);z-index:1080;display:flex;justify-content:center;align-items:flex-start;padding:2rem 1rem}
.invoice-overlay[hidden]{display:none!important}
.invoice-panel{width:100%;max-width:1150px;max-height:90vh;background:#fff;border-radius:.5rem;display:flex;flex-direction:column;overflow:hidden;position:relative;box-shadow:0 6px 28px -4px rgba(0,0,0,.35);animation:invoiceFadeSlide .25s ease}
@keyframes invoiceFadeSlide{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
.invoice-panel-header{background:#031F4A;color:#fff;padding:.75rem 1rem;display:flex;justify-content:space-between;align-items:center;flex-shrink:0}
.invoice-panel-header h5{font-size:1rem;line-height:1.25rem;margin:0;display:flex;align-items:center;gap:.4rem}
.invoice-panel-body{position:relative;flex:1 1 auto;overflow-y:auto;padding:1rem 1rem .75rem;min-height:0}
.invoice-panel-footer{position:sticky;bottom:0;background:#f8f9fa;padding:.75rem 1rem;border-top:1px solid #e0e0e0;box-shadow:0 -2px 6px -3px rgba(0,0,0,.15);z-index:5}
.invoice-panel .table-wrapper{max-height:320px;overflow:auto;border:1px solid #e1e1e1;background:#fff;border-radius:.25rem}
#manualItemsTable input.form-control-sm,#manualItemsTable select.form-select-sm{min-height:30px;line-height:1.2;font-size:.75rem;padding:.25rem .4rem}
#manualItemsTable th,#manualItemsTable td{vertical-align:middle;font-size:.78rem;white-space:nowrap}
#manualItemsTable thead th{position:sticky;top:0;z-index:2;background:#f8f9fa}
@media (max-width:576px){.invoice-overlay{padding:1rem .5rem}.invoice-panel{max-height:95vh;border-radius:.4rem}.invoice-panel-body{padding:.75rem .6rem .5rem}.invoice-panel-footer{padding:.55rem .6rem}#manualItemsTable th,#manualItemsTable td{font-size:.68rem}.invoice-panel-header h5{font-size:.9rem}}


/* Core invoice styling */
.invoice-wrapper {
    background:#fff;
    border:1px solid #dcdcdc;
    border-radius:6px;
    padding:2rem;
    position:relative;
    font-size:.9rem;
}
.invoice-header {
    display:flex;
    justify-content:space-between;
    flex-wrap:wrap;
    gap:1.5rem;
    border-bottom:2px solid #eee;
    margin-bottom:1.25rem;
    padding-bottom:1rem;
}
.invoice-header .ih-left h4 {
    margin:0 0 .35rem;
    font-size:1.35rem;
}
.invoice-meta {
    text-align:right;
    min-width:250px;
}
.invoice-meta h2 {
    font-size:1.6rem;
    margin:0 0 .3rem;
    letter-spacing:1px;
}
.info-grid {
    display:flex;
    flex-wrap:wrap;
    gap:1.5rem;
    margin-bottom:1.5rem;
}
.info-card {
    flex:1 1 300px;
    background:#fafafa;
    border:1px solid #e6e6e6;
    border-radius:4px;
    padding:1rem 1.1rem;
}
.info-card h6 {
    text-transform:uppercase;
    font-size:.75rem;
    letter-spacing:.75px;
    margin:0 0 .5rem;
    font-weight:600;
    color:#555;
}
.invoice-table th,
.invoice-table td { vertical-align:middle; }
.invoice-table tbody tr:last-child td { border-bottom:1px solid #dee2e6; }
.invoice-summary {
    max-width:380px;
    margin-left:auto;
}
.invoice-summary table {
    width:100%;
    font-size:.9rem;
}
.invoice-summary td {
    padding:.4rem .6rem;
}
.invoice-summary tr:last-child td {
    border-top:2px solid #000;
    font-weight:600;
}
.invoice-watermark {
    position:absolute;
    top:50%;
    left:50%;
    transform:translate(-50%,-50%) rotate(-25deg);
    font-size:5rem;
    font-weight:800;
    color:rgba(150,150,150,0.15);
    pointer-events:none;
    user-select:none;
    z-index:0;
    text-align:center;
    width:80%;
}
.invoice-watermark.canceled { color:rgba(120,0,0,0.18); }
.invoice-watermark.overdue { color:rgba(190,110,0,0.18); }
.invoice-watermark.draft   { color:rgba(120,120,120,0.18); }

.payments-block {
    margin-top:2rem;
}
.badge-status {
    font-size:.7rem;
    padding:.4rem .6rem;
}
.invoice-notes {
    margin-top:1.5rem;
    font-size:.85rem;
    white-space:pre-line;
}
@media print {
    body { background:#fff!important; }
    .no-print { display:none!important; }
    .invoice-wrapper {
        border:none;
        box-shadow:none;
        padding:0;
    }
}
