/* ============================================================
   Plumbers' Supply Co. — Parts Finder App
   Responsive stylesheet: Desktop · Tablet · Mobile
   ============================================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;500;600;700&family=Barlow:wght@600;700&display=swap');

/* ---------- Design Tokens ---------- */
:root {
  /* Brand Colors */
  --clr-navy:        #0d1b2e;
  --clr-navy-mid:    #14253e;
  --clr-blue:        #1565a0;
  --clr-blue-light:  #1e7dc8;
  --clr-blue-footer: #1a6db5;
  --clr-red:         #d94035;
  --clr-red-hover:   #b83229;

  /* Neutrals */
  --clr-white:       #ffffff;
  --clr-off-white:   #f4f6f9;
  --clr-border:      #d8dde5;
  --clr-text:        #1a1a2e;
  --clr-text-muted:  #5a6475;
  --clr-text-light:  #cdd5e0;

  /* Typography */
  --font-body:       'Source Sans 3', sans-serif;
  --font-heading:    'Barlow', sans-serif;

  /* Spacing */
  --space-xs:  0.375rem;
  --space-sm:  0.75rem;
  --space-md:  1.25rem;
  --space-lg:  2rem;
  --space-xl:  3rem;

  /* Radii */
  --radius-sm: 3px;
  --radius-md: 6px;

  /* Shadows */
  --shadow-card: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-btn:  0 2px 6px rgba(213,64,53,0.30);

  /* Layout */
  --max-width: 1200px;
  --header-h:  70px;
}

/* ---------- Reset / Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--clr-text);
  background: var(--clr-off-white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { display: block; max-width: 100%; }

a { text-decoration: none; color: inherit; }

/* ---------- Layout Wrapper ---------- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* ============================================================
   HEADER
   ============================================================ */

/* ---- Top Info Bar ---- */
.site-topbar {
  background: var(--clr-navy);
  color: var(--clr-text-light);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.site-topbar .container {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-lg);
  height: 36px;
}

.site-topbar a {
  color: var(--clr-text-light);
  transition: color 0.2s;
}

.site-topbar a:hover { color: var(--clr-white); }

.topbar-links {
  display: flex;
  gap: var(--space-lg);
  list-style: none;
}

/* ---- Main Header ---- */
.site-header {
  background: var(--clr-white);
  height: var(--header-h);
  border-bottom: 3px solid var(--clr-blue);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.10);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

/* Logo */
.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.site-logo img {
  height: 48px;
  width: auto;
}

/* User account link */
.header-user-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--clr-navy);
  transition: color 0.2s;
}

.header-user-link:hover { color: var(--clr-blue); }

.header-user-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  color: var(--clr-blue);
}

.header-user-label {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.header-user-greeting {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--clr-navy);
}

.header-user-sub {
  font-size: 0.72rem;
  color: var(--clr-text-muted);
  font-weight: 500;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
main {
  flex: 1;
  padding: var(--space-lg) 0 var(--space-xl);
}

/* Page Title */
.page-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  color: var(--clr-navy);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--clr-border);
}

/* ============================================================
   PARAMETERS PANEL
   ============================================================ */
.params-panel {
  background: var(--clr-white);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.params-panel h2 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--clr-navy);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--clr-blue);
  display: inline-block;
}

.params-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-md);
}

.param-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  flex: 1;
  min-width: 180px;
  max-width: 260px;
}

.param-group label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
}

.param-group select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 40px;
  padding: 0 36px 0 var(--space-sm);
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: var(--clr-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231565a0' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--clr-text);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.param-group select:focus {
  outline: none;
  border-color: var(--clr-blue);
  box-shadow: 0 0 0 3px rgba(21,101,160,0.15);
}

.param-group select:disabled {
  background-color: #f0f2f5;
  color: var(--clr-text-muted);
  cursor: not-allowed;
}

/* Go Button */
.btn-go {
  height: 40px;
  padding: 0 var(--space-lg);
  background: var(--clr-red);
  color: var(--clr-white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: var(--shadow-btn);
  flex-shrink: 0;
}

.btn-go:hover {
  background: var(--clr-red-hover);
  box-shadow: 0 4px 12px rgba(213,64,53,0.40);
}

.btn-go:active { transform: translateY(1px); }

.btn-go:disabled {
  background: #b0b8c4;
  box-shadow: none;
  cursor: not-allowed;
}

/* ============================================================
   PARTS LISTING PANEL
   ============================================================ */
.parts-panel {
  background: var(--clr-white);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.parts-panel-header {
  background: var(--clr-navy-mid);
  color: var(--clr-white);
  padding: var(--space-sm) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.parts-panel-header h2 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.parts-count {
  font-size: 0.82rem;
  color: var(--clr-text-light);
  font-weight: 500;
}

/* Parts List */
.parts-list {
  list-style: none;
}

.parts-list-empty {
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  color: var(--clr-text-muted);
  font-size: 0.95rem;
}

.parts-list-empty .empty-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-sm);
  opacity: 0.4;
}

/* Part Row */
.part-item {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--clr-border);
  transition: background 0.15s;
}

