@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 13px; /* Compact base font for laptops & small screens */
}

body {
  font-family: 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-main);
  color: #1e293b;
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
  margin: 0;
  padding: 0;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Compact Card Shadow */
.card-clean {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  transition: all 0.15s ease;
}

/* Status Badges */
.badge-matched {
  background-color: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
}

.badge-shortage {
  background-color: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
}

.badge-overage {
  background-color: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
}

.badge-pending {
  background-color: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
}

/* ========================================== */
/* THERMAL RECEIPT & PRINT STYLING (80mm LINED) */
/* ========================================== */
.receipt-paper {
  font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
  background-color: #ffffff;
  color: #000000;
  width: 100%;
  max-width: 320px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  padding: 14px;
  border: 1.5px solid #000000;
  box-sizing: border-box;
}

.receipt-table, .table-grid {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 6px;
  border: 1px solid #000000;
}

.receipt-table th, .receipt-table td,
.table-grid th, .table-grid td {
  padding: 3.5px 5px;
  vertical-align: middle;
  border: 1px solid #000000;
  color: #000000;
  font-size: 11px;
}

.receipt-table th, .table-grid th {
  background-color: #f1f5f9;
  font-weight: 800;
  text-align: center;
}

.receipt-table td.label-col, .table-grid td.label-cell {
  text-align: right;
  white-space: nowrap;
  font-weight: 700;
  background-color: #f8fafc;
  color: #000000;
  width: 36%;
}

.receipt-table td.val-col {
  text-align: left;
  direction: ltr;
  font-weight: 700;
  color: #000000;
}

.total-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 6px;
  border: 2px solid #000000;
}

.total-table td {
  border: 1px solid #000000;
  padding: 4px 6px;
}

.grand-total-row {
  background-color: #000000;
  color: #ffffff !important;
  font-weight: 900;
  font-size: 13px;
}

.grand-total-row td {
  border: 1px solid #000000;
  color: #ffffff !important;
}

.tafqeet-box {
  border: 1px dashed #000000;
  background: #fafafa;
  padding: 4px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 6px;
}

.sig-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  border: 1px solid #000000;
}

.sig-table td {
  border: 1px solid #000000;
  padding: 4px 2px;
  text-align: center;
  font-size: 9.5px;
  vertical-align: top;
}

.receipt-footer {
  text-align: center;
  border-top: 1.5px solid #000000;
  padding-top: 4px;
  margin-top: 6px;
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1.3;
}

