:root {
  --primary: #2c5282;
  --primary-dark: #1a365d;
  --primary-light: #e2e8f0;
  --secondary: #2d3748;
  --tertiary: #4a5568;
  --accent: #00897b;
  --danger: #c53030;
  --warning: #dd6b20;
  --success: #2f855a;
  --background: #f7fafc;
  --card-bg: #ffffff;
  --text: #1a202c;
  --text-secondary: #4a5568;
  --border: rgba(0, 0, 0, 0.15);
  --border-light: rgba(0, 0, 0, 0.05);
  --input-bg: #f8fafc;
  --header-bg: #f7fafc;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--background);
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Roboto Condensed', sans-serif;
  margin-bottom: 0.5rem;
}

a {
  color: var(--primary);
  text-decoration: none;
}

button, .btn {
  display: inline-block;
  padding: 8px 16px;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 180ms ease;
}

button:hover, .btn:hover {
  background-color: var(--primary-dark);
}

button:disabled, .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-success {
  background-color: var(--success);
}

.btn-success:hover {
  background-color: #206e45;
}

.btn-danger {
  background-color: var(--danger);
}

.btn-danger:hover {
  background-color: #b22a2a;
}

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background-color: var(--input-bg);
  transition: all 180ms ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.2);
}

label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
}

