/* G-Plex Farm ERP & CRM Stylesheet */

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

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background-color: #f8fafc;
  color: #1e293b;
}

/* Tab panes switching */
.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.25s ease-in-out;
}

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

:root {
  --gplex-watermark-opacity: 0.10;
  --gplex-watermark-print-opacity: 0.16;
  --gplex-watermark-angle: -24deg;
  --gplex-watermark-scale: 65%;
}

/* Brand Logo Size & Flex Protection (Supports Horizontal ~2:1 Custom Logo) */
.brand-logo-img {
  height: 38px;
  width: auto;
  min-width: 68px;
  max-width: 145px;
  max-height: 40px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

/* Corporate Document Watermark Layers (Screen Preview + Multi-Page Print) */
.gplex-global-print-watermark {
  display: none;
}

.gplex-doc-watermark-wrap {
  position: relative;
  isolation: isolate;
}

.gplex-doc-watermark-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  user-select: none;
  z-index: 20;
  overflow: hidden;
}

body.watermark-disabled .gplex-doc-watermark-layer {
  display: none !important;
}

.gplex-doc-watermark-layer img {
  width: var(--gplex-watermark-scale, 62%);
  max-width: 460px;
  height: auto;
  object-fit: contain;
  opacity: var(--gplex-watermark-opacity, 0.09);
  transform: rotate(var(--gplex-watermark-angle, -24deg));
  mix-blend-mode: multiply;
  filter: contrast(1.04);
}

/* Sidebar navigation styling & subtle scrollbar */
.sidebar-scrollbar::-webkit-scrollbar {
  width: 4px;
}
.sidebar-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-scrollbar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.sidebar-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.nav-category-header {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  padding: 0.5rem 0.5rem 0.2rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-tab-btn {
  color: #475569;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  padding: 0.45rem 0.65rem;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.775rem;
  font-weight: 500;
  transition: all 0.15s ease-in-out;
}

.nav-tab-btn:hover {
  background-color: #f8fafc;
  color: #0f172a;
  border-color: #e2e8f0;
  transform: translateX(1px);
}

.nav-tab-btn.active {
  background-color: #ecfdf5;
  color: #065f46;
  font-weight: 700;
  border-color: #a7f3d0;
  box-shadow: 0 1px 3px 0 rgba(16, 185, 129, 0.08);
}

.nav-icon-box {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  background-color: #f1f5f9;
  color: #475569;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.nav-tab-btn:hover .nav-icon-box {
  background-color: #e2e8f0;
  color: #0f172a;
}

.nav-tab-btn.active .nav-icon-box {
  background-color: #059669;
  color: #ffffff;
  box-shadow: 0 2px 4px 0 rgba(5, 150, 105, 0.25);
}

.nav-pill {
  font-size: 9px;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 0.375rem;
  background-color: #f1f5f9;
  color: #64748b;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.nav-tab-btn.active .nav-pill {
  background-color: #d1fae5;
  color: #065f46;
}

.nav-pill-accent {
  font-size: 9px;
  font-weight: 800;
  padding: 0.15rem 0.4rem;
  border-radius: 0.375rem;
  background-color: #fef3c7;
  color: #92400e;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.nav-pill-live {
  font-size: 9px;
  font-weight: 800;
  padding: 0.15rem 0.4rem;
  border-radius: 0.375rem;
  background-color: #e0f2fe;
  color: #0369a1;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* Category filter buttons in inventory */
.inv-filter-btn.active {
  background-color: #15803d;
  color: #ffffff;
}

/* Modal styling */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.hidden {
  display: none;
}

#modalPrintFieldDossier {
  z-index: 250 !important;
}

#modalPrintFieldDossier .modal-card {
  max-width: 58rem;
  width: 100%;
  max-height: 94vh;
  overflow-y: auto;
  padding: 0;
}

