/* ============================================================
   Scrap Price Calculator — Frontend CSS v2
   ============================================================ */

:root {
  --spc-accent:     #f4c542;
  --spc-bg:         #ffffff;
  --spc-bg-alt:     #f8fafc;
  --spc-border:     #e2e8f0;
  --spc-text:       #1e293b;
  --spc-muted:      #64748b;
  --spc-light:      #94a3b8;
  --spc-success:    #059669;
  --spc-radius:     14px;
  --spc-radius-sm:  9px;
  --spc-shadow:     0 4px 28px rgba(0,0,0,.09);
  --spc-tr:         0.17s ease;
}

/* ── Wrapper ─────────────────────────────────────────────────────────────── */
.spc-calculator {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: var(--spc-text);
  background: var(--spc-bg);
  border: 1px solid var(--spc-border);
  border-radius: var(--spc-radius);
  box-shadow: var(--spc-shadow);
  max-width: 820px;
  margin: 0 auto;
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.spc-header {
  background: linear-gradient(135deg, #f4c542 0%, color-mix(in srgb, #f4c542 78%, black) 100%);
  color: #fff;
  padding: 22px 26px 18px;
}
.spc-header-inner {
  display: flex; align-items: center; gap: 14px; margin-bottom: 10px;
}
.spc-header-icon { font-size: 34px; line-height: 1; }
.spc-title {
  margin: 0 0 3px !important; padding: 0 !important;
  font-size: 1.4rem !important; font-weight: 800 !important;
  color: #fff !important; border: none !important;
}
.spc-subtitle { margin: 0 !important; font-size: 0.83rem; opacity: .82; }
.spc-updated {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.76rem; opacity: .78;
}
.spc-updated-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #4ade80;
  animation: spc-pulse 2.4s ease-in-out infinite;
}
@keyframes spc-pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

/* ── Form ─────────────────────────────────────────────────────────────────── */
.spc-form {
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 14px;
  background: var(--spc-bg-alt);
  border-bottom: 1px solid var(--spc-border);
}
.spc-row { display: grid; gap: 14px; }
.spc-row-2 { grid-template-columns: 1fr 1fr; }
.spc-row-3 { grid-template-columns: 1fr 1fr 1fr; }
@media(max-width:620px) { .spc-row-2, .spc-row-3 { grid-template-columns: 1fr; } }

.spc-field { display: flex; flex-direction: column; gap: 5px; }
.spc-field label {
  font-size: 0.74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .55px;
  color: var(--spc-muted);
}

/* Select */
.spc-select-wrap { position: relative; }
.spc-select-wrap::after {
  content: '▾'; position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%); color: var(--spc-muted);
  pointer-events: none; font-size: 12px;
}
.spc-select {
  width: 100%; padding: 10px 34px 10px 13px;
  border: 1.5px solid var(--spc-border); border-radius: var(--spc-radius-sm);
  background: var(--spc-bg); color: var(--spc-text);
  font-size: 0.9rem; appearance: none; cursor: pointer;
  transition: border-color var(--spc-tr), box-shadow var(--spc-tr);
  outline: none;
}
.spc-select:focus {
  border-color: var(--spc-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--spc-accent) 18%, transparent);
}
.spc-select:disabled { opacity: .5; cursor: not-allowed; background: #f1f5f9; }

/* Description */
.spc-desc-wrap {
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: var(--spc-radius-sm); padding: 10px 14px; margin-top: -2px;
}
.spc-item-description { margin: 0 0 3px !important; font-size: 0.84rem; color: #1d4ed8; }
.spc-item-note { margin: 0 !important; font-size: 0.8rem; color: #d97706; font-weight: 600; }

/* Quantity */
.spc-qty-field { max-width: 300px; }
.spc-qty-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--spc-bg); border: 1.5px solid var(--spc-border);
  border-radius: var(--spc-radius-sm); padding: 6px 12px;
  transition: border-color var(--spc-tr);
}
.spc-qty-wrap:focus-within {
  border-color: var(--spc-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--spc-accent) 18%, transparent);
}
.spc-qty-btn {
  background: none; border: none; font-size: 1.3rem; color: var(--spc-accent);
  cursor: pointer; width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--spc-tr); line-height: 1; padding: 0;
}
.spc-qty-btn:hover { background: #eff6ff; }
.spc-qty-input {
  flex: 1; border: none; outline: none; font-size: 1.05rem; font-weight: 700;
  text-align: center; background: transparent; color: var(--spc-text);
  -moz-appearance: textfield;
}
.spc-qty-input::-webkit-outer-spin-button,
.spc-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.spc-qty-unit-label { font-size: 0.82rem; color: var(--spc-muted); white-space: nowrap; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.spc-empty-state { padding: 44px 24px; text-align: center; color: var(--spc-muted); }
.spc-empty-icon  { font-size: 48px; opacity: .35; margin-bottom: 12px; }
.spc-empty-state p { margin: 0 !important; font-size: 0.92rem; }

/* ── Results ─────────────────────────────────────────────────────────────── */
.spc-results { padding: 0 24px 22px; animation: spc-fade .22s ease; }
@keyframes spc-fade { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:none} }

.spc-results-inner {
  background: var(--spc-bg); border: 1px solid var(--spc-border);
  border-radius: var(--spc-radius); overflow: hidden;
  margin-top: 18px; box-shadow: 0 2px 10px rgba(0,0,0,.05);
}
.spc-result-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px; border-bottom: 1px solid var(--spc-border);
  transition: background var(--spc-tr);
}
.spc-result-row:last-child { border-bottom: none; }
.spc-result-row:hover { background: var(--spc-bg-alt); }
.spc-result-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.88rem; color: var(--spc-muted); font-weight: 500;
}
.spc-result-icon { font-size: 1.05rem; }
.spc-result-sublabel { font-size: 0.76rem; color: var(--spc-light); font-weight: 400; }
.spc-result-value { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Total row — hero */
.spc-total-row { background: linear-gradient(135deg,#f0fdf4,#dcfce7); padding: 20px 20px; }
.spc-total-row .spc-result-label { font-size: 1rem; color: var(--spc-text); font-weight: 700; }
.spc-total-value {
  font-size: 1.6rem !important; font-weight: 900 !important;
  color: var(--spc-success) !important; font-variant-numeric: tabular-nums;
}

/* Disclaimer */
.spc-disclaimer {
  margin-top: 10px; font-size: 0.74rem;
  color: var(--spc-light); line-height: 1.5; padding: 0 2px;
}

/* ══════════════════════════════════════════════════════════════════════════
   SCRAP PRICE TABLE
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Section wrapper ─────────────────────────────────────────────────────── */
.spc-table-section {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: var(--spc-text);
  max-width: 820px;
  margin: 28px auto 0;
  border: 1px solid var(--spc-border);
  border-radius: var(--spc-radius);
  box-shadow: var(--spc-shadow);
  background: var(--spc-bg);
  overflow: hidden;
}

/* ── Table header (title + filters) ─────────────────────────────────────── */
.spc-table-header {
  background: var(--spc-bg-alt);
  border-bottom: 1px solid var(--spc-border);
  padding: 18px 22px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}

.spc-table-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  margin-right: auto;
}
.spc-table-icon { font-size: 22px; }
.spc-table-title {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  color: var(--spc-text) !important;
  border: none !important;
}
.spc-table-badge {
  background: var(--spc-accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  letter-spacing: .3px;
}

/* ── Filters row ─────────────────────────────────────────────────────────── */
.spc-table-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.spc-filter-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
}
.spc-filter-wrap label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .55px;
  color: var(--spc-muted);
}
.spc-filter-select {
  padding: 8px 30px 8px 11px !important;
  font-size: 0.84rem !important;
}
.spc-search-input {
  padding: 8px 12px;
  border: 1.5px solid var(--spc-border);
  border-radius: var(--spc-radius-sm);
  font-size: 0.84rem;
  color: var(--spc-text);
  background: var(--spc-bg);
  outline: none;
  transition: border-color var(--spc-tr), box-shadow var(--spc-tr);
}
.spc-search-input:focus {
  border-color: var(--spc-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--spc-accent) 18%, transparent);
}

