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

:root {
  --spc-accent:     #2563eb;
  --spc-text:       #1e293b;
  --spc-muted:      #64748b;
  --spc-light:      #94a3b8;
  --spc-border:     #e2e8f0;
  --spc-bg:         #ffffff;
  --spc-bg-alt:     #f8fafc;
  --spc-success:    #059669;
  --spc-radius:     12px;
  --spc-tr:         0.17s ease;
}

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

/* ── Controls ────────────────────────────────────────────────────────────── */
.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 var(--spc-border);
  border-radius: 8px;
  font-size: 0.9rem;
  width: 220px;
  outline: none;
  transition: border-color var(--spc-tr);
}
.spt-search:focus {
  border-color: var(--spc-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* Category filter badge */
.spt-cat-filter-bar {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
  font-size: 0.82rem;
  color: #1e40af;
  animation: spt-fade-in .2s ease;
}
.spt-cat-filter-label { color: var(--spc-muted); }
.spt-clear-cat-btn {
  background: none; border: none;
  color: #1e40af; cursor: pointer;
  font-size: 0.78rem; font-weight: 700;
  padding: 2px 6px; border-radius: 12px;
  transition: background var(--spc-tr);
}
.spt-clear-cat-btn:hover { background: #bfdbfe; }

.spt-control-group {
  display: flex; align-items: center; gap: 6px; font-size: 0.82rem;
}
.spt-control-group label { color: var(--spc-muted); font-weight: 600; white-space: nowrap; }

.spt-select {
  padding: 7px 28px 7px 10px;
  border: 1.5px solid var(--spc-border);
  border-radius: 7px;
  font-size: 0.85rem;
  appearance: none;
  background: var(--spc-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='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 9px center;
  cursor: pointer; outline: none;
  transition: border-color var(--spc-tr);
}
.spt-select:focus { border-color: var(--spc-accent); }
.spt-select-sm { padding: 5px 26px 5px 9px; font-size: 0.82rem; }

.spt-updated { font-size: 0.76rem; color: var(--spc-light); white-space: nowrap; }

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

.spt-th {
  padding: 12px 14px;
  text-align: left;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--spc-muted);
  background: var(--spc-bg-alt);
  border-bottom: 2px solid var(--spc-border);
  white-space: nowrap;
  user-select: none;
}
.spt-th-cat { min-width: 160px; }
.spt-sort-hint {
  display: block;
  font-size: 0.68rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--spc-light);
  margin-top: 1px;
}
.spt-sortable { cursor: pointer; }
.spt-sortable:hover { background: #f1f5f9; color: var(--spc-accent); }
.spt-sortable:focus { outline: 2px solid var(--spc-accent); outline-offset: -2px; }
.spt-sorted-asc, .spt-sorted-desc { background: #eff6ff; color: var(--spc-accent); }
.spt-sort-icon { margin-left: 4px; opacity: .5; font-size: .85em; }
.spt-sorted-asc .spt-sort-icon, .spt-sorted-desc .spt-sort-icon { opacity: 1; }
.spt-price-col { text-align: right; }

/* ── Rows ────────────────────────────────────────────────────────────────── */
.spt-row {
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background var(--spc-tr);
}
.spt-row:last-child { border-bottom: none; }
.spt-row:hover { background: #f8fafc; }
.spt-row:focus { outline: 2px solid var(--spc-accent); outline-offset: -2px; }
.spt-row-active { background: #eff6ff !important; }
.spt-row-active .spt-price-val { color: var(--spc-accent); }

.spt-td { padding: 10px 14px; vertical-align: middle; }

/* Category cell */
.spt-td-cat {
  white-space: nowrap;
  position: relative;
}
.spt-td-cat:hover { background: #f0fdf4; }
.spt-cat-icon { margin-right: 6px; font-size: 1em; }
.spt-cat-label { font-size: 0.83rem; color: var(--spc-muted); font-weight: 500; }
.spt-cat-filter-hint {
  font-size: 0.7rem;
  color: var(--spc-accent);
  opacity: 0;
  margin-left: 6px;
  transition: opacity var(--spc-tr);
  font-weight: 600;
}
.spt-row:hover .spt-cat-filter-hint { opacity: 1; }

/* Material cell */
.spt-material-name { display: block; font-size: 0.9rem; font-weight: 600; color: var(--spc-text); }
.spt-material-desc {
  display: block; font-size: 0.77rem; color: var(--spc-light);
  margin-top: 2px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 340px;
}

/* Price cell */
.spt-td-price {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  color: var(--spc-text);
}
.spt-price-sym { color: var(--spc-muted); margin-right: 2px; font-weight: 400; font-size: .85em; }
.spt-row-hint {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--spc-accent);
  margin-left: 8px;
  opacity: 0;
  transition: opacity var(--spc-tr);
  font-weight: 600;
}
.spt-row:hover .spt-row-hint { opacity: 1; }

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

/* ── Detail panel (slides in from right) ─────────────────────────────────── */
.spt-detail-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 460px;
  max-width: 100vw;
  background: var(--spc-bg);
  box-shadow: -6px 0 40px rgba(0,0,0,.18);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.34,1.1,.64,1);
  overflow: hidden;
}
.spt-panel-open { transform: translateX(0) !important; }

/* Overlay (mobile) */
.spt-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 99998;
  backdrop-filter: blur(2px);
}
.spt-panel-body-open .spt-panel-overlay { display: block; }

@media (max-width: 520px) {
  .spt-detail-panel { width: 100vw; }
}

.spt-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--spc-border);
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--spc-accent) 0%, color-mix(in srgb, var(--spc-accent) 78%, black) 100%);
  color: #fff;
}
.spt-panel-cat {
  font-size: 0.76rem; opacity: .8; margin-bottom: 4px; font-weight: 500;
}
.spt-panel-title {
  margin: 0 0 4px !important; font-size: 1.15rem !important;
  font-weight: 800 !important; color: #fff !important;
  border: none !important; padding: 0 !important;
}
.spt-panel-desc { margin: 0 !important; font-size: 0.81rem; opacity: .82; }