.form-group {
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.form-group:has(.product-search-popup) {
  z-index: 100000;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background-color: #edf2f7;
  color: var(--tertiary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 12px;
  padding: 10px 12px;
  text-align: left;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}

tr:nth-child(even) {
  background-color: var(--background);
}

tr:hover {
  background-color: #ebf8ff;
}

.section {
  background-color: var(--card-bg);
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.section-header {
  display: none;
}

.section-body {
  padding: 20px;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 12px;
}

.badge-pending {
  background-color: rgba(74, 85, 104, 0.1);
  color: var(--tertiary);
}

.badge-partial {
  background-color: rgba(221, 107, 32, 0.1);
  color: var(--warning);
}

.badge-complete {
  background-color: rgba(56, 161, 105, 0.1);
  color: var(--success);
}

.badge-low {
  background-color: rgba(229, 62, 62, 0.1);
  color: var(--danger);
}

.badge-medium {
  background-color: rgba(221, 107, 32, 0.1);
  color: var(--warning);
}

.badge-high {
  background-color: rgba(56, 161, 105, 0.1);
  color: var(--success);
}

.alert {
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 16px;
}

.alert-success {
  background-color: rgba(56, 161, 105, 0.1);
  border-left: 4px solid var(--success);
  color: var(--success);
}

.alert-error {
  background-color: rgba(229, 62, 62, 0.1);
  border-left: 4px solid var(--danger);
  color: var(--danger);
}

.card {
  background-color: var(--card-bg);
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.danger-zone {
  border: 1px solid var(--danger);
  background-color: rgba(229, 62, 62, 0.05);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.justify-between {
  justify-content: space-between;
}

.items-center {
  align-items: center;
}

.gap-2 {
  gap: 8px;
}

.gap-4 {
  gap: 16px;
}

.grid {
  display: grid;
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.col-span-2 {
  grid-column: span 2;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-sm {
  font-size: 12px;
}

.text-lg {
  font-size: 16px;
}

.font-bold {
  font-weight: 700;
}

.font-medium {
  font-weight: 500;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-4 {
  margin-bottom: 16px;
}

.mb-6 {
  margin-bottom: 24px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-4 {
  margin-top: 16px;
}

.w-full {
  width: 100%;
}

.main-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background-color: var(--card-bg);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  overflow-y: auto;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
}

.content {
  flex: 1;
  padding: 20px;
  margin-left: 250px;
}

.logo-container {
  padding: 10px;
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.logo {
  max-width: 90%;
  max-height: 80px;
}

.nav-item {
  display: block;
  padding: 12px 18px;
  color: var(--text);
  border-left: 3px solid transparent;
  transition: all 180ms ease;
}

.nav-item:hover {
  background-color: #f8f9fa;
}

.nav-item.active {
  background-color: #e9ecef;
  font-weight: 500;
  border-left-color: var(--primary);
}

.nav-item::before {
  content: '•';
  margin-right: 10px;
}

.hidden {
  display: none;
}

.product-image {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
}

.image-placeholder {
  width: 40px;
  height: 40px;
  background-color: #edf2f7;
  border-radius: 4px;
}

.categories-tree .category {
  padding: 8px 12px;
  margin-bottom: 4px;
  background-color: var(--card-bg);
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.categories-tree .category.main {
  border-left: 3px solid var(--primary);
}

.categories-tree .category.sub {
  border-left: 3px solid var(--accent);
  margin-left: 20px;
}

.action-btn {
  cursor: pointer;
  color: var(--tertiary);
  margin-left: 8px;
}

.action-btn:hover {
  color: var(--danger);
}

.bg-light {
  background-color: var(--primary-light);
}

.border {
  border: 1px solid var(--border);
}

.rounded {
  border-radius: 4px;
}

.p-4 {
  padding: 16px;
}

.list-disc {
  list-style-type: disc;
}

.list-decimal {
  list-style-type: decimal;
}

.pl-5 {
  padding-left: 20px;
}

.login-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  background: white;
  border-radius: 8px;
  padding: 30px;
  width: 400px;
  max-width: 90%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 20px;
}

.login-logo img {
  max-width: 150px;
  height: auto;
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-light);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* Optimized loading states */
.loading-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.optimized-input {
  transition: none; /* Remove transitions for better performance */
}

.optimized-table {
  table-layout: fixed; /* Faster rendering */
}

/* Reduce repaints and reflows */
.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform;
}

/* Compressed image loading */
.lazy-image {
  opacity: 0;
  transition: opacity 0.3s;
}

.lazy-image.loaded {
  opacity: 1;
}

/* Enhanced search popup styling for product formula */
.product-search-popup {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: white;
  border: 2px solid #2c5282;
  border-radius: 8px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.25);
  z-index: 99999;
  max-height: 400px;
  overflow-y: auto;
  width: 100%;
  min-width: 300px;
  margin-top: 2px;
}

.product-search-item {
  padding: 15px 20px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
  background-color: white;
}

.product-search-item:hover {
  background-color: #f8fafc;
  border-left: 4px solid #2c5282;
  padding-left: 16px;
  color: #2c5282;
}

.product-search-item:last-child {
  border-bottom: none;
}

@media (max-width: 1024px) {
  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: relative;
    overflow-x: auto;
    white-space: nowrap;
    height: auto;
  }
  
  .nav-item {
    display: inline-block;
    padding: 12px 24px;
  }
  
  .content {
    margin-left: 0;
  }
  
  .grid-cols-3, .grid-cols-2 {
    grid-template-columns: 1fr;
  }
  
  button, .btn {
    min-height: 44px;
    padding: 10px 16px;
  }
  
  .desktop-only {
    display: none;
  }
}

@media print {
  body.printing-price-list * {
    visibility: hidden;
  }
  
  body.printing-price-list .section,
  body.printing-price-list .section * {
    visibility: visible;
  }
  
  body.printing-price-list .section {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
  }
  
  body.printing-price-list form,
  body.printing-price-list .form-group,
  body.printing-price-list button {
    display: none !important;
  }
  
  body.printing-price-list .grid,
  body.printing-price-list .mb-4:not(.print-wrapper) {
    display: none !important;
  }
  
  body.printing-price-list table th:nth-child(3),
  body.printing-price-list table th:nth-child(4),
  body.printing-price-list table th:nth-child(5),
  body.printing-price-list table td:nth-child(3),
  body.printing-price-list table td:nth-child(4),
  body.printing-price-list table td:nth-child(5) {
    display: none !important;
  }

  /* Hide half price column for regular price list print */
  body.printing-price-list:not(.printing-half-price) table th:nth-child(7),
  body.printing-price-list:not(.printing-half-price) table td:nth-child(7) {
    display: none !important;
  }

  body.printing-price-list .product-image {
    width: 60px;
    height: 60px;
  }
  
  a[href]:after {
    content: none !important;
  }
  
  @page {
    size: A4;
    margin: 15mm;
    @top-left { content: none; }
    @top-center { content: none; }
    @top-right { content: none; }
    @bottom-left { content: none; }
    @bottom-center { content: none; }
    @bottom-right { content: none; }
    @top-left-corner { content: none; }
    @top-right-corner { content: none; }
    @bottom-left-corner { content: none; }
    @bottom-right-corner { content: none; }
  }

  *:before, *:after {
    content: none !important;
    display: none !important;
  }

  .url { display: none !important; }
  .page-number { display: none !important; }
  .header { display: none !important; }
  .footer { display: none !important; }
  
  html {
    -webkit-print-color-adjust: exact;
  }
  
  body {
    -webkit-print-color-adjust: exact;
  }

  /* Simple Print Styles - Same for both layouts */
  body.printing-price-list .print-header {
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    flex-direction: column;
    border-bottom: 2px solid #2c5282;
    padding-bottom: 15px;
  }
  
  body.printing-price-list .print-header img {
    height: 80px;
    margin-bottom: 10px;
  }
  
  body.printing-price-list .print-header h1 {
    display: block !important;
    font-size: 18px !important;
    font-weight: bold !important;
    color: #2c5282 !important;
    margin: 8px 0 4px 0 !important;
    text-align: center !important;
    letter-spacing: 1px !important;
  }
  
  body.printing-price-list .print-header p {
    display: block !important;
    font-size: 12px !important;
    color: #4a5568 !important;
    margin: 4px 0 0 0 !important;
    text-align: center !important;
  }

  /* Hide any title text that might appear */
  body.printing-price-list .print-header::before {
    display: none !important;
  }
  
  body.printing-price-list .print-header::after {
    display: none !important;
  }
  
  body.printing-price-list .print-wrapper {
    display: block !important;
    border: 1px solid #ccc;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    background-color: white;
  }

  body.printing-price-list .print-wrapper table {
    width: 100%;
    border-collapse: collapse;
  }
  
  body.printing-price-list .print-wrapper table th,
  body.printing-price-list .print-wrapper table td {
    border: 1px solid #ddd;
    padding: 8px;
  }
  
  body.printing-price-list .print-wrapper table th {
    background-color: #f2f2f2;
    font-weight: bold;
  }
  
  body.printing-price-list .print-wrapper table tr:nth-child(even) {
    background-color: #f9f9f9;
  }

  /* Enhanced Half Price Print Layout */
  body.printing-half-price * {
    visibility: hidden;
  }

  body.printing-half-price .section,
  body.printing-half-price .section * {
    visibility: visible;
  }
  
  body.printing-half-price .section {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
  }
  
  body.printing-half-price form,
  body.printing-half-price .form-group,
  body.printing-half-price button,
  body.printing-half-price .grid,
  body.printing-half-price .mb-4:not(.print-wrapper),
  body.printing-half-price input,
  body.printing-half-price select,
  body.printing-half-price .alert,
  body.printing-half-price h3,
  body.printing-half-price h4,
  body.printing-half-price .flex,
  body.printing-half-price .card {
    display: none !important;
  }
  
  body.printing-half-price .print-header {
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    flex-direction: column;
    border-bottom: 2px solid #2c5282;
    padding-bottom: 15px;
  }
  
  body.printing-half-price .print-header img {
    height: 80px;
    margin-bottom: 10px;
  }
  
  body.printing-half-price .print-header h1 {
    display: block !important;
    font-size: 18px !important;
    font-weight: bold !important;
    color: #2c5282 !important;
    margin: 8px 0 4px 0 !important;
    text-align: center !important;
    letter-spacing: 1px !important;
  }
  
  body.printing-half-price .print-header p {
    display: block !important;
    font-size: 12px !important;
    color: #4a5568 !important;
    margin: 4px 0 0 0 !important;
    text-align: center !important;
  }

  /* Hide all columns except image, product name, and Price for HP print */
  body.printing-half-price table th:nth-child(3),
  body.printing-half-price table th:nth-child(4),
  body.printing-half-price table th:nth-child(5),
  body.printing-half-price table td:nth-child(3),
  body.printing-half-price table td:nth-child(4),
  body.printing-half-price table td:nth-child(5) {
    display: none !important;
  }

  /* Rename HP column header to Price and hide the HP text */
  body.printing-half-price table th:nth-child(7) {
    display: table-cell !important;
  }

  body.printing-half-price table th:nth-child(7)::before {
    content: "Price" !important;
  }

  body.printing-half-price table th:nth-child(7) {
    font-size: 0 !important;
  }

  body.printing-half-price table td:nth-child(7) {
    display: table-cell !important;
  }

  /* Hide Final Price column for half price print layout */
  body.printing-half-price table th:nth-child(6),
  body.printing-half-price table td:nth-child(6) {
    display: none !important;
  }

  /* Raw Materials Print Layout */
  body.printing-raw-materials * {
    visibility: hidden;
  }
  
  body.printing-raw-materials .section,
  body.printing-raw-materials .section * {
    visibility: visible;
  }
  
  body.printing-raw-materials .section {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
  }
  
  body.printing-raw-materials form,
  body.printing-raw-materials .form-group,
  body.printing-raw-materials button,
  body.printing-raw-materials .grid,
  body.printing-raw-materials .mb-4:not(.print-wrapper) {
    display: none !important;
  }
  
  body.printing-raw-materials .print-header {
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    flex-direction: column;
    border-bottom: 2px solid #2c5282;
    padding-bottom: 15px;
  }
  
  body.printing-raw-materials .print-header img {
    height: 80px;
    margin-bottom: 10px;
  }
  
  body.printing-raw-materials .print-header h1 {
    display: block !important;
    font-size: 18px !important;
    font-weight: bold !important;
    color: #2c5282 !important;
    margin: 8px 0 4px 0 !important;
    text-align: center !important;
    letter-spacing: 1px !important;
  }
  
  body.printing-raw-materials .print-header p {
    display: block !important;
    font-size: 12px !important;
    color: #4a5568 !important;
    margin: 4px 0 0 0 !important;
    text-align: center !important;
  }
  
  body.printing-raw-materials .print-wrapper {
    display: block !important;
    border: 1px solid #ccc;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    background-color: white;
  }
  
  body.printing-raw-materials .print-wrapper table {
    width: 100%;
    border-collapse: collapse;
  }
  
  body.printing-raw-materials .print-wrapper table th,
  body.printing-raw-materials .print-wrapper table td {
    border: 1px solid #ddd;
    padding: 8px;
  }
  
  body.printing-raw-materials .print-wrapper table th {
    background-color: #f2f2f2;
    font-weight: bold;
  }
  
  body.printing-raw-materials .print-wrapper table tr:nth-child(even) {
    background-color: #f9f9f9;
  }
  
  /* Hide actions column for raw materials print */
  body.printing-raw-materials table th:last-child,
  body.printing-raw-materials table td:last-child {
    display: none !important;
  }
  
  /* Labour Transaction History Print Layout */
  body.printing-labour-transactions * {
    visibility: hidden;
  }
  
  body.printing-labour-transactions .section,
  body.printing-labour-transactions .section * {
    visibility: visible;
  }
  
  body.printing-labour-transactions .section {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
  }
  
  body.printing-labour-transactions form,
  body.printing-labour-transactions .form-group,
  body.printing-labour-transactions button,
  body.printing-labour-transactions .grid,
  body.printing-labour-transactions .mb-4:not(.print-wrapper) {
    display: none !important;
  }
  
  body.printing-labour-transactions .print-header {
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    flex-direction: column;
    border-bottom: 2px solid #2c5282;
    padding-bottom: 15px;
  }
  
  body.printing-labour-transactions .print-header img {
    height: 80px;
    margin-bottom: 10px;
  }
  
  body.printing-labour-transactions .print-header h1 {
    display: block !important;
    font-size: 18px !important;
    font-weight: bold !important;
    color: #2c5282 !important;
    margin: 8px 0 4px 0 !important;
    text-align: center !important;
    letter-spacing: 1px !important;
  }
  
  body.printing-labour-transactions .print-header p {
    display: block !important;
    font-size: 12px !important;
    color: #4a5568 !important;
    margin: 4px 0 0 0 !important;
    text-align: center !important;
  }
  
  body.printing-labour-transactions .print-wrapper {
    display: block !important;
    border: 1px solid #ccc;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    background-color: white;
  }
  
  body.printing-labour-transactions .print-wrapper table {
    width: 100%;
    border-collapse: collapse;
  }
  
  body.printing-labour-transactions .print-wrapper table th,
  body.printing-labour-transactions .print-wrapper table td {
    border: 1px solid #ddd;
    padding: 8px;
  }
  
  body.printing-labour-transactions .print-wrapper table th {
    background-color: #f2f2f2;
    font-weight: bold;
  }
  
  body.printing-labour-transactions .print-wrapper table tr:nth-child(even) {
    background-color: #f9f9f9;
  }
}