@media print {
  @page {
    size: 80mm auto;
    margin: 2mm 3mm;
  }

  html, body {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
    direction: rtl !important;
    font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .no-print,
  .no-print * {
    display: none !important;
  }

  /* 1. Shift Receipt Print Mode */
  body.print-mode-shift > *:not(#modal-receipt-print),
  body.print-mode-shift #modal-receipt-print .no-print {
    display: none !important;
  }
  body.print-mode-shift #modal-receipt-print {
    position: static !important;
    display: block !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    box-shadow: none !important;
  }
  body.print-mode-shift #modal-receipt-print > div {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* 2. Expense Voucher Print Mode */
  body.print-mode-exp-voucher > *:not(#modal-expense-voucher),
  body.print-mode-exp-voucher #modal-expense-voucher .no-print {
    display: none !important;
  }
  body.print-mode-exp-voucher #modal-expense-voucher {
    position: static !important;
    display: block !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    box-shadow: none !important;
  }
  body.print-mode-exp-voucher #modal-expense-voucher > div {
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* 3. Daily Expenses Statement Print Modes */
  body.print-mode-daily-exp > *:not(#modal-daily-expenses-invoice),
  body.print-mode-daily-exp #modal-daily-expenses-invoice .no-print,
  body.print-mode-daily-exp-thermal > *:not(#modal-daily-expenses-invoice),
  body.print-mode-daily-exp-thermal #modal-daily-expenses-invoice .no-print,
  body.print-mode-daily-exp-a4 > *:not(#modal-daily-expenses-invoice),
  body.print-mode-daily-exp-a4 #modal-daily-expenses-invoice .no-print {
    display: none !important;
  }

  body.print-mode-daily-exp #modal-daily-expenses-invoice,
  body.print-mode-daily-exp-thermal #modal-daily-expenses-invoice,
  body.print-mode-daily-exp-a4 #modal-daily-expenses-invoice {
    position: static !important;
    display: block !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    box-shadow: none !important;
  }

  body.print-mode-daily-exp #modal-daily-expenses-invoice > div,
  body.print-mode-daily-exp-thermal #modal-daily-expenses-invoice > div,
  body.print-mode-daily-exp-a4 #modal-daily-expenses-invoice > div {
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Thermal Receipt Mode for Daily Expenses (Default & Explicit) */
  body.print-mode-daily-exp-thermal #daily-exp-a4-view,
  body.print-mode-daily-exp #daily-exp-a4-view {
    display: none !important;
  }
  body.print-mode-daily-exp-thermal #daily-exp-thermal-view,
  body.print-mode-daily-exp #daily-exp-thermal-view {
    display: block !important;
    width: 74mm !important;
    max-width: 74mm !important;
    margin: 0 auto !important;
    padding: 2mm 1mm !important;
    box-sizing: border-box !important;
    color: #000000 !important;
    background: #ffffff !important;
    font-size: 11px !important;
    line-height: 1.3 !important;
  }
  body.print-mode-daily-exp-thermal #daily-expenses-print-area,
  body.print-mode-daily-exp #daily-expenses-print-area {
    padding: 1mm !important;
    margin: 0 auto !important;
    width: 76mm !important;
    max-width: 76mm !important;
    box-sizing: border-box !important;
    background: #ffffff !important;
  }

  /* Full A4 Mode for Daily Expenses */
  body.print-mode-daily-exp-a4 #daily-exp-thermal-view {
    display: none !important;
  }
  body.print-mode-daily-exp-a4 #daily-exp-a4-view {
    display: block !important;
    width: 100% !important;
  }
  body.print-mode-daily-exp-a4 #daily-expenses-print-area {
    padding: 8mm 6mm !important;
    max-width: 210mm !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }

  /* 4. Warehouse Voucher Print Mode */
  body.print-mode-wh-voucher > *:not(#modal-wh-voucher),
  body.print-mode-wh-voucher #modal-wh-voucher .no-print {
    display: none !important;
  }
  body.print-mode-wh-voucher #modal-wh-voucher {
    position: static !important;
    display: block !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    box-shadow: none !important;
  }
  body.print-mode-wh-voucher #modal-wh-voucher > div {
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Thermal Styling for 80mm/72mm Printers */
  #print-section,
  .thermal-voucher-mode {
    position: relative !important;
    display: block !important;
    width: 74mm !important;
    max-width: 74mm !important;
    margin: 0 auto !important;
    padding: 3mm 2mm !important;
    box-sizing: border-box !important;
    border: 1.5px solid #000000 !important;
    border-radius: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11px !important;
    line-height: 1.35 !important;
  }

  /* Completely exclude uploaded photos/screenshots from physical receipts */
  #exp-voucher-image-section,
  .thermal-voucher-mode #exp-voucher-image-section,
  .receipt-image-preview {
    display: none !important;
  }

  .thermal-voucher-mode * {
    color: #000000 !important;
    font-size: 10px !important;
  }
  .thermal-voucher-mode h2 {
    font-size: 13px !important;
    font-weight: 900 !important;
  }
  .thermal-voucher-mode .text-xl,
  .thermal-voucher-mode .text-2xl {
    font-size: 15px !important;
  }
  .thermal-voucher-mode table td.w-32 {
    width: auto !important;
    min-width: 72px !important;
    white-space: nowrap !important;
  }
  .thermal-voucher-mode .grid-cols-3 {
    display: flex !important;
    justify-content: space-between !important;
    gap: 4px !important;
  }
  .thermal-voucher-mode .grid-cols-3 > div {
    flex: 1 !important;
  }

  /* Standard A4 / A5 Clean Document Format */
  #expense-voucher-print-area:not(.thermal-voucher-mode),
  #wh-voucher-print-area {
    padding: 8mm 6mm !important;
    max-width: 210mm !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
  }
}

/* ========================================== */
/* SIDEBAR NAVIGATION STYLES                  */
/* ========================================== */
#app-sidebar {
  transition: margin-right 0.28s cubic-bezier(0.4, 0, 0.2, 1), transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
  will-change: margin-right, transform;
}

/* Desktop behavior */
@media (min-width: 1024px) {
  #app-sidebar {
    margin-right: 0;
    transform: none !important;
  }
  #app-sidebar.sidebar-closed {
    margin-right: -16rem !important; /* -256px in RTL hides sidebar */
    opacity: 0;
    pointer-events: none;
  }
}

/* Mobile & Tablet behavior (< 1024px) */
@media (max-width: 1023px) {
  #app-sidebar {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    z-index: 50 !important;
    transform: translateX(100%); /* Hidden off-screen right */
  }
  #app-sidebar:not(.sidebar-closed) {
    transform: translateX(0) !important; /* Visible */
    box-shadow: -8px 0 25px -5px rgba(0, 0, 0, 0.2);
  }
}

/* Sidebar active tab item */
.tab-btn.active {
  background-color: #2563eb !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.2) !important;
}

.tab-btn.active i {
  color: #ffffff !important;
}