.spt-panel-close {
  background: rgba(255,255,255,.2); border: none; border-radius: 50%;
  width: 32px; height: 32px; flex-shrink: 0; margin-left: 10px;
  cursor: pointer; font-size: .95rem; color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--spc-tr);
}
.spt-panel-close:hover { background: rgba(255,255,255,.35); }
.spt-panel-close:focus { outline: 2px solid rgba(255,255,255,.6); outline-offset: 2px; }

.spt-panel-controls {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
  background: var(--spc-bg-alt);
}
.spt-panel-count { font-size: 0.78rem; color: var(--spc-light); }

.spt-panel-table-wrap { overflow-y: auto; flex: 1; }

.spt-panel-table { width: 100%; border-collapse: collapse; }
.spt-panel-table thead th {
  position: sticky; top: 0; background: var(--spc-bg-alt);
  padding: 9px 16px;
  text-align: left; font-size: 0.74rem;
  font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--spc-muted);
  border-bottom: 1px solid var(--spc-border);
}
.spt-panel-price-col { text-align: right; }
.spt-panel-td {
  padding: 8px 16px;
  border-bottom: 1px solid #f8fafc;
  font-size: 0.86rem;
  vertical-align: middle;
}
.spt-panel-table tbody tr:hover { background: var(--spc-bg-alt); }
.spt-panel-price {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--spc-success);
}
.spt-panel-cur-name { font-size: 0.75rem; color: var(--spc-light); font-weight: 400; }
.spt-panel-td-countries { color: var(--spc-muted); font-size: 0.81rem; }

.spt-panel-note {
  padding: 10px 18px;
  font-size: 0.74rem;
  color: var(--spc-light);
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
  margin: 0 !important;
}

@keyframes spt-fade-in { from{opacity:0;transform:translateY(-4px)} to{opacity:1;transform:none} }

@media (max-width: 480px) {
  .spt-controls { flex-direction: column; align-items: stretch; }
  .spt-controls-left, .spt-controls-right { width: 100%; }
  .spt-search { width: 100%; }
  .spt-material-desc { max-width: 180px; }
}