.modal-card {
  background: #ffffff;
  border-radius: 1.25rem;
  max-width: 34rem;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: scaleUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleUp {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Weather Badges */
.badge-optimal {
  background-color: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

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

.badge-risk {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Toast Popups */
.toast-popup {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: #0f172a;
  color: #ffffff;
  padding: 0.875rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideInToast 0.3s ease-out;
}

.toast-popup.hidden {
  display: none;
}

@keyframes slideInToast {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Print Media Styles for Comprehensive Enterprise Report */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 8mm;
  }

  body {
    background-color: #ffffff !important;
    color: #0f172a !important;
    font-size: 10pt !important;
    line-height: 1.3 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  header, aside, #sidebar, #mobileSidebar, #quickActionBtn, #quickActionMenu, .toast-popup, .report-no-print, nav, button,
  .nav-tab-btn, .tab-btn, .fleet-subtab-btn, .pos-subtab-btn, .exp-subtab-btn, .sr-subtab-btn, .seed-comm-nav-btn, #seedCommSubNav,
  [role="tablist"], [role="tab"], .subtab-bar, .subtabs, .tab-navigation, .nav-tabs, .nav-category-header, .tab-strip,
  #passportSummaryKpiCards, #cropPassportPrintableContent > .grid:first-of-type,
  .modal-header, .modal-footer {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
  }

  /* Universal Multi-Page Corporate Watermark on Every Printed Document */
  .gplex-doc-watermark-layer {
    display: none !important;
  }

  body:not(.watermark-disabled):not(.printing-pos-receipt) .gplex-global-print-watermark,
  body:not(.watermark-disabled):not(.printing-pos-receipt) #globalPrintWatermarkOverlay {
    display: flex !important;
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none !important;
    user-select: none !important;
    z-index: 99999999 !important;
    background: transparent !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body:not(.watermark-disabled):not(.printing-pos-receipt) .gplex-global-print-watermark img,
  body:not(.watermark-disabled):not(.printing-pos-receipt) #globalPrintWatermarkOverlay img {
    display: block !important;
    width: var(--gplex-watermark-scale, 65%) !important;
    max-width: 520px !important;
    height: auto !important;
    object-fit: contain !important;
    opacity: var(--gplex-watermark-print-opacity, 0.16) !important;
    transform: rotate(var(--gplex-watermark-angle, -24deg)) !important;
    filter: contrast(1.1) !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Printable Dossier Modal Support */
  body.printing-modal-dossier {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.printing-modal-dossier main,
  body.printing-modal-dossier .tab-pane,
  body.printing-modal-dossier #tab-reports,
  body.printing-modal-dossier .modal-backdrop:not(#modalPrintFieldDossier) {
    display: none !important;
  }

  body.printing-modal-dossier #modalPrintFieldDossier {
    display: block !important;
    position: static !important;
    inset: auto !important;
    background: #ffffff !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    z-index: 99999 !important;
  }

  body.printing-modal-dossier #modalPrintFieldDossier .modal-card {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    background: #ffffff !important;
  }

  body.printing-modal-dossier .screen-only-action {
    display: none !important;
  }

  /* Direct Printable Modals (PO, GRN, Delivery Note, Finance Dossier, Farmer Profile, Season Cert, QR Label) */
  body.printing-active-modal {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.printing-active-modal main,
  body.printing-active-modal .tab-pane,
  body.printing-active-modal #tab-reports,
  body.printing-active-modal .modal-backdrop:not(.active-print-modal) {
    display: none !important;
  }

  body.printing-active-modal .modal-backdrop.active-print-modal {
    display: block !important;
    position: static !important;
    inset: auto !important;
    background: #ffffff !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    z-index: 99999 !important;
  }

  body.printing-active-modal .modal-backdrop.active-print-modal .modal-card {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    background: #ffffff !important;
  }

  body.printing-active-modal .modal-backdrop.active-print-modal .overflow-y-auto {
    max-height: none !important;
    overflow: visible !important;
  }

  body.printing-active-modal .modal-print-hide {
    display: none !important;
  }

  /* Default print mode (Tab 12 Comprehensive Report) */
  body:not(.printing-modal-dossier):not(.printing-active-modal):not(.printing-pos-receipt):not(.gplex-printing-modal):not(.printing-seed-comm-subview):not(.printing-fleet-subview) .modal-backdrop {
    display: none !important;
  }

  body:not(.printing-modal-dossier):not(.printing-active-modal):not(.printing-pos-receipt):not(.gplex-printing-modal):not(.printing-seed-comm-subview):not(.printing-fleet-subview) .tab-pane {
    display: none !important;
  }

  body:not(.printing-modal-dossier):not(.printing-active-modal):not(.printing-pos-receipt):not(.gplex-printing-modal):not(.printing-seed-comm-subview):not(.printing-fleet-subview) #tab-reports {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  main {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .print-page-break {
    page-break-before: always !important;
    break-before: page !important;
  }

  .print-avoid-break {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .report-table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  .report-table th, .report-table td {
    border: 1px solid #cbd5e1 !important;
    padding: 4px 6px !important;
    font-size: 8.5pt !important;
  }

  .report-table th {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    font-weight: 700 !important;
  }

  /* Remove heavy shadows & dark background fills for clean paper printing */
  .shadow-sm, .shadow-md, .shadow-lg, .shadow-xl, .shadow-2xl {
    box-shadow: none !important;
  }

  .bg-gradient-to-r, .bg-gradient-to-br {
    background: #ffffff !important;
    color: #0f172a !important;
  }

  .text-white {
    color: #0f172a !important;
  }

  .border-white\/10, .border-white\/20, .border-slate-800 {
    border-color: #e2e8f0 !important;
  }

  .bg-slate-900, .bg-slate-800, .bg-slate-850, .bg-brand-950, .bg-brand-900 {
    background-color: #f8fafc !important;
    color: #0f172a !important;
  }

  .print-header-banner {
    border-bottom: 2px solid #0f172a !important;
    padding-bottom: 8px !important;
    margin-bottom: 12px !important;
  }
}

/* ==========================================================================
   DEDICATED POS THERMAL RECEIPT PRINTING STYLES (PRINTS RECEIPT ONLY)
   ========================================================================== */
@media print {
  /* POS Receipt Only Mode */
  body.printing-pos-receipt {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 80mm !important;
  }

  body.printing-pos-receipt * {
    visibility: hidden !important;
  }

  body.printing-pos-receipt header,
  body.printing-pos-receipt aside,
  body.printing-pos-receipt nav,
  body.printing-pos-receipt main,
  body.printing-pos-receipt #tab-reports,
  body.printing-pos-receipt .tab-pane,
  body.printing-pos-receipt button,
  body.printing-pos-receipt #quickActionBtn,
  body.printing-pos-receipt #quickActionMenu {
    display: none !important;
  }

  body.printing-pos-receipt #modalPosReceipt,
  body.printing-pos-receipt #modalPosReceipt * {
    visibility: visible !important;
  }

  body.printing-pos-receipt #modalPosReceipt {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 80mm !important;
    max-width: 80mm !important;
    margin: 0 auto !important;
    padding: 0 !important;
    background: #ffffff !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
    border: none !important;
    z-index: 9999999 !important;
  }

  body.printing-pos-receipt #modalPosReceipt > div {
    width: 80mm !important;
    max-width: 80mm !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: #ffffff !important;
  }

  body.printing-pos-receipt #posThermalReceiptContainer {
    display: block !important;
    width: 76mm !important;
    max-width: 76mm !important;
    margin: 0 auto !important;
    padding: 3mm 1mm !important;
    background: #ffffff !important;
    color: #0f172a !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    font-size: 11px !important;
    line-height: 1.35 !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
  }

  body.printing-pos-receipt #modalPosReceipt,
  body.printing-pos-receipt #modalPosReceipt > div {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
  }

  body.printing-pos-receipt table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  body.printing-pos-receipt #modalPosReceipt .flex.items-center.justify-between,
  body.printing-pos-receipt #modalPosReceipt .flex.items-center.justify-end,
  body.printing-pos-receipt #modalPosReceipt button {
    display: none !important;
  }
}


