/* Purchases Page Styles - Enhancements for TellerPro */

/* Purchase theme colors - green for inventory inflow */
:root {
  --purchase-primary: linear-gradient(135deg, #10b981, #059669);
  --purchase-glass: rgba(16,185,129,0.08);
  --purchase-border: rgba(16,185,129,0.2);
}

/* Purchase cards with theme accent */
.card.purchase-card {
  border-left: 4px solid #10b981;
  position: relative;
}

.card.purchase-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--purchase-primary);
}

/* Enhanced search box for products */
.search-box {
  position: relative;
}

.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  z-index: 1;
}

#product-search {
  padding-left: 42px;
  border: 2px solid var(--border-soft);
  transition: all var(--transition);
}

#product-search:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}

/* Product search dropdown */
.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  max-height: 320px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}

.search-result {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-result:hover {
  background: var(--glass-bg);
}

.search-result img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.search-result-info h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 2px 0;
}

.search-result-info p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

/* Purchase table enhancements */
#purchase-items {
  font-size: 0.88rem;
}

#purchase-items thead th {
  background: var(--bg-raised);
  position: sticky;
  top: 0;
  z-index: 5;
}

#purchase-items tbody tr {
  transition: background var(--transition);
}

#purchase-items tbody tr:hover {
  background: rgba(16,185,129,0.05);
}

#purchase-items tfoot tr {
  background: linear-gradient(135deg, rgba(16,185,129,0.1), rgba(16,185,129,0.05));
  font-weight: 700;
  color: #059669;
}

/* Input group for money fields */
.input-group input[type="number"] {
  text-align: right;
}

/* Summary card styling */
.card.mb-6 .card-header h3 {
  color: #059669;
}

/* Totals highlight */
.flex.justify-between[style*="1.4rem"] span:last-child {
  color: #059669 !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Save button accent */
.btn-primary {
  background: var(--purchase-primary) !important;
  box-shadow: 0 6px 20px rgba(16,185,129,0.4);
}

.btn-primary:hover {
  box-shadow: 0 8px 25px rgba(16,185,129,0.5);
  transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 1024px) {
  .grid-3[style*="2fr 1fr"] {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .grid-3[style*="2fr 1fr"] {
    grid-template-columns: 1fr;
  }
  
  #purchase-items {
    font-size: 0.82rem;
  }
  
  .table-wrapper {
    border-radius: 8px;
    margin: 0 -16px;
    width: calc(100% + 32px);
  }
  
  .stats-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  
  /* Search */
  .search-box { max-width: 100%; }
  .search-dropdown { max-height: 250px; }
  .search-result { padding: 10px 14px; }
  .search-result img { width: 36px; height: 36px; }
  
  /* Card */
  .card { padding: 16px; }
  .card-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  
  /* Buttons */
  .btn { padding: 12px 16px; width: 100%; justify-content: center; }
  .btn-sm { padding: 8px 12px; }
}

@media (max-width: 480px) {
  #purchase-items {
    font-size: 0.78rem;
  }
  
  .table-wrapper {
    margin: 0 -12px;
    width: calc(100% + 24px);
  }
  
  #purchase-items thead th,
  #purchase-items tbody td {
    padding: 8px 10px;
  }
  
  /* Search */
  .search-result { padding: 8px 12px; }
  .search-result img { width: 32px; height: 32px; }
  .search-result-info h4 { font-size: 0.85rem; }
  .search-result-info p { font-size: 0.75rem; }
  
  /* Card */
  .card { padding: 14px; }
  
  /* Buttons */
  .btn { padding: 11px 14px; font-size: 0.88rem; }
  .btn-sm { padding: 7px 11px; font-size: 0.82rem; }
}

/* Touch-friendly tap targets */
@media (hover: none) and (pointer: coarse) {
  .btn, .search-result {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Loading state for items */
.item-row.loading {
  opacity: 0.6;
}

.item-row.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-soft);
  border-top-color: #10b981;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  transform: translate(-50%, -50%);
}