/* ── Clickable category cell ─────────────────────────────────────────────── */
.spt-td-cat {
  cursor: pointer;
  transition: background .13s;
  user-select: none;
}
.spt-td-cat:hover { background: #eff6ff; }
.spt-td-cat:hover .spt-cat-label { color: var(--spc-accent, #2563eb); }
.spt-cat-hint {
  font-size: 0.65rem; color: #94a3b8; margin-left: 5px;
  opacity: 0; transition: opacity .15s;
}
.spt-row:hover .spt-cat-hint { opacity: 1; }

/* ── Clickable material name ──────────────────────────────────────────────── */
.spt-material-name {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  transition: color .13s;
}
.spt-material-name:hover { color: var(--spc-accent, #2563eb); text-decoration: underline; }

/* ── Active category filter bar ──────────────────────────────────────────── */
.spt-active-cat-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 8px;
  padding: 9px 14px;
  margin-bottom: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1d4ed8;
}
.spt-clear-cat {
  background: none; border: 1.5px solid #93c5fd; border-radius: 6px;
  color: #1d4ed8; cursor: pointer; font-size: 0.8rem; font-weight: 600;
  padding: 3px 10px; transition: all .15s;
}
.spt-clear-cat:hover { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }

/* ── Modal hint line ─────────────────────────────────────────────────────── */
.spt-modal-hint {
  font-size: 0.76rem; color: #94a3b8; margin: 4px 0 0 12px;
}

/* ════════════════════════════════════════════════════════════════════════════
   Material Price Page  (.spc-material-page)
   ════════════════════════════════════════════════════════════════════════════ */

.spc-material-page {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  max-width: 860px;
  margin: 0 auto;
}

/* Breadcrumb */
.spc-mp-breadcrumb {
  font-size: 0.83rem;
  color: var(--spc-muted, #64748b);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.spc-mp-breadcrumb a { color: var(--spc-accent, #2563eb); text-decoration: none; }
.spc-mp-breadcrumb a:hover { text-decoration: underline; }

/* Header card */
.spc-mp-header {
  background: linear-gradient(135deg, var(--spc-accent, #2563eb) 0%,
              color-mix(in srgb, var(--spc-accent, #2563eb) 78%, black) 100%);
  color: #fff;
  border-radius: var(--spc-radius, 12px);
  padding: 24px 28px 22px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  position: relative;
}
.spc-mp-header-icon { font-size: 2.8rem; line-height: 1; flex-shrink: 0; }
.spc-mp-header-text { flex: 1; }
.spc-mp-category {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  opacity: .75;
  margin-bottom: 5px;
  font-weight: 600;
}
.spc-mp-title {
  margin: 0 0 8px !important;
  font-size: 1.55rem !important;
  font-weight: 800 !important;
  color: #fff !important;
  line-height: 1.2 !important;
}
.spc-mp-desc { margin: 0 0 6px !important; font-size: 0.88rem; opacity: .88; }
.spc-mp-note { margin: 0 !important; font-size: 0.82rem; opacity: .78; }
.spc-mp-updated {
  position: absolute;
  top: 18px; right: 22px;
  font-size: 0.75rem;
  opacity: .72;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Controls */
.spc-mp-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.spc-mp-hint { font-size: 0.8rem; color: var(--spc-light, #94a3b8); margin: 0; }

/* All-currency table */
.spc-mp-table-container {
  border-radius: var(--spc-radius, 12px);
  border: 1px solid var(--spc-border, #e2e8f0);
  overflow: hidden;
  box-shadow: 0 2px 14px rgba(0,0,0,.06);
  margin-bottom: 20px;
}
.spc-mp-table { width: 100%; border-collapse: collapse; background: #fff; }

.spc-mp-table thead th {
  background: var(--spc-bg-alt, #f8fafc);
  padding: 11px 16px;
  text-align: left;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--spc-muted, #64748b);
  border-bottom: 2px solid var(--spc-border, #e2e8f0);
  white-space: nowrap;
}
.spc-mp-price-col { text-align: right; }
.spc-mp-row {
  border-bottom: 1px solid #f1f5f9;
  transition: background .12s;
}
.spc-mp-row:last-child { border-bottom: none; }
.spc-mp-row:hover { background: var(--spc-bg-alt, #f8fafc); }
.spc-mp-td {
  padding: 10px 16px;
  font-size: 0.88rem;
  vertical-align: middle;
}
.spc-mp-td-countries { color: var(--spc-muted, #64748b); font-size: 0.82rem; }
.spc-mp-cur-name {
  font-size: 0.78rem;
  color: var(--spc-light, #94a3b8);
  margin-left: 5px;
  font-weight: 400;
}
.spc-mp-price {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--spc-success, #059669);
  white-space: nowrap;
}
.spc-mp-sym { font-size: .85em; font-weight: 400; margin-right: 2px; color: var(--spc-muted, #64748b); }

.spc-mp-disclaimer {
  font-size: 0.77rem;
  color: var(--spc-light, #94a3b8);
  line-height: 1.5;
}

/* Table row interaction styles */
.spt-row-linked { cursor: pointer; }
.spt-row-linked:hover .spt-price-val { color: var(--spc-accent, #2563eb); }
.spt-material-link {
  color: inherit;
  text-decoration: none;
}
.spt-material-link:hover { text-decoration: underline; color: var(--spc-accent, #2563eb); }
.spt-detail-btn--disabled { color: var(--spc-light, #94a3b8); font-size: 0.82rem; }