/* Role-Based Access Control (RBAC): Read-Only Privileges (Auditors & External Reviewers) */
body.gplex-readonly-role .btn-action-mutate,
body.gplex-readonly-role button.btn-danger,
body.gplex-readonly-role button[data-role-action="mutate"] {
  opacity: 0.45 !important;
  pointer-events: none !important;
  cursor: not-allowed !important;


  /* ========================================================================= */
  /* PRINT STYLES FOR SEED COMMERCIALISATION & INVENTORY SUBVIEWS              */
  /* ========================================================================= */
  body.printing-seed-comm-subview {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.printing-seed-comm-subview header,
  body.printing-seed-comm-subview aside,
  body.printing-seed-comm-subview #sidebar,
  body.printing-seed-comm-subview .sidebar-scrollbar,
  body.printing-seed-comm-subview #headerSearchContainer,
  body.printing-seed-comm-subview #mobileSearchGlassBtn,
  body.printing-seed-comm-subview .nav-tab-btn,
  body.printing-seed-comm-subview #seedCommSubNav,
  body.printing-seed-comm-subview .seed-comm-nav-bar,
  body.printing-seed-comm-subview #seedCommercialisationKpisRibbon,
  body.printing-seed-comm-subview #tab-seed-commercialisation > *:not(.seed-comm-subview),
  body.printing-seed-comm-subview button,
  body.printing-seed-comm-subview .no-print,
  body.printing-seed-comm-subview .report-no-print {
    display: none !important;
  }

  body.printing-seed-comm-subview main {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.printing-seed-comm-subview .tab-pane:not(#tab-seed-commercialisation) {
    display: none !important;
  }

  body.printing-seed-comm-subview #tab-seed-commercialisation {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.printing-seed-comm-subview .seed-comm-subview:not(.active-print-subview) {
    display: none !important;
  }

  body.printing-seed-comm-subview .seed-comm-subview.active-print-subview {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.printing-seed-comm-subview .seed-comm-subview.active-print-subview .print-only-header {
    display: block !important;
  }

  /* ========================================================================= */
  /* MACHINERY & FLEET DIRECT SUBVIEW PRINT STYLES                            */
  /* ========================================================================= */
  body.printing-fleet-subview {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.printing-fleet-subview header,
  body.printing-fleet-subview aside,
  body.printing-fleet-subview #sidebar,
  body.printing-fleet-subview .sidebar-scrollbar,
  body.printing-fleet-subview #headerSearchContainer,
  body.printing-fleet-subview #mobileSearchGlassBtn,
  body.printing-fleet-subview .nav-tab-btn,
  body.printing-fleet-subview .fleet-subtab-btn,
  body.printing-fleet-subview button,
  body.printing-fleet-subview .no-print,
  body.printing-fleet-subview .report-no-print {
    display: none !important;
  }

  body.printing-fleet-subview main {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.printing-fleet-subview .tab-pane:not(#tab-machinery) {
    display: none !important;
  }

  body.printing-fleet-subview #tab-machinery {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.printing-fleet-subview .fleet-pane:not(.active-print-fleet-pane) {
    display: none !important;
  }

  body.printing-fleet-subview .fleet-pane.active-print-fleet-pane {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.printing-fleet-subview .fleet-pane.active-print-fleet-pane .print-only-header {
    display: block !important;
  }

}
