/* Purchase Tracking Table & Cards CSS */

.table-responsive {
  width: 100%;
  overflow-x: auto;
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  box-shadow: var(--glass-shadow);
  margin-top: 16px;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.8rem;
}

.custom-table th {
  background: rgba(0, 0, 0, 0.02);
  padding: 10px 8px;
  font-weight: 600;
  color: var(--text-main);
  border-bottom: 1px solid var(--glass-border);
}

.dark-mode .custom-table th {
  background: rgba(255, 255, 255, 0.02);
}

.custom-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
  color: var(--text-main);
}

.dark-mode .custom-table td {
  border-bottom-color: rgba(255, 255, 255, 0.03);
}

.custom-table tbody tr {
  transition: var(--transition);
}

.custom-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.25);
}

.dark-mode .custom-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Row highlights with soft backgrounds and left borders (Light Mode) */
.custom-table tr.row-overdue td {
  background-color: rgba(239, 68, 68, 0.08) !important;
}
.custom-table tr.row-overdue:hover td {
  background-color: rgba(239, 68, 68, 0.12) !important;
}
.custom-table tr.row-overdue td:first-child {
  border-left: 4px solid var(--danger) !important;
}

.custom-table tr.row-po-issued td {
  background-color: rgba(16, 185, 129, 0.06) !important;
}
.custom-table tr.row-po-issued:hover td {
  background-color: rgba(16, 185, 129, 0.1) !important;
}
.custom-table tr.row-po-issued td:first-child {
  border-left: 4px solid var(--success) !important;
}

.custom-table tr.row-pending td {
  background-color: rgba(245, 158, 11, 0.05) !important;
}
.custom-table tr.row-pending:hover td {
  background-color: rgba(245, 158, 11, 0.09) !important;
}
.custom-table tr.row-pending td:first-child {
  border-left: 4px solid var(--warning) !important;
}

/* Row highlights with soft backgrounds (Dark Mode) */
.dark-mode .custom-table tr.row-overdue td {
  background-color: rgba(239, 68, 68, 0.15) !important;
}
.dark-mode .custom-table tr.row-overdue:hover td {
  background-color: rgba(239, 68, 68, 0.22) !important;
}

.dark-mode .custom-table tr.row-po-issued td {
  background-color: rgba(16, 185, 129, 0.1) !important;
}
.dark-mode .custom-table tr.row-po-issued:hover td {
  background-color: rgba(16, 185, 129, 0.15) !important;
}

.dark-mode .custom-table tr.row-pending td {
  background-color: rgba(245, 158, 11, 0.08) !important;
}
.dark-mode .custom-table tr.row-pending:hover td {
  background-color: rgba(245, 158, 11, 0.13) !important;
}

/* Mobile Cards Left Border Highlights */
.purchase-card.row-overdue {
  border-left: 5px solid var(--danger) !important;
}
.purchase-card.row-po-issued {
  border-left: 5px solid var(--success) !important;
}
.purchase-card.row-pending {
  border-left: 5px solid var(--warning) !important;
}

.pr-alert-flag {
  color: var(--danger);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  background: rgba(239, 68, 68, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.purchase-age {
  font-weight: 700;
  color: var(--text-main);
}

.purchase-age.warning {
  color: var(--warning);
}

.purchase-age.danger {
  color: var(--danger);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.6; }
  100% { opacity: 1; }
}

/* Purchase Status badging custom rules */
.status-pill {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  display: inline-block;
  text-align: center;
}

/* Purchase Cards (For mobile or grids) */
.purchase-grid {
  display: none;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 16px;
}

@media (max-width: 768px) {
  .table-responsive {
    display: none;
  }
  .purchase-grid {
    display: grid;
  }
}

.purchase-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.purchase-card.alert-border {
  border-left: 5px solid var(--danger);
}

.purchase-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pr-num {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
}

.purchase-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
}

.purchase-card-row {
  display: flex;
  justify-content: space-between;
}

.purchase-card-label {
  color: var(--text-muted);
}

.purchase-card-value {
  font-weight: 500;
  color: var(--text-main);
}

/* Autocomplete Suggestion Dropdown */
.autocomplete-suggestions {
  position: absolute;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--border-radius);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
  max-height: 250px;
  overflow-y: auto;
  z-index: 2000;
  padding: 6px 0;
  min-width: 450px;
  max-width: 600px;
}

.dark-mode .autocomplete-suggestions {
  background: rgba(30, 30, 30, 0.98);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.suggestion-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  transition: var(--transition);
  border-bottom: 1px dashed rgba(0, 0, 0, 0.04);
}

.dark-mode .suggestion-item {
  border-bottom-color: rgba(255, 255, 255, 0.04);
}

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

.suggestion-item:hover, .suggestion-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

.dark-mode .suggestion-item:hover, .dark-mode .suggestion-item.active {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.suggestion-item .suggestion-code {
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
  font-family: monospace;
  background: rgba(59, 130, 246, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.dark-mode .suggestion-item .suggestion-code {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.2);
}

.suggestion-item .suggestion-desc {
  color: var(--text-main);
  text-align: left;
  white-space: normal;
  word-break: break-word;
  flex-grow: 1;
  line-height: 1.4;
}

.suggestion-item .suggestion-unit {
  font-size: 0.7rem;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-weight: 600;
}

.dark-mode .suggestion-item .suggestion-unit {
  background: rgba(255, 255, 255, 0.08);
}