.part-item:last-child { border-bottom: none; }

.part-item:hover { background: #f7f9fc; }

/* Part Thumbnail */
.part-thumb {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f0f3f7;
  display: flex;
  align-items: center;
  justify-content: center;
}

.part-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.part-thumb .no-image {
  font-size: 0.65rem;
  color: var(--clr-text-muted);
  text-align: center;
  padding: 4px;
  line-height: 1.3;
}

/* Part Info */
.part-info {
  flex: 1;
  min-width: 0;
}

.part-number {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--clr-blue);
  margin-bottom: 4px;
}

.part-number a {
  text-decoration: underline;
}

.part-number span {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
  margin-right: 6px;
}

.part-description {
  font-size: 0.92rem;
  color: var(--clr-text);
  line-height: 1.5;
}

/* ============================================================
   PARTS SEARCH / FILTER BAR
   ============================================================ */
.parts-search {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--clr-border);
}

.parts-search-input {
  width: 100%;
  max-width: 420px;
  height: 40px;
  padding: 0 var(--space-sm);
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--clr-text);
  background: var(--clr-white);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.parts-search-input:focus {
  outline: none;
  border-color: var(--clr-blue);
  box-shadow: 0 0 0 3px rgba(21, 101, 160, 0.15);
}

.parts-search-input::placeholder {
  color: var(--clr-text-muted);
}

/* Gas Code badge — flags parts tied to a gas-code-specific equipment record */
.gas-code-badge {
  display: inline-flex;
  align-items: center;
  margin: 2px 0 4px;
  padding: 2px 9px;
  background: #fff4e0;
  color: #9a5b00;
  border: 1px solid #f0c36d;
  border-radius: 999px;
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.4;
  white-space: nowrap;
}

/* Kit badge — marks a parent part that contains kit components */
.kit-badge {
  display: inline-flex;
  align-items: center;
  margin: 4px 0 2px;
  padding: 2px 9px;
  background: #e8f0fe;
  color: #1a56c4;
  border: 1px solid #a4c0f4;
  border-radius: 999px;
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.4;
  white-space: nowrap;
}

/* Component of badge — marks a part that belongs to a parent kit */
.component-of-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: 2px 9px;
  background: #f0eafa;
  color: #6b21a8;
  border: 1px solid #c4a8e8;
  border-radius: 999px;
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.4;
  white-space: nowrap;
}

/* Row that pairs the "Component of" badge with its parent kit's details */
.component-of-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 5px;
  padding: 6px 10px;
  background: #faf7fe;
  border-left: 3px solid #c4a8e8;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.component-of-detail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.82rem;
  color: var(--clr-text);
  line-height: 1.45;
  min-width: 0;
}

/* Kit components block — sits below the kit badge */
.kit-components {
  margin-top: 6px;
}

.kit-component-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 8px 12px;
  background: #f4f7fe;
  border-left: 3px solid #a4c0f4;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.kit-component-item {
  font-size: 0.82rem;
  color: var(--clr-text);
  line-height: 1.45;
}

.kit-component-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
  margin-right: 4px;
}

.kit-component-link {
  color: var(--clr-blue);
  text-decoration: underline;
}

.kit-component-link:hover {
  color: var(--clr-blue-light);
}

.kit-component-desc {
  display: block;
  margin-top: 2px;
  color: var(--clr-text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

@media (max-width: 600px) {
  .kit-component-list {
    padding: 6px 10px;
  }
}


/* Hidden by the JS filter */
.part-item.is-hidden { display: none; }

/* Shown when the filter matches nothing */
.parts-no-matches {
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  color: var(--clr-text-muted);
  font-size: 0.95rem;
}

.parts-no-matches[hidden] { display: none; }

/* Part Actions */
.part-actions {
  flex-shrink: 0;
}

.btn-detail {
  display: inline-block;
  padding: 6px 16px;
  background: transparent;
  border: 1.5px solid var(--clr-blue);
  border-radius: var(--radius-sm);
  color: var(--clr-blue);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.btn-detail:hover {
  background: var(--clr-blue);
  color: var(--clr-white);
}

/* ============================================================
   EMPTY / INITIAL STATE
   ============================================================ */
.state-prompt {
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  color: var(--clr-text-muted);
}

.state-prompt p { font-size: 0.95rem; margin-top: var(--space-sm); }

/* ============================================================
   FOOTER — simplified: contact info + copyright only
   ============================================================ */
.site-footer {
  margin-top: auto;
}

/* Main footer band */
.footer-main {
  background: var(--clr-navy);
  padding: var(--space-lg) 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-lg);
}

/* Contact block */
.footer-contact {
  font-style: normal;
  font-size: 0.82rem;
  color: var(--clr-text-light);
  line-height: 1.85;
}

.footer-contact strong {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--clr-white);
  margin-bottom: var(--space-xs);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.footer-contact a {
  color: var(--clr-blue-light);
  transition: color 0.2s;
}

.footer-contact a:hover { color: var(--clr-white); }

/* Copyright band */
.footer-copy {
  background: var(--clr-blue-footer);
  padding: var(--space-sm) 0;
}

.footer-copy p {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.75);
  text-align: center;
}

/* ============================================================
   UTILITY
   ============================================================ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Loading indicator */
.loading-spinner {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--clr-text-muted);
  padding: var(--space-md) var(--space-lg);
}

