/* public/styles.css - Excel-like spreadsheet styling & Professional Print Engine */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --primary: #1e3a8a;
  --primary-light: #3b82f6;
  --primary-dark: #172554;
  --accent: #f59e0b;
  --bg-main: #f8fafc;
  --border-color: #cbd5e1;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: #1e293b;
  -webkit-font-smoothing: antialiased;
}

.font-mono-numbers {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}

/* Excel-like Table Styling */
.excel-table-container {
  overflow-x: auto;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

.excel-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  text-align: left;
}

.excel-table th {
  background-color: #f1f5f9;
  color: #334155;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  border-bottom: 2px solid #cbd5e1;
  border-right: 1px solid #e2e8f0;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
  user-select: none;
}

.excel-table th:last-child {
  border-right: none;
}

.excel-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #f1f5f9;
  color: #1e293b;
  white-space: nowrap;
}

.excel-table td:last-child {
  border-right: none;
}

.excel-table tbody tr:nth-child(even) {
  background-color: #fcfcfd;
}

.excel-table tbody tr:hover {
  background-color: #f0f7ff !important;
}

/* Compact Excel Dense Mode */
.table-dense th {
  padding: 5px 8px !important;
  font-size: 11px !important;
}

.table-dense td {
  padding: 4px 8px !important;
  font-size: 12px !important;
  line-height: 1.35 !important;
}

/* Quick Status Badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.status-loading {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.status-transit {
  background-color: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.status-reported {
  background-color: #f3e8ff;
  color: #6b21a8;
  border: 1px solid #e9d5ff;
}

.status-unloaded {
  background-color: #ccfbf1;
  color: #115e59;
  border: 1px solid #99f6e4;
}

.status-delivered {
  background-color: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.status-cancelled {
  background-color: #ffe4e6;
  color: #9f1239;
  border: 1px solid #fecdd3;
}

/* Scrollbar styling for smooth Excel browsing */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* PRINT ENGINE & PDF STYLING */
#print-container {
  display: none;
}

@media print {
  /* Hide the rest of the application */
  body * {
    visibility: hidden;
  }
  
  #print-container, #print-container * {
    visibility: visible;
  }

  #print-container {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    overflow: visible !important;
  }

  #print-container *,
  #print-container .sticky-table-viewport,
  #print-container .excel-table-container,
  #print-container .overflow-x-auto,
  #print-container .overflow-y-auto,
  #print-container .overflow-hidden {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
  }

  #print-container thead th,
  #print-container tfoot tr,
  #print-container .sticky,
  #print-container .sticky-bottom-totals {
    position: static !important;
    box-shadow: none !important;
  }

  #print-container table {
    width: 100% !important;
    max-width: 100% !important;
    border-collapse: collapse !important;
    table-layout: auto !important;
  }

  #print-container th,
  #print-container td {
    white-space: normal !important;
    word-break: break-word !important;
  }

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

  @page {
    size: A4 portrait;
    margin: 8mm 8mm 8mm 8mm;
  }

  .print-page {
    page-break-after: always;
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    background: white;
    color: black;
    font-size: 12px;
    line-height: 1.4;
  }

  .print-page:last-child {
    page-break-after: auto;
  }

  /* Watermark for copy type */
  .copy-watermark {
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 2px;
    padding: 2px 10px;
    border: 1.5px solid #111;
    font-size: 11px;
    display: inline-block;
  }

  table.print-grid {
    width: 100%;
    border-collapse: collapse;
  }

  table.print-grid th, table.print-grid td {
    border: 1px solid #333;
    padding: 4px 6px;
    font-size: 11px;
  }

  table.print-grid th {
    background-color: #f1f5f9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-weight: 700;
  }
}

/* Uppercase inputs for standard formatting */
.uppercase-input, input.uppercase-input, textarea.uppercase-input, .lr-field {
  text-transform: uppercase;
}

/* Sticky Bottom Totals & Scrollbar for Laptop Screens */
.sticky-table-viewport {
  max-height: calc(100vh - 260px);
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
  scrollbar-width: thin;
}

.sticky-table-viewport thead th {
  position: sticky;
  top: 0;
  z-index: 25;
}

.sticky-table-viewport tfoot tr, .sticky-bottom-totals {
  position: sticky !important;
  bottom: 0 !important;
  z-index: 25 !important;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.15), 0 -2px 4px -2px rgba(0, 0, 0, 0.1);
}
