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

* { box-sizing: border-box; }

body { font-family: 'Inter', sans-serif; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #fafafa; }
::-webkit-scrollbar-thumb { background: #fed7aa; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #f97316; }

.sidebar { transition: transform 0.3s ease; }
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 50px rgba(0,0,0,0.2); }
  .main-content { margin-left: 0 !important; }
}

.kpi-card { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(249,115,22,0.15); }
.nav-link { transition: all 0.15s ease; }
.page-enter { animation: pageIn 0.3s ease; }
@keyframes pageIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
tbody tr { transition: background 0.1s ease; }
.chart-wrap { position: relative; }
.nav-active-dot { width:6px; height:6px; border-radius:50%; background:rgba(255,255,255,0.7); flex-shrink:0; }
.badge-active { background:#dcfce7; color:#166534; }
.badge-inactive { background:#fee2e2; color:#991b1b; }
.badge-pending { background:#fef3c7; color:#92400e; }
.badge-processing { background:#dbeafe; color:#1e40af; }
.badge-delivered { background:#dcfce7; color:#166534; }
.badge-cancelled { background:#fee2e2; color:#991b1b; }
.badge-lowstock { background:#fff7ed; color:#c2410c; }
.modal-backdrop { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.modal-box { animation: modalIn 0.25s ease; }
@keyframes modalIn { from { opacity:0; transform:scale(0.95) translateY(-10px); } to { opacity:1; transform:scale(1) translateY(0); } }
.app-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.46);
  backdrop-filter: blur(2px);
  pointer-events: auto;
}
.app-loading-overlay.hidden {
  display: none;
}
.app-loading-dialog {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(380px, 100%);
  border: 1px solid #fed7aa;
  border-radius: 16px;
  background: #fff;
  padding: 18px 20px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.26);
  animation: modalIn 0.18s ease;
}
.app-loading-spinner {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 3px solid #fed7aa;
  border-top-color: #f97316;
  border-radius: 999px;
  animation: appLoadingSpin 0.75s linear infinite;
}
.app-loading-dialog p {
  margin: 0 0 3px;
  color: #111827;
  font-size: 0.92rem;
  font-weight: 800;
}
.app-loading-dialog span {
  display: block;
  color: #6b7280;
  font-size: 0.8rem;
  line-height: 1.35;
}
body.app-loading-active {
  cursor: wait;
  overflow: hidden;
  touch-action: none;
}
.is-loading-pending {
  cursor: wait !important;
  opacity: 0.72;
  pointer-events: none;
}
@keyframes appLoadingSpin { to { transform: rotate(360deg); } }
.live-toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.live-toast {
  pointer-events: auto;
  border: 1px solid #fed7aa;
  border-left: 4px solid #f97316;
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
  animation: liveToastIn 0.22s ease;
}
.live-toast p {
  margin: 0 0 2px;
  color: #111827;
  font-size: 0.875rem;
  font-weight: 700;
}
.live-toast span {
  color: #6b7280;
  font-size: 0.78rem;
  line-height: 1.35;
}
.live-toast-order { border-left-color: #16a34a; }
.live-toast-inventory { border-left-color: #f59e0b; }
.live-toast-shift { border-left-color: #2563eb; }
.live-toast-billing { border-left-color: #7c3aed; }
.live-toast-exit { opacity: 0; transform: translateY(8px); transition: opacity 0.25s ease, transform 0.25s ease; }
@keyframes liveToastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
.live-notification-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 70;
  width: min(360px, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid #fed7aa;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.16);
}
.live-notification-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #fff7ed;
  color: #111827;
  font-size: 0.85rem;
  font-weight: 800;
}
.live-notification-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.live-notification-header button {
  color: #f97316;
  font-size: 0.75rem;
  font-weight: 700;
}
.live-notification-list {
  max-height: 340px;
  overflow-y: auto;
}
.live-notification-item {
  padding: 12px 14px;
  border-bottom: 1px solid #f9fafb;
}
.live-notification-item p {
  margin: 0 0 2px;
  color: #111827;
  font-size: 0.83rem;
  font-weight: 700;
}
.live-notification-item span {
  display: block;
  color: #6b7280;
  font-size: 0.76rem;
  line-height: 1.35;
}
.live-notification-item small {
  display: block;
  margin-top: 5px;
  color: #fb923c;
  font-size: 0.7rem;
  font-weight: 700;
}
.live-empty {
  padding: 18px 14px;
  color: #9ca3af;
  font-size: 0.8rem;
  text-align: center;
}
.live-reload-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #fed7aa;
  border-radius: 16px;
  background: #fff7ed;
  padding: 12px 14px;
  color: #9a3412;
  font-size: 0.85rem;
  font-weight: 700;
}
.live-reload-banner button {
  flex-shrink: 0;
  border-radius: 10px;
  background: #f97316;
  padding: 7px 12px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
}
.live-highlight {
  animation: liveHighlight 1.8s ease;
}
@keyframes liveHighlight {
  0% { box-shadow: 0 0 0 0 rgba(249,115,22,0.45); background: #fff7ed; }
  100% { box-shadow: 0 0 0 12px rgba(249,115,22,0); }
}
.auto-filter-loading {
  position: relative;
  opacity: 0.78;
}
.auto-filter-loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid #fed7aa;
  border-top-color: #f97316;
  border-radius: 999px;
  animation: autoFilterSpin 0.7s linear infinite;
}
@keyframes autoFilterSpin { to { transform: rotate(360deg); } }
@media (max-width: 768px) {
  .data-table { font-size: 0.8rem; }
  .data-table th, .data-table td { padding: 8px 10px; }
}
.print-invoice {
  display: none;
}
@media print {
  @page {
    size: A4 portrait;
    margin: 8mm;
  }

  html,
  body {
    background: #fff !important;
    color: #111827 !important;
    font-family: Arial, Helvetica, sans-serif !important;
  }

  .sidebar,
  header,
  .no-print,
  .live-toast-root,
  .live-notification-dropdown,
  .live-reload-banner,
  #confirm-modal,
  #loading-overlay {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    min-height: auto !important;
  }

  main {
    padding: 0 !important;
  }

  .screen-receipt {
    display: none !important;
  }

  .print-invoice {
    display: block !important;
    width: 100%;
    max-width: 194mm;
    margin: 0 auto !important;
    padding: 0 !important;
    color: #111827 !important;
    font-size: 10pt;
    line-height: 1.28;
    page-break-inside: avoid;
  }

  .print-invoice * {
    box-sizing: border-box;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  .print-invoice-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12mm;
    border-bottom: 2px solid #111827;
    padding-bottom: 4mm;
    margin-bottom: 4mm;
  }

  .print-invoice-brand {
    font-size: 20pt;
    font-weight: 800;
    letter-spacing: 0;
  }

  .print-invoice-title {
    text-align: right;
    font-size: 15pt;
    font-weight: 800;
    text-transform: uppercase;
  }

  .print-invoice-title span,
  .print-invoice-muted,
  .print-label,
  .print-invoice-footer,
  .print-payment-box small {
    color: #4b5563 !important;
  }

  .print-invoice-title span {
    display: block;
    margin-top: 1mm;
    font-size: 10pt;
    font-weight: 700;
  }

  .print-invoice-muted {
    margin-top: 1mm;
    font-size: 9pt;
  }

  .print-invoice-void {
    border: 1px solid #991b1b;
    color: #991b1b !important;
    font-weight: 800;
    text-align: center;
    padding: 2mm;
    margin-bottom: 3mm;
    letter-spacing: 1px;
  }

  .print-invoice-meta {
    display: grid;
    grid-template-columns: 1.1fr 1.2fr 1.1fr;
    gap: 3mm;
    margin-bottom: 4mm;
  }

  .print-invoice-meta > div,
  .print-payment-box,
  .print-total-box {
    border: 1px solid #d1d5db;
    border-radius: 3mm;
    padding: 3mm;
  }

  .print-label {
    margin-bottom: 1.5mm;
    font-size: 7.5pt;
    font-weight: 800;
    letter-spacing: 0.04em;
  }

  .print-invoice-meta strong,
  .print-invoice-meta span {
    display: block;
  }

  .print-invoice-meta strong {
    margin-bottom: 1mm;
    font-size: 10pt;
  }

  .print-invoice-meta span {
    font-size: 8.5pt;
  }

  .print-invoice-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin-bottom: 4mm;
    font-size: 9pt;
  }

  .print-invoice-table th {
    background: #f3f4f6 !important;
    border: 1px solid #d1d5db;
    padding: 2mm;
    font-size: 8pt;
    text-align: left;
    text-transform: uppercase;
  }

  .print-invoice-table td {
    border: 1px solid #e5e7eb;
    padding: 1.8mm 2mm;
    vertical-align: top;
  }

  .print-invoice-table strong,
  .print-invoice-table span {
    display: block;
  }

  .print-invoice-table span {
    margin-top: 0.5mm;
    color: #6b7280 !important;
    font-size: 7.5pt;
  }

  .print-col-no {
    width: 9mm;
    text-align: center !important;
  }

  .print-col-qty {
    width: 16mm;
    text-align: right !important;
  }

  .print-col-money {
    width: 28mm;
    text-align: right !important;
  }

  .print-invoice-bottom {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 62mm;
    gap: 4mm;
    align-items: start;
    page-break-inside: avoid;
  }

  .print-payment-box p {
    margin: 0 0 1.5mm;
    font-size: 8.5pt;
  }

  .print-payment-box p:last-child {
    margin-bottom: 0;
  }

  .print-payment-box span,
  .print-payment-box small {
    display: block;
  }

  .print-note {
    border-top: 1px solid #e5e7eb;
    padding-top: 1.5mm;
  }

  .print-total-box {
    padding: 0;
    overflow: hidden;
  }

  .print-total-box > div {
    display: flex;
    justify-content: space-between;
    gap: 4mm;
    padding: 2mm 3mm;
    border-bottom: 1px solid #e5e7eb;
    font-size: 9pt;
  }

  .print-total-box > div:last-child {
    border-bottom: 0;
  }

  .print-grand-total {
    background: #111827 !important;
    color: #fff !important;
    font-size: 11pt !important;
    font-weight: 800;
  }

  .print-grand-total * {
    color: #fff !important;
  }

  .print-invoice-footer {
    display: flex;
    justify-content: space-between;
    gap: 4mm;
    border-top: 1px solid #d1d5db;
    margin-top: 4mm;
    padding-top: 2.5mm;
    font-size: 8pt;
    page-break-inside: avoid;
  }

  .receipt-shell {
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
    max-width: 80mm;
    margin: 0 auto;
  }

  .receipt-shell table {
    page-break-inside: auto;
  }

  .receipt-shell tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  .receipt-shell img {
    display: none !important;
  }
}
