/* ============================================================
   Scrap Price Calculator — Price Table CSS
   ============================================================ */

/* ── Wrapper ─────────────────────────────────────────────────────────────── */
.spc-table-wrap {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--spc-text, #1e293b);
  max-width: 100%;
  position: relative;
}

/* ── Controls bar ────────────────────────────────────────────────────────── */
.spt-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 16px;
  flex-wrap: wrap;
}
.spt-controls-left, .spt-controls-right {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.spt-search {
  padding: 8px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  width: 240px;
  outline: none;
  transition: border-color .17s;
}
.spt-search:focus { border-color: var(--spc-accent, #2563eb); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.spt-control-group { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; }
.spt-control-group label { color: #64748b; font-weight: 600; white-space: nowrap; }
.spt-select {
  padding: 7px 30px 7px 10px;
  border: 1.5px solid #e2e8f0;
  border-radius: 7px;
  font-size: 0.85rem;
  appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
  cursor: pointer; outline: none;
  transition: border-color .17s;
}
.spt-select:focus { border-color: var(--spc-accent, #2563eb); }
.spt-select-sm { padding: 6px 26px 6px 9px; font-size: 0.82rem; }
.spt-updated { font-size: 0.77rem; color: #94a3b8; white-space: nowrap; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.spt-table-container { overflow-x: auto; border-radius: 12px; border: 1px solid #e2e8f0; box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.spt-table { width: 100%; border-collapse: collapse; background: #fff; }

.spt-th {
  padding: 12px 14px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
  user-select: none;
}
.spt-sortable { cursor: pointer; }
.spt-sortable:hover { background: #f1f5f9; color: var(--spc-accent, #2563eb); }
.spt-sortable:focus { outline: 2px solid var(--spc-accent, #2563eb); outline-offset: -2px; }
.spt-sorted-asc, .spt-sorted-desc { color: var(--spc-accent, #2563eb); background: #eff6ff; }
.spt-sort-icon { margin-left: 4px; opacity: .55; font-size: 0.85em; }
.spt-sorted-asc .spt-sort-icon, .spt-sorted-desc .spt-sort-icon { opacity: 1; }
.spt-price-col  { text-align: right; }
.spt-details-col { text-align: center; width: 100px; }

.spt-row {
  border-bottom: 1px solid #f1f5f9;
  transition: background .12s;
  cursor: pointer;
}
.spt-row:last-child { border-bottom: none; }
.spt-row:hover { background: #f8fafc; }
.spt-row:focus { outline: 2px solid var(--spc-accent, #2563eb); outline-offset: -2px; }

.spt-td { padding: 10px 14px; vertical-align: middle; }
.spt-td-cat { white-space: nowrap; }
.spt-cat-icon { margin-right: 6px; font-size: 1.05em; }
.spt-cat-label { font-size: 0.83rem; color: #64748b; }
.spt-material-name { display: block; font-size: 0.9rem; font-weight: 600; color: #1e293b; }
.spt-material-desc {
  display: block;
  font-size: 0.77rem; color: #94a3b8; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px;
}
.spt-td-price {
  text-align: right; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 600; color: #1e293b;
}
.spt-price-sym { color: #64748b; margin-right: 2px; font-weight: 400; font-size: 0.85em; }
.spt-td-action { text-align: center; }

.spt-detail-btn {
  background: none;
  border: 1.5px solid #e2e8f0;
  color: var(--spc-accent, #2563eb);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.spt-detail-btn:hover {
  background: var(--spc-accent, #2563eb);
  color: #fff;
  border-color: var(--spc-accent, #2563eb);
}

/* ── No results ──────────────────────────────────────────────────────────── */
.spt-no-results {
  padding: 32px; text-align: center; color: #94a3b8;
  border: 1px solid #e2e8f0; border-top: none; border-radius: 0 0 12px 12px;
}
.spt-clear-search {
  background: none; border: none; color: var(--spc-accent, #2563eb);
  cursor: pointer; font-size: 0.9rem; font-weight: 600; text-decoration: underline;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.spt-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  z-index: 99999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .22s ease;
}
.spt-modal-visible { opacity: 1 !important; }
.spt-modal-visible .spt-modal { transform: translateY(0) !important; }

@media (min-width: 640px) {
  .spt-modal-overlay { align-items: center; }
}

.spt-modal {
  background: #fff;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
  transform: translateY(40px);
  transition: transform .25s cubic-bezier(.34,1.26,.64,1);
}
@media (min-width: 640px) {
  .spt-modal { border-radius: 16px; max-height: 86vh; }
}

.spt-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 22px 14px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.spt-modal-cat { font-size: 0.78rem; color: #64748b; margin-bottom: 4px; }
.spt-modal-title { margin: 0 0 4px !important; font-size: 1.2rem !important; font-weight: 800 !important; color: #1e293b !important; border: none !important; padding: 0 !important; }
.spt-modal-subtitle { margin: 0 !important; font-size: 0.83rem; color: #64748b; }
.spt-modal-close {
  background: #f1f5f9; border: none; border-radius: 50%;
  width: 32px; height: 32px; flex-shrink: 0; margin-left: 12px; margin-top: 2px;
  cursor: pointer; font-size: 1rem; color: #64748b;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.spt-modal-close:hover { background: #e2e8f0; color: #1e293b; }
.spt-modal-close:focus { outline: 2px solid var(--spc-accent, #2563eb); outline-offset: 2px; }

.spt-modal-controls {
  padding: 12px 22px;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.spt-modal-table-wrap {
  overflow-y: auto;
  flex: 1;
  padding: 0;
}

.spt-modal-table {
  width: 100%;
  border-collapse: collapse;
}
.spt-modal-table thead th {
  position: sticky; top: 0;
  background: #f8fafc;
  padding: 10px 18px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
}
.spt-modal-price-col { text-align: right; }
.spt-modal-td { padding: 9px 18px; border-bottom: 1px solid #f8fafc; font-size: 0.88rem; vertical-align: middle; }
.spt-modal-td:last-child { border-bottom: none; }
.spt-modal-table tbody tr:hover { background: #f8fafc; }
.spt-modal-price {
  text-align: right; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #059669;
}
.spt-modal-cur-name { font-size: 0.78rem; color: #94a3b8; font-weight: 400; }

.spt-modal-note {
  padding: 12px 22px;
  font-size: 0.76rem;
  color: #94a3b8;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
  margin: 0 !important;
}

@media (max-width: 480px) {
  .spt-controls { gap: 8px; }
  .spt-search { width: 100%; }
  .spt-controls-right { gap: 8px; width: 100%; }
  .spt-material-desc { max-width: 180px; }
}