.loading-spinner.visible { display: flex; }

.spinner-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--clr-blue);
  animation: bounce 1.2s infinite ease-in-out;
}

.spinner-dot:nth-child(2) { animation-delay: 0.2s; }
.spinner-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ============================================================
   MEDIA QUERIES
   ============================================================ */

/* ---- Tablet  (≤ 900px) ---- */
@media (max-width: 900px) {

  :root { --space-lg: 1.5rem; }

  .container { padding: 0 var(--space-md); }

  /* Header */
  .site-header { height: 60px; }
  .site-logo img { height: 40px; }

  /* Params: allow full width on each control */
  .param-group { max-width: 100%; }
}

/* ---- Mobile (≤ 600px) ---- */
@media (max-width: 600px) {

  :root { --space-lg: 1rem; }

  /* Topbar: hide on mobile */
  .site-topbar { display: none; }

  /* Header: compact */
  .site-header { height: 54px; }
  .site-logo img { height: 36px; }

  /* Page title */
  .page-title { font-size: 1.4rem; }

  /* Params form: stack vertically */
  .params-form { flex-direction: column; }
  .param-group { max-width: 100%; width: 100%; }
  .btn-go { width: 100%; justify-content: center; }

  /* Part item: slightly compact */
  .part-item { gap: var(--space-sm); padding: var(--space-sm) var(--space-md); }

  .part-thumb { width: 60px; height: 60px; }

  .part-number { font-size: 0.9rem; }
  .part-description { font-size: 0.85rem; }

  .btn-detail { padding: 5px 12px; font-size: 0.78rem; }

  /* Parts panel header */
  .parts-panel-header { flex-direction: column; align-items: flex-start; gap: 2px; }

  /* Parts search bar */
  .parts-search { padding: var(--space-sm) var(--space-md); }
  .parts-search-input { max-width: 100%; }

  /* Footer: stack contact block */
  .footer-inner { flex-direction: column; gap: var(--space-sm); }
}

/* ============================================================
   RECENT SEARCHES PANEL
   ============================================================ */
.recent-panel {
  background: var(--clr-white);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-lg);
  overflow: hidden;
}

.recent-panel-header {
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-lg);
  background: var(--clr-off-white);
  border-bottom: 1px solid var(--clr-border);
}

.recent-panel-header h2 {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
  margin: 0;
}

.recent-panel-header h2::before {
  content: "🕐";
  margin-right: 6px;
  font-size: 0.85rem;
}

.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  list-style: none;
}

.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 6px 12px;
  background: var(--clr-off-white);
  border: 1.5px solid var(--clr-border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
  max-width: 340px;
  min-width: 0;
}

.recent-chip:hover,
.recent-chip:focus-visible {
  border-color: var(--clr-blue);
  background: #eef4fb;
  box-shadow: 0 2px 8px rgba(21,101,160,0.12);
  outline: none;
}

.recent-chip:active { transform: translateY(1px); }

.recent-chip-brand {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--clr-blue);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.recent-chip-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--clr-border);
  flex-shrink: 0;
}

.recent-chip-model {
  font-size: 0.82rem;
  color: var(--clr-text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ============================================================
   PART THUMBNAIL GALLERY (multiple images)
   ============================================================ */

/* Container shown when a part has more than one thumbnail */
.part-thumb-gallery {
  display: flex;
  flex-direction: row;        /* ← was column */
  flex-wrap: wrap;            /* ← wrap to next line if too many */
  gap: 4px;
  width: auto;                /* ← was 80px; let it grow to fit images */
  flex-shrink: 0;
  max-width: 260px;           /* ← cap so it doesn't push part-info off screen */
}

.part-thumb-gallery .part-thumb {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .part-thumb-gallery {
    max-width: 160px;
  }
  .part-thumb-gallery .part-thumb {
    width: 60px;
    height: 60px;
  }
}

@media (max-width: 900px) {
  .recent-list { gap: var(--space-xs) var(--space-sm); }
  .recent-chip { max-width: 280px; }
}

@media (max-width: 600px) {
  .recent-panel-header { padding: var(--space-sm) var(--space-md); }
  .recent-list          { padding: var(--space-sm) var(--space-md); flex-direction: column; gap: var(--space-xs); }
  .recent-chip          { max-width: 100%; }
}