/* ============================================
   INVOICE DETAIL PAGE STYLES
   ============================================ */

.invoice-preview {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 30px;
  max-height: 900px;
  overflow-y: auto;
}

.invoice-loading {
  display: flex;
  min-height: 280px;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  color: #52606d;
}

.invoice-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  align-items: start;
}

.invoice-editor-grid > .panel {
  min-width: 0;
  margin-bottom: 0 !important;
}

.btn.is-loading {
  cursor: wait;
}

.invoice-preview * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Invoice Header */
.invoice-preview .header {
  text-align: center;
  margin-bottom: 10px;
  border-bottom: 2px solid #000;
  padding-bottom: 15px;
}

.invoice-preview .company-name {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 5px;
}

.invoice-preview .company-details {
  font-size: 11px;
  line-height: 1.5;
}

.invoice-preview .company-details p {
  margin: 2px 0;
}

/* Invoice Body */
.invoice-preview .invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 11px;
}

.invoice-preview .invoice-table thead {
  background-color: #f0f0f0;
}

.invoice-preview .invoice-table th,
.invoice-preview .invoice-table td {
  border: 1px solid #000;
  padding: 6px;
  text-align: left;
}

.invoice-preview .invoice-table th {
  font-weight: bold;
  text-align: center;
}

.invoice-preview .invoice-table tbody tr:nth-child(odd) {
  background-color: #fafafa;
}

/* Totals Section */
.invoice-preview .totals-section {
  display: flex;
  justify-content: flex-end;
  margin: 15px 0;
}

.invoice-preview .totals {
  width: 280px;
  border: 1px solid #000;
}

.invoice-preview .total-row {
  display: flex;
  border-bottom: 1px solid #000;
  padding: 6px;
  font-size: 11px;
}

.invoice-preview .total-label {
  flex: 1;
}

.invoice-preview .total-value {
  min-width: 80px;
  text-align: right;
  font-weight: bold;
}

.invoice-preview .total-row.grand-total {
  background-color: #f0f0f0;
  border-bottom: 2px solid #000;
  font-weight: bold;
}

/* Panel Styles */
.panel {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}

.panel-heading {
  background: #f9f9f9;
  padding: 15px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-heading h3,
.panel-heading h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.panel-heading .eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
  display: block;
  margin-bottom: 5px;
}

.panel-body {
  padding: 20px;
}

/* Total Display */
.total-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 14px;
  border-bottom: 1px solid #e0e0e0;
}

.total-row:last-child {
  border-bottom: none;
}

.total-row.total-grand {
  padding: 15px 0;
  border-top: 2px solid #e0e0e0;
  border-bottom: none;
  font-size: 16px;
  font-weight: 600;
  color: #000;
}

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

/* Charges List */
.list-group {
  border: 0;
  margin: -20px;
  margin-top: 0;
}

.list-group-item {
  border: 0;
  border-bottom: 1px solid #e0e0e0;
  padding: 15px 20px;
  background: white;
}

.list-group-item:last-child {
  border-bottom: 0;
}

.list-group-item:hover {
  background: #f9f9f9;
}

.list-group-item strong {
  font-weight: 600;
  color: #000;
}

/* Forms */
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  display: block;
}

.form-control {
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
  outline: none;
}

textarea.form-control {
  font-family: inherit;
  resize: vertical;
}

/* Buttons */
.btn {
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 6px;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: #0066cc;
  color: white;
}

.btn-primary:hover {
  background: #0052a3;
  transform: translateY(-1px);
}

.btn-outline-primary {
  border: 1px solid #0066cc;
  color: #0066cc;
  background: white;
}

.btn-outline-primary:hover {
  background: #f0f6ff;
}

.btn-outline-secondary {
  border: 1px solid #999;
  color: #333;
  background: white;
}

.btn-outline-secondary:hover {
  background: #f5f5f5;
}

.btn-outline-danger {
  border: 1px solid #dc3545;
  color: #dc3545;
  background: white;
}

.btn-outline-danger:hover {
  background: #fff0f0;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Utilities */
.gap-2 {
  gap: 12px !important;
}

.flex-fill {
  flex: 1;
}

.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
}

.eyebrow.accent {
  color: #0066cc;
}

.d-none {
  display: none;
}

.d-flex {
  display: flex;
}

.mb-3 {
  margin-bottom: 16px;
}

.mb-1 {
  margin-bottom: 8px;
}

.mt-3 {
  margin-top: 16px;
}

.text-secondary {
  color: #666;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 20px;
  border: 0;
}

.alert-danger {
  background: #fff0f0;
  color: #d32f2f;
  border-left: 4px solid #d32f2f;
}

.alert-success {
  background: #f0fff0;
  color: #2e7d32;
  border-left: 4px solid #2e7d32;
}

.alert-warning {
  background: #fff8f0;
  color: #f57c00;
  border-left: 4px solid #f57c00;
}

.alert-info {
  background: #f0f6ff;
  color: #0066cc;
  border-left: 4px solid #0066cc;
}

/* Responsive */
@media (max-width: 992px) {
  .invoice-preview {
    max-height: 600px;
  }
  
  .row > [class*='col-'] {
    margin-bottom: 20px;
  }
}

@media (max-width: 768px) {
  .invoice-preview {
    padding: 12px;
    font-size: 11px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .invoice-preview .company-name {
    font-size: 17px;
  }
  
  .invoice-preview table {
    min-width: 500px;
  }

  .btn {
    min-height: 42px;
    padding: 8px 14px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .btn-sm {
    min-height: 38px;
    padding: 6px 12px;
    font-size: 13px;
  }
  
  .panel-heading {
    padding: 12px 14px;
  }
  
  .panel-body {
    padding: 14px;
  }

  .invoice-editor-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .panel-body {
    padding: 12px;
  }

  .form-control,
  .form-select {
    font-size: 16px;
    min-height: 46px;
  }

  .d-flex.gap-2:has(#saveDraftBtn) {
    flex-direction: column;
    width: 100%;
  }

  #saveDraftBtn,
  #downloadPdfBtn {
    width: 100%;
    min-height: 46px;
  }
}

/* Print Styles */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 12mm;
  }

  body {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  
  .sidebar,
  .dashboard-header,
  .invoice-editor-grid,
  .action-buttons,
  .toast-portal-container,
  #pageAlert,
  #backBtn,
  .btn,
  .d-flex.gap-2 {
    display: none !important;
  }
  
  .main-content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  
  .panel {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
  }
  
  .panel-heading {
    display: none !important;
  }
  
  .invoice-preview {
    border: none !important;
    box-shadow: none !important;
    max-height: none !important;
    padding: 0 !important;
    overflow: visible !important;
  }
  
  .invoice-sheet {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  .table-responsive {
    overflow: visible !important;
    border: none !important;
  }
  
  .invoice-table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 8.5pt !important;
  }
  
  .invoice-table th,
  .invoice-table td {
    border: 1px solid #1e293b !important;
    padding: 4px 6px !important;
  }
  
  .invoice-table th {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    font-weight: 700 !important;
    text-align: center !important;
  }

  .invoice-footer {
    page-break-inside: avoid;
  }
}
