/* ============================================
   UNIFIED PAGE LAYOUT & STYLING
   Applied to all TERP pages for consistent theme
   ============================================ */

/* Base page styling */
* {
  box-sizing: border-box;
}

body {
  margin: 0 !important;
  display: block !important;
  background: #f0f2f5;
  font-family: Arial, sans-serif;
  color: #0f2541;
}

body.has-unified-header {
  padding-top: 56px !important;
}

/* First element in container should have no top margin */
.container > :first-child {
  margin-top: 0 !important;
}

/* ============================================
   UNIFIED HEADER OVERRIDES
   Standardize all header variations to use
   the same gradient theme
   ============================================ */

/* Main header class - used by 83 pages */
.header {
  background: linear-gradient(135deg, #063970, #0a4a8a) !important;
  color: white !important;
  padding: 20px 30px !important;
  border-radius: 12px !important;
  margin: 0 0 16px 0 !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 20px !important;
}

.header h1 {
  color: white !important;
  margin: 0 !important;
  font-size: 1.4em !important;
  font-weight: 700 !important;
}

.header h2 {
  color: white !important;
  margin: 0 !important;
  font-weight: 700 !important;
}

.header p {
  color: rgba(255, 255, 255, 0.85) !important;
  margin: 4px 0 0 0 !important;
  font-size: 0.875em !important;
}

.header-left {
  flex: 1;
}

.header-right {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

/* Section headers */
.section-header {
  background: linear-gradient(135deg, #063970, #0a4a8a) !important;
  color: white !important;
  padding: 16px 24px !important;
  border-radius: 10px !important;
  margin: 0 0 16px 0 !important;
}

.section-header h2 {
  color: white !important;
  margin: 0 !important;
  font-weight: 700 !important;
}

.section-header h3 {
  color: white !important;
  margin: 0 !important;
  font-weight: 700 !important;
}

/* Content headers */
.content-header {
  background: linear-gradient(135deg, #063970, #0a4a8a) !important;
  color: white !important;
  padding: 16px 20px !important;
  border-radius: 10px !important;
  margin: 0 0 20px 0 !important;
}

.content-header h1,
.content-header h2 {
  color: white !important;
  margin: 0 !important;
  font-weight: 700 !important;
}

/* Dashboard/Doc headers */
.statement-header {
  background: linear-gradient(135deg, #063970, #0a4a8a) !important;
  color: white !important;
  padding: 16px 20px !important;
  border-radius: 10px !important;
  margin: 0 0 16px 0 !important;
}

.statement-header h2 {
  color: white !important;
  margin: 0 !important;
}

/* Form/Detail page headers */
.ip-header {
  background: linear-gradient(135deg, #063970, #0a4a8a) !important;
  color: white !important;
  padding: 16px 20px !important;
  border-radius: 10px !important;
  margin: 0 0 16px 0 !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

.ip-header-title {
  color: white !important;
  font-weight: 700 !important;
  font-size: 1.1em !important;
}

.detail-header,
.profile-header,
.report-header {
  background: linear-gradient(135deg, #063970, #0a4a8a) !important;
  color: white !important;
  padding: 16px 20px !important;
  border-radius: 10px !important;
  margin: 0 0 16px 0 !important;
}

.detail-header h2,
.profile-header h2,
.report-header h2 {
  color: white !important;
  margin: 0 !important;
}

/* Ensure white text on all gradient headers */
.header i,
.section-header i,
.content-header i,
.statement-header i,
.ip-header i,
.detail-header i,
.profile-header i,
.report-header i {
  color: white !important;
  display: inline !important;
  font-size: inherit !important;
  width: auto !important;
  height: auto !important;
  opacity: 1 !important;
}

/* Ensure icons are visible in header h1/h2/h3 */
.header h1 i,
.header h2 i,
.header h3 i,
.page-header h1 i,
.page-header h2 i,
.section-header h1 i,
.section-header h2 i {
  color: white !important;
  display: inline !important;
  margin-right: 10px !important;
  font-size: 1em !important;
  opacity: 1 !important;
}

/* Override any inline styles that set different background colors */
.header[style*="background"],
.header[style*="margin-bottom"],
.page-header[style*="margin"],
.section-header[style*="background"],
.content-header[style*="margin"] {
  background: linear-gradient(135deg, #063970, #0a4a8a) !important;
  margin: 0 0 16px 0 !important;
  margin-bottom: 16px !important;
}

/* Force all major headers to have consistent spacing */
[class*="header"]:not(.modal-header):not(.card-header):not(.table-header):not(.sidebar-header):not(.uh-sidebar-header) {
  margin-top: 0 !important;
  margin-bottom: 16px !important;
}

.container {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto !important;
  padding: 12px 24px 32px !important;
  box-sizing: border-box;
}

/* Page Header */
.page-header {
  background: linear-gradient(135deg, #063970, #0a4a8a);
  padding: 20px 28px;
  border-radius: 12px;
  margin: 0 0 16px 0 !important;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.page-header-left h1 {
  color: #fff;
  margin: 0;
  font-size: 1.4em;
  font-weight: 700;
}

.page-header-left p {
  color: rgba(255, 255, 255, 0.85);
  margin: 4px 0 0;
  font-size: 0.875em;
}

.page-header-right {
  display: flex;
  gap: 10px;
}

/* Page Header Buttons */
.ph-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 9px 20px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s;
}

.ph-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.ph-btn.primary {
  background: #fff;
  color: #063970;
}

.ph-btn.primary:hover {
  background: #e8f0fb;
}

/* Summary Cards / Summary Bar */
.summary-bar {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.sc {
  background: #fff;
  border-radius: 10px;
  padding: 14px 20px;
  min-width: 130px;
  flex: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  border-left: 4px solid #063970;
}

.sc-val {
  font-size: 26px;
  font-weight: 700;
  color: #063970;
  line-height: 1.1;
}

.sc-lbl {
  font-size: 11px;
  color: #7a8aab;
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 3px;
}

.sc.amber {
  border-color: #d97706;
}

.sc.amber .sc-val {
  color: #d97706;
}

.sc.teal {
  border-color: #0891b2;
}

.sc.teal .sc-val {
  color: #0891b2;
}

.sc.green {
  border-color: #16a34a;
}

.sc.green .sc-val {
  color: #16a34a;
}

.sc.red {
  border-color: #dc2626;
}

.sc.red .sc-val {
  color: #dc2626;
}

/* Panel / Card Container */
.panel {
  background: #fff;
  border-radius: 10px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid #e8edf5;
  flex-wrap: wrap;
}

.show-ent {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #4b5563;
}

.show-ent select {
  padding: 4px 8px;
  border: 1px solid #dde3ee;
  border-radius: 5px;
  font-size: 13px;
}

.toolbar-r {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.flt {
  padding: 6px 10px;
  border: 1px solid #dde3ee;
  border-radius: 6px;
  font-size: 13px;
  min-width: 130px;
}

.srch {
  padding: 6px 10px;
  border: 1px solid #dde3ee;
  border-radius: 6px;
  font-size: 13px;
  width: 200px;
}

.flt:focus,
.srch:focus {
  outline: none;
  border-color: #063970;
}

/* Table Wrapper */
.tbl-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: #fff;
  border-bottom: 2px solid #dde3ee;
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  color: #374151;
  white-space: nowrap;
}

tbody tr:nth-child(odd) {
  background: #eef2f9;
}

tbody tr:nth-child(even) {
  background: #fff;
}

tbody tr:hover {
  background: #dce7f7 !important;
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid #e8edf5;
  vertical-align: middle;
}

/* Column widths */
td.col-date {
  white-space: nowrap;
  width: 100px;
}

td.col-inv {
  font-weight: 700;
  color: #063970;
  white-space: nowrap;
  width: 130px;
}

td.col-buyer {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.col-shipref {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.col-awb {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.col-status {
  width: 160px;
}

td.col-actions {
  white-space: normal !important;
  width: auto !important;
  min-width: 200px;
  overflow: visible !important;
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 10px;
  white-space: nowrap;
}

.badge-draft {
  background: #e2e8f0;
  color: #4a5568;
}

.badge-issued {
  background: #dbeafe;
  color: #1e40af;
}

.badge-paid {
  background: #d1fae5;
  color: #065f46;
}

.badge-partially_paid {
  background: #fef9c3;
  color: #92400e;
}

.badge-voided {
  background: #fee2e2;
  color: #991b1b;
}

.badge-cancelled {
  background: #e2e8f0;
  color: #6c757d;
}

.badge-transit {
  background: #fef3c7;
  color: #92400e;
}

.badge-arrived_port {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-weight_out {
  background: #ede9fe;
  color: #4c1d95;
}

.badge-docs_uploaded {
  background: #fce7f3;
  color: #9d174d;
}

.badge-departed {
  background: #dbeafe;
  color: #1e40af;
}

.badge-arrived {
  background: #d1fae5;
  color: #065f46;
}

.badge-closed {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

/* Inline Buttons (action buttons) */
.ib {
  font-size: 11px;
  font-weight: 700;
  padding: 0 7px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid #b0bed4;
  background: #eef2f9;
  color: #1e3a5f;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  margin-right: 2px;
  transition: background 0.15s;
}

.ib:hover {
  background: #dce7f7;
}

.ib-view {
  border-color: #0891b2;
  background: #e0f2fe;
  color: #0369a1;
}

.ib-view:hover {
  background: #bae6fd;
}

.ib-edit {
  border-color: #d97706;
  background: #fef3c7;
  color: #92400e;
}

.ib-edit:hover {
  background: #fde68a;
}

.ib-issue {
  border-color: #063970;
  background: #dbeafe;
  color: #1e40af;
}

.ib-issue:hover {
  background: #bfdbfe;
}

.ib-recalc {
  border-color: #b45309;
  background: #fef3c7;
  color: #92400e;
}

.ib-recalc:hover {
  background: #fde68a;
}

.ib-receipt {
  border-color: #16a34a;
  background: #d1fae5;
  color: #065f46;
}

.ib-receipt:hover {
  background: #a7f3d0;
}

.ib-netting {
  border-color: #7c3aed;
  background: #ede9fe;
  color: #4c1d95;
}

.ib-netting:hover {
  background: #ddd6fe;
}

.ib-void {
  border-color: #dc2626;
  background: #fee2e2;
  color: #991b1b;
}

.ib-void:hover {
  background: #fecaca;
}

.ib-claim {
  border-color: #063970;
  background: #dbeafe;
  color: #1e40af;
}

.ib-claim:hover {
  background: #bfdbfe;
}

.ib-del {
  border-color: #6b7280;
  background: #f3f4f6;
  color: #374151;
}

.ib-del:hover {
  background: #fee2e2;
  border-color: #dc2626;
  color: #dc2626;
}

.ib-adv {
  border-color: #059669;
  background: #d1fae5;
  color: #065f46;
}

.ib-adv:hover {
  background: #a7f3d0;
}

.ib-pdf {
  border-color: #b91c1c;
  background: #fee2e2;
  color: #991b1b;
}

.ib-pdf:hover {
  background: #fecaca;
}

/* Payment pill */
.pay-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 8px;
  white-space: nowrap;
  margin-top: 3px;
  letter-spacing: 0.3px;
}

.pay-paid {
  background: #d1fae5;
  color: #065f46;
}

.pay-partial {
  background: #fef3c7;
  color: #92400e;
}

.pay-unpaid {
  background: #fee2e2;
  color: #991b1b;
}

/* Mode tags */
.mode-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 8px;
  white-space: nowrap;
  margin-top: 3px;
  letter-spacing: 0.3px;
}

.tag-air {
  background: #e0f2fe;
  color: #0369a1;
}

.tag-sea {
  background: #dbeafe;
  color: #1e3a8a;
}

.tag-land {
  background: #dcfce7;
  color: #166534;
}

.tag-dom {
  background: #f3f4f6;
  color: #4b5563;
}

.tag-exp {
  background: #fef3c7;
  color: #92400e;
}

/* Footer / Pagination */
.footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid #e8edf5;
  gap: 6px;
}

.pg-info {
  font-size: 12px;
  color: #6b7280;
  margin-right: auto;
}

.pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid #dde3ee;
  background: #fff;
  color: #374151;
  cursor: pointer;
  font-size: 13px;
}

.pg-btn:hover {
  background: #eef2f9;
  border-color: #063970;
  color: #063970;
}

.pg-btn.active {
  background: #063970;
  color: #fff;
  border-color: #063970;
  font-weight: 700;
}

.pg-btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.pg-ellipsis {
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
  font-size: 13px;
  color: #9ca3af;
}

.empty-row td {
  text-align: center;
  padding: 50px;
  color: #9ca3af;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-overlay.active {
  display: flex;
}

.modal-overlay .modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 720px;
  margin: auto;
}

.modal-overlay .modal h3 {
  margin-top: 0;
  color: #063970;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  color: #374151;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #dde3ee;
  border-radius: 6px;
  font-size: 13px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #063970;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  border-top: 1px solid #e8edf5;
  padding-top: 16px;
}

.modal-footer .ph-btn {
  background: #eef2f9;
  color: #1e3a5f;
  border: 1px solid #b0bed4;
}

.modal-footer .ph-btn:hover {
  background: #dce7f7;
}

.modal-footer .ph-btn.primary {
  background: #063970;
  color: #fff;
  border-color: #063970;
}

.modal-footer .ph-btn.primary:hover {
  background: #0a4a8a;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 12px !important;
  }

  .page-header {
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    align-items: flex-start;
  }

  .page-header-right {
    width: 100%;
    flex-wrap: wrap;
  }

  .summary-bar {
    gap: 8px;
  }

  .sc {
    min-width: calc(50% - 8px);
    padding: 10px 14px;
  }

  .sc-val {
    font-size: 20px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
  }

  .toolbar-r {
    margin-left: 0;
    flex-direction: column;
    align-items: stretch;
  }

  .flt,
  .srch {
    width: 100%;
    min-width: 0;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .modal-overlay .modal {
    max-width: 95vw;
    padding: 16px;
    margin: 10px auto;
  }

  /* Reset fixed column widths for card view */
  td.col-date,
  td.col-inv,
  td.col-buyer,
  td.col-shipref,
  td.col-awb,
  td.col-status,
  td.col-actions {
    width: auto !important;
    max-width: none !important;
    overflow: visible !important;
    text-overflow: unset !important;
    white-space: normal !important;
  }

  .footer {
    flex-wrap: wrap;
    gap: 4px;
    padding: 10px 12px;
  }
}
