@import '../wip-shared/styles.css';

.wip-detail-page .header h1 {
  font-size: 24px;
}

.error-banner {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 13px;
}

.filters {
  background: var(--card-bg);
  padding: 16px 20px;
  border-radius: 10px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.autocomplete-container {
  position: relative;
  display: inline-block;
}

.autocomplete-container input {
  width: 180px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}

.autocomplete-container input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: var(--shadow);
  z-index: 20;
  display: none;
}

.autocomplete-dropdown.show {
  display: block;
}

.autocomplete-item,
.autocomplete-empty {
  padding: 8px 12px;
  font-size: 13px;
}

.autocomplete-item {
  cursor: pointer;
}

.autocomplete-item:hover {
  background: #f0f2ff;
}

.autocomplete-empty {
  color: var(--muted);
}

.detail-summary-row {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.detail-summary-row .summary-card.status-run,
.detail-summary-row .summary-card.status-queue,
.detail-summary-row .summary-card.status-quality-hold,
.detail-summary-row .summary-card.status-non-quality-hold {
  cursor: pointer;
  transition: all 0.2s ease;
}

.detail-summary-row .summary-card.status-run:hover,
.detail-summary-row .summary-card.status-queue:hover,
.detail-summary-row .summary-card.status-quality-hold:hover,
.detail-summary-row .summary-card.status-non-quality-hold:hover {
  transform: translateY(-2px);
}

.detail-summary-row .summary-card.status-run {
  background: #f0fdf4;
  border-color: #22c55e;
}

.detail-summary-row .summary-card.status-queue {
  background: #fffbeb;
  border-color: #f59e0b;
}

.detail-summary-row .summary-card.status-quality-hold {
  background: #fef2f2;
  border-color: #ef4444;
}

.detail-summary-row .summary-card.status-non-quality-hold {
  background: #fff7ed;
  border-color: #f97316;
}

.detail-summary-row .summary-card.status-run .summary-value {
  color: #166534;
}

.detail-summary-row .summary-card.status-queue .summary-value {
  color: #92400e;
}

.detail-summary-row .summary-card.status-quality-hold .summary-value {
  color: #991b1b;
}

.detail-summary-row .summary-card.status-non-quality-hold .summary-value {
  color: #9a3412;
}

.detail-summary-row .summary-card.active {
  border-width: 3px;
  transform: scale(1.03);
}

.detail-summary-row.filtering .summary-card.status-run:not(.active),
.detail-summary-row.filtering .summary-card.status-queue:not(.active),
.detail-summary-row.filtering .summary-card.status-quality-hold:not(.active),
.detail-summary-row.filtering .summary-card.status-non-quality-hold:not(.active) {
  opacity: 0.5;
}

.table-section {
  background: var(--card-bg);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}

.table-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.table-info {
  font-size: 13px;
  color: var(--muted);
}

.table-container {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 600px;
}

.table-container table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-container thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.table-container th {
  background: #f8f9fa;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}

.table-container td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
}

.table-container th.fixed-col,
.table-container td.fixed-col {
  position: sticky;
  background: #fff;
  z-index: 5;
}

.table-container th.fixed-col {
  background: #f8f9fa;
  z-index: 11;
}

.table-container th.fixed-col:nth-child(1),
.table-container td.fixed-col:nth-child(1) {
  left: 0;
  min-width: 150px;
}

.table-container th.fixed-col:nth-child(2),
.table-container td.fixed-col:nth-child(2) {
  left: 150px;
  min-width: 100px;
}

.table-container th.fixed-col:nth-child(3),
.table-container td.fixed-col:nth-child(3) {
  left: 250px;
  min-width: 120px;
}

.table-container th.fixed-col:nth-child(4),
.table-container td.fixed-col:nth-child(4) {
  left: 370px;
  min-width: 100px;
  border-right: 2px solid var(--primary);
}

.table-container tbody tr:hover td {
  background: #f8f9fc;
}

.table-container tbody tr:hover td.fixed-col {
  background: #f0f2ff;
}

.spec-col {
  background: #e8ebff;
  text-align: center;
  font-size: 12px;
  min-width: 80px;
}

.spec-cell {
  text-align: center;
  font-weight: 600;
}

.spec-cell.has-data {
  background: #d4edda;
  color: #155724;
}

.wip-status-run {
  color: #166534;
  background: #f0fdf4;
  font-weight: 600;
}

.wip-status-queue {
  color: #92400e;
  background: #fffbeb;
  font-weight: 600;
}

.wip-status-hold {
  color: #991b1b;
  background: #fef2f2;
  font-weight: 600;
}

.lot-id-link {
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s;
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
}

.lot-id-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.lot-id-link.active {
  background: rgba(102, 126, 234, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

.lot-detail-panel {
  background: var(--card-bg);
  border-radius: 10px;
  box-shadow: var(--shadow);
  margin-top: 16px;
  overflow: hidden;
}

.lot-detail-panel.show {
  display: block;
}

.lot-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.lot-detail-title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.lot-detail-title .lot-id {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 12px;
  border-radius: 6px;
  font-family: monospace;
}

.lot-detail-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.lot-detail-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lot-detail-content {
  padding: 20px;
}

.lot-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.lot-detail-section {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 14px;
}

.lot-detail-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--primary);
}

.lot-detail-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}

.lot-detail-field:last-child {
  margin-bottom: 0;
}

.lot-detail-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.lot-detail-value {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

.lot-detail-value.status-run {
  color: #166534;
  font-weight: 600;
}

.lot-detail-value.status-queue {
  color: #92400e;
  font-weight: 600;
}

.lot-detail-value.status-hold {
  color: #991b1b;
  font-weight: 600;
}

.lot-detail-loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

.lot-detail-loading.error {
  color: #991b1b;
}

@media (max-width: 1400px) {
  .detail-summary-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .lot-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1000px) {
  .detail-summary-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .autocomplete-container,
  .autocomplete-container input {
    width: 100%;
  }

  .detail-summary-row,
  .lot-detail-grid {
    grid-template-columns: 1fr;
  }
}
