/* ===== BASE STYLES ===== */
:root {
  --primary: #1b3585;
  --primary-light: #3b82f6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #1f2937;
  --text-light: #6b7280;
  --bg-light: #f8fafc;
  --border: #e5e7eb;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== GLOBAL RESETS ===== */
.select2-container--default .select2-selection--single {
  border-radius: var(--radius);
}

/* ===== LAYOUT COMPONENTS ===== */
/* Header */
.skin-blue .main-header .navbar,
.skin-blue-light .main-header .navbar,
.bg-primary {
  background-color: var(--primary) !important;
}

.skin-blue-light .main-header .navbar .nav>li>a {
  color: #fff;
}

/* Box Component */
.box {
  position: relative;
  border-radius: var(--radius);
  background: #fff;
  border-top: 3px solid transparent;
  margin: 20px 0;
  width: 100%;
  box-shadow: 0 6px 20px 0 rgba(123, 31, 162, 0.1);
  transition: var(--transition);
}

.box:hover {
  box-shadow: 0 6px 20px 0 rgba(123, 31, 162, 0.2);
}

.box-header {
  border-radius: var(--radius) var(--radius) 0 0;
}

/* ===== DATA TABLES ===== */
.items_table {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.items_table thead {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.items_table thead th {
  font-weight: 600;
  color: #374151;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 8px; /* Reduced from 10px 8px */
  border-bottom: 2px solid var(--border);
}

.items_table tbody tr {
  transition: background-color 0.2s ease;
}

.items_table tbody tr:hover {
  background-color: var(--bg-light);
}

.items_table tbody td {
  padding: 4px 8px; /* Reduced from 8px */
  font-size: 13px;
  border-bottom: 1px solid #f3f4f6;
}

/* Zebra striping */
.items_table > tbody > tr:nth-of-type(odd) {
  background-color: #f9f9f9;
}

/* ===== TYPOGRAPHY & TEXT ===== */
.tot_qty, .tot_amt, .tot_disc, .tot_grand {
  font-size: 18px;
  color: var(--text);
  font-weight: 700;
}

.custom-font-size {
  font-size: 22px;
}

.search_item {
  text-transform: uppercase;
  font-size: 10px;
  color: #000;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== FORM ELEMENTS ===== */
.form-control {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-group-sm .form-control {
  height: 32px;
  font-size: 13px;
}

/* ===== BUTTONS ===== */
.btn {
  border-radius: var(--radius);
  font-weight: 500;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 12px;
}

/* Button Base */
.btnhold {
  border-radius: var(--radius);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: var(--transition);
  min-height: 45px;
}

.btnhold:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Primary Button */
.btn-primary, #pay_due_btn {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  border-color: var(--primary-light);
  color: white;
}

.btn-primary:hover, #pay_due_btn:hover {
  background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
}

/* Success Button */
.btn-success, #add_advance_btn {
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  border-color: var(--success);
  color: white;
}

.btn-success:hover, #add_advance_btn:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

/* Warning Button */
.btn-warning {
  background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
  border-color: var(--warning);
  color: white;
}

.btn-warning:hover {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

/* Small Buttons */
#pay_due_btn, #add_advance_btn {
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  border: none;
}

/* ===== PRODUCT GRID ===== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px; /* Further reduced from 2px */
  padding: 1px; /* Further reduced from 2px */
  max-width: 100%;
}

.product-card {
  background: linear-gradient(135deg, #fff 0%, #f8fafe 100%);
  border-radius: 6px; /* Reduced from 8px */
  box-shadow: var(--shadow);
  transition: var(--transition);
  border: 1px solid rgba(59, 130, 246, 0.1);
  margin-bottom: 0;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  min-height: 35px; /* Further reduced from 40px */
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 3px; /* Further reduced from 6px 4px */
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.product-card:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
  border-color: var(--primary-light);
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

/* Product States */
.product-card.out-of-stock {
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  opacity: 0.6;
  border-color: var(--border);
}

.product-card.service {
  background: linear-gradient(135deg, #fdf4ff 0%, #f3e8ff 100%);
  border-color: rgba(147, 51, 234, 0.2);
}

/* Product Info */
.product-info {
  padding: 0;
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.product-name {
  font-size: 9px; /* Reduced from 10px */
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1px; /* Reduced from 2px */
  line-height: 1.1; /* Reduced from 1.2 */
  max-height: 20px; /* Reduced from 24px */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.product-price {
  font-size: 10px; /* Reduced from 11px */
  font-weight: 700;
  color: var(--primary-light);
  margin: 0;
}

/* Badges */
.product-stock-badge {
  position: absolute;
  top: 1px; /* Reduced from 2px */
  right: 2px; /* Reduced from 4px */
  background: var(--success);
  color: white;
  font-size: 7px; /* Reduced from 8px */
  padding: 0px 2px; /* Reduced from 1px 3px */
  border-radius: 3px; /* Reduced from 4px */
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1px; /* Reduced from 0.2px */
}

.product-stock-badge.out-of-stock {
  background: var(--danger);
}

.product-stock-badge.service {
  background: #8b5cf6;
}

/* ===== UTILITY CLASSES ===== */
.pointer { cursor: pointer; }
.min_width { min-width: 70px; }
.item_image {
  min-width: 70px;
  min-height: 70px;
  max-width: 70px;
  max-height: 70px;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 768px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    padding: 1px;
  }
  
  .product-card {
    min-height: 40px; /* Reduced from 50px */
    padding: 4px 3px; /* Reduced from 6px 4px */
  }
  
  .product-name {
    font-size: 9px; /* Reduced from 11px */
    max-height: 22px; /* Reduced from 28px */
  }
  
  .product-price {
    font-size: 10px; /* Reduced from 12px */
  }
}

@media (min-width: 992px) {
  .product-card {
    min-height: 45px; /* Reduced from 60px */
    padding: 5px 4px; /* Reduced from 8px 6px */
  }
  
  .product-name {
    font-size: 10px; /* Reduced from 13px */
    max-height: 26px; /* Reduced from 36px */
  }
  
  .product-price {
    font-size: 11px; /* Reduced from 14px */
  }
}

/* ===== MODALS ===== */
#due_payment_modal .modal-content {
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

#due_payment_modal .alert-info {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border-color: var(--primary-light);
  color: #1e40af;
  border-radius: var(--radius);
}

/* ===== LOADING STATES ===== */
.ajax-load {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 15px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius);
  margin: 10px;
}

.loading-spinner {
  border: 2px solid var(--border);
  border-top: 2px solid var(--primary-light);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===== SCROLLBARS ===== */
.search_div::-webkit-scrollbar {
  width: 4px;
}

.search_div::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 2px;
}

.search_div::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  border-radius: 2px;
}

.search_div {
  padding: 2px; /* Add minimal padding to the container */
}