/* Custom Styles for Production Electronics Inventory & POS Management System */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;600;700&display=swap');

:root {
  --font-arabic: 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

body {
  font-family: var(--font-arabic);
  direction: rtl;
  text-align: right;
  background-color: #0b0f19;
  color: #f1f5f9;
}

.font-mono-code {
  font-family: var(--font-mono);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #0f172a;
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Glassmorphism & Cards */
.glass-panel {
  background: rgba(17, 24, 39, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.glass-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.8) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Glow effects */
.glow-primary {
  box-shadow: 0 0 20px -5px rgba(59, 130, 246, 0.3);
}
.glow-emerald {
  box-shadow: 0 0 20px -5px rgba(16, 185, 129, 0.3);
}
.glow-amber {
  box-shadow: 0 0 20px -5px rgba(245, 158, 11, 0.3);
}
.glow-rose {
  box-shadow: 0 0 20px -5px rgba(244, 63, 94, 0.35);
}
.glow-cyan {
  box-shadow: 0 0 20px -5px rgba(6, 182, 212, 0.3);
}
.glow-purple {
  box-shadow: 0 0 20px -5px rgba(168, 85, 247, 0.3);
}

/* Specific Packaging Condition Badges */
.badge-tier-zero {
  background-color: rgba(16, 185, 129, 0.14);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-tier-medium {
  background-color: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-tier-customs {
  background-color: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.45);
  box-shadow: 0 0 10px -2px rgba(239, 68, 68, 0.3);
}

/* Location Badges */
.badge-loc-warehouse {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.badge-loc-shop {
  background-color: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.35);
}

/* Modal Viewport & Scrolling Fixes (Responsive Limits) */
.modal-backdrop-custom {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow-y: auto;
}

.modal-backdrop-custom.hidden {
  display: none !important;
  pointer-events: none !important;
}

.modal-container-custom {
  position: relative;
  width: 96%;
  max-width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 1.25rem;
  margin: auto;
}

@media (max-width: 640px) {
  .modal-backdrop-custom {
    padding: 0.5rem;
  }
  .modal-container-custom {
    width: 98%;
    max-height: 92vh;
    border-radius: 1rem;
  }
  .modal-body-scrollable {
    padding: 1rem !important;
  }
}

.modal-body-scrollable {
  flex: 1 1 auto;
  overflow-y: auto;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  padding: 1.5rem;
}

/* ==========================================================
   MOBILE & TABLET RESPONSIVE SIDEBAR (Strict Off-Canvas Drawer)
   ========================================================== */
#sidebar-overlay,
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 990;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

#sidebar-overlay.active,
#sidebar-overlay.open,
.sidebar-backdrop.active,
.sidebar-backdrop.open {
  display: block !important;
  opacity: 1 !important;
}

/* Screens under 1024px (Mobile & Small/Medium Tablets) */
@media (max-width: 1023px) {
  #app-sidebar {
    position: fixed !important;
    top: 0 !important;
    right: -320px !important;
    bottom: 0 !important;
    left: auto !important;
    width: 280px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 1000 !important;
    margin: 0 !important;
    box-shadow: -10px 0 35px -5px rgba(0, 0, 0, 0.75);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    transform: none !important;
    visibility: hidden;
  }

  #app-sidebar.open,
  #app-sidebar.active,
  #app-sidebar.sidebar-open {
    right: 0 !important;
    visibility: visible !important;
  }

  #main-content-wrapper,
  .main-content-container {
    width: 100% !important;
    margin-right: 0 !important;
    padding-right: 0 !important;
  }

  #mobile-menu-toggle {
    display: inline-flex !important;
  }
}

@media (min-width: 1024px) {
  #app-sidebar {
    position: static !important;
    right: auto !important;
    width: 16rem !important;
    height: auto !important;
    z-index: 10 !important;
    visibility: visible !important;
  }

  #sidebar-overlay,
  .sidebar-backdrop {
    display: none !important;
  }

  #mobile-menu-toggle {
    display: none !important;
  }
}

/* Responsive Table Wrapper Fixes */
.overflow-x-auto {
  -webkit-overflow-scrolling: touch;
}

table {
  min-width: 100%;
}

@media (max-width: 768px) {
  table th, table td {
    white-space: nowrap;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
}

/* Timeline Components */
.timeline-item {
  position: relative;
  padding-right: 2rem;
  padding-bottom: 1.5rem;
}
.timeline-item:last-child {
  padding-bottom: 0;
}
.timeline-item::before {
  content: '';
  position: absolute;
  top: 0.5rem;
  right: 0.45rem;
  bottom: 0;
  width: 2px;
  background-color: #334155;
}
.timeline-item:last-child::before {
  display: none;
}
.timeline-dot {
  position: absolute;
  top: 0.25rem;
  right: 0;
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  border: 2px solid #0f172a;
}

/* Thermal Label Styling (80mm / Receipt) */
.thermal-receipt-preview {
  width: 80mm;
  min-height: 95mm;
  background: #ffffff;
  color: #000000;
  font-family: 'Cairo', sans-serif;
  padding: 4mm 5mm;
  box-sizing: border-box;
  margin: 0 auto;
  border: 1px dashed #64748b;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

/* Shipping Slip / Dispatch Receipt Preview (A5 / Half Sheet) */
.shipping-slip-preview {
  width: 148mm;
  min-height: 200mm;
  background: #ffffff;
  color: #0f172a;
  font-family: 'Cairo', sans-serif;
  padding: 10mm;
  box-sizing: border-box;
  margin: 0 auto;
  border: 1px solid #cbd5e1;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

/* Print Overrides */
@media print {
  body * {
    visibility: hidden;
  }
  #print-area, #print-area * {
    visibility: visible;
  }
  #print-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    background: transparent !important;
  }
  .no-print {
    display: none !important;
  }
  .thermal-receipt-preview, .shipping-slip-preview {
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
  }
}

/* View transition tabs */
.tab-pane {
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}
.tab-pane.active {
  display: block;
  opacity: 1;
}