/* ── Table scroll wrapper ────────────────────────────────────────────────── */
.spc-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Table ───────────────────────────────────────────────────────────────── */
.spc-price-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.spc-price-table thead tr {
  background: linear-gradient(135deg, var(--spc-accent) 0%, color-mix(in srgb, var(--spc-accent) 78%, black) 100%);
  color: #fff;
}
.spc-price-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  white-space: nowrap;
  user-select: none;
}
.spc-th-price { text-align: right; }
.spc-sortable { cursor: pointer; transition: opacity .15s; }
.spc-sortable:hover { opacity: .82; }
.spc-sort-icon { font-size: 0.8em; opacity: .6; margin-left: 4px; }
.spc-sort-asc  .spc-sort-icon::before { content: '↑'; }
.spc-sort-desc .spc-sort-icon::before { content: '↓'; }
.spc-sortable:not(.spc-sort-asc):not(.spc-sort-desc) .spc-sort-icon::before { content: '↕'; }

/* ── Rows ─────────────────────────────────────────────────────────────────── */
.spc-price-table tbody tr {
  border-bottom: 1px solid var(--spc-border);
  transition: background var(--spc-tr);
}
.spc-price-table tbody tr:last-child { border-bottom: none; }
.spc-price-table tbody tr:hover { background: #f0f9ff; }

.spc-price-table td {
  padding: 11px 16px;
  vertical-align: middle;
}

/* Category badge */
.spc-td-cat { white-space: nowrap; }
.spc-cat-badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--spc-accent) 10%, transparent);
  color: var(--spc-accent);
  border: 1px solid color-mix(in srgb, var(--spc-accent) 25%, transparent);
  white-space: nowrap;
}

.spc-td-material {
  font-weight: 500;
  color: var(--spc-text);
}

/* Price cells */
.spc-td-price {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Price tier colouring */
.spc-tr-high .spc-td-price { color: var(--spc-success); }
.spc-tr-mid  .spc-td-price { color: #d97706; }
.spc-tr-low  .spc-td-price { color: var(--spc-muted); }

/* Odd/even stripe */
.spc-price-table tbody tr:nth-child(even) { background: var(--spc-bg-alt); }
.spc-price-table tbody tr:nth-child(even):hover { background: #f0f9ff; }

/* Loading / empty states */
.spc-table-loading,
.spc-table-empty {
  text-align: center;
  padding: 42px 24px;
  color: var(--spc-muted);
  font-size: 0.9rem;
}

/* ── Disclaimer ──────────────────────────────────────────────────────────── */
.spc-table-disclaimer {
  font-size: 0.73rem;
  color: var(--spc-light);
  line-height: 1.5;
  padding: 12px 22px 16px;
  margin: 0 !important;
  border-top: 1px solid var(--spc-border);
  background: var(--spc-bg-alt);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 620px) {
  .spc-table-header { flex-direction: column; align-items: stretch; }
  .spc-table-filters { flex-direction: column; }
  .spc-filter-wrap { min-width: 0; }
  .spc-th-price:last-child,
  .spc-td-price:last-child { display: none; } /* hide lb on mobile */
}
