/* ═══════════════════════════════════════════
   JH 靖珲面料样品库 — DESIGN_SPEC.md v1.0
   Brand: J&H Corporation (Jing Hui)
   Brand Red: #BA261C | Warm tone: #F9F8F8
   ═══════════════════════════════════════════ */

/* ───────── RESET & BASE ───────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  background: #F9F8F8;
  color: #1E1916;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* ───────── CSS VARIABLES (DESIGN_SPEC.md §八) ───────── */
:root {
  /* Brand Colors */
  --jh-red:         #BA261C;
  --jh-red-dark:    #A52018;
  --jh-red-light:   #FDF2F1;

  /* Text Colors */
  --text-primary:   #1E1916;
  --text-secondary: #5F5C5A;
  --text-tertiary:  #B4B2B1;
  --text-white:     #FFFFFF;
  --text-muted:     #B4B2B1;

  /* Backgrounds */
  --bg-body:        #F9F8F8;
  --bg-surface:     #FFFFFF;
  --bg-hover:       #F3EEEA;
  --bg-card:        #FFFFFF;
  --bg-page:        #F9F8F8;

  /* Borders */
  --border-light:   #E8E4DF;
  --border-card:    #E8E4DF;
  --border-hover:   #D4CFCA;
  --border-medium:  #D4CFCA;

  /* Shadows */
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg:      0 20px 60px rgba(0,0,0,0.12);
  --shadow-btn:     0 4px 12px rgba(186,38,28,0.25);

  /* Radius */
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      14px;
  --radius-pill:    20px;

  /* Typography */
  --font-sans:      'Inter', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;

  /* Spacing */
  --space-xs:       4px;
  --space-sm:       8px;
  --space-md:       12px;
  --space-lg:       16px;
  --space-xl:       20px;
  --space-2xl:      24px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.35s ease;

  /* Layout */
  --max-width:      1060px;
  --card-min:       280px;
}

.icon { width: 1em; height: 1em; vertical-align: -0.125em; fill: currentColor; flex-shrink: 0; }

/* ───────── HEADER ───────── */
.header {
  background: #fff;
  border-bottom: 1px solid var(--border-light);
  padding: 16px 5% 14px;
  position: relative;
  z-index: 10;
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header .brand-img {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--jh-red-light);
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.header .brand-img img {
  width: 100%; height: 100%;
  object-fit: contain;
}
.header .brand-text h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: .2px;
  line-height: 1.2;
}
.header .brand-text .sub {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 1px;
}
.header .stats {
  display: flex;
  gap: 18px;
  margin-left: auto;
  font-size: 12px;
  color: var(--text-secondary);
}
.header .stats .stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.header .stats .stat-item .num {
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.loading-bar {
  height: 2px;
  background: #E8E4DF;
  margin-top: 10px;
  border-radius: 1px;
  overflow: hidden;
}
.loading-bar .fill {
  height: 100%; width: 0%;
  background: var(--jh-red);
  border-radius: 1px;
  transition: width .3s ease;
}

/* ───────── SEARCH SECTION ───────── */
.content-wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 10px;
}
.search-section {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: var(--space-lg) 18px;
  box-shadow: var(--shadow-sm);
  margin: 14px auto 0;
}
.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.search-row .input-wrap {
  flex: 1;
  position: relative;
}
.search-row .input-wrap .search-icon {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  font-size: 16px;
  line-height: 1;
}
.search-row input {
  width: 100%;
  padding: 11px 14px 11px 40px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  background: #FAFAFA;
}
.search-row input:focus {
  border-color: var(--jh-red);
  box-shadow: 0 0 0 3px rgba(186,38,28,0.08);
  background: #fff;
}
.search-row input::placeholder { color: var(--text-tertiary); }

/* Search button — brand red + shadow */
.search-row .btn-search {
  background: var(--jh-red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition-base), transform var(--transition-fast), box-shadow var(--transition-base);
  font-weight: 500;
  box-shadow: var(--shadow-btn);
}
.search-row .btn-search:hover {
  background: var(--jh-red-dark);
  transform: translateY(-1px);
}
.search-row .btn-search:active { transform: scale(.97); }
.search-row .btn-search:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.search-row .btn-search .btn-loading {
  display: none;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
.search-row .btn-search.loading .btn-loading { display: inline-block; }
.search-row .btn-search.loading .btn-text { display: none; }

/* Outline buttons */
.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-outline:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}
.btn-outline.active {
  background: var(--jh-red-light);
  border-color: var(--jh-red);
  color: var(--jh-red);
}

.search-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

/* ───────── FILTERS (Pill Shape §5.3) ───────── */

/* ───────── FILTER SELECT DROPDOWNS (搜索升级 v2) ───────── */
.filter-select-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}
.filter-select-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-select {
  padding: 7px 28px 7px 12px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: #FAFAFA url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23B4B2B1' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--text-secondary);
  font-family: inherit;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  min-width: 100px;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
.filter-select:hover {
  border-color: var(--border-hover);
}
.filter-select:focus {
  border-color: var(--jh-red);
  box-shadow: 0 0 0 2px rgba(186,38,28,0.08);
  background-color: #fff;
}

/* ───────── RESPONSIVE: mobile dropdowns ───────── */
@media (max-width: 599px) {
  .filter-select-group {
    flex-direction: column;
    gap: 4px;
  }
  .filter-select {
    width: 100%;
    min-width: 0;
  }
}

.filter-bar {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}
.filter-bar .filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.filter-bar .filter-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 600;
  padding: 4px 4px;
  white-space: nowrap;
}
.filter-bar span.chip {
  background: #F9F8F8;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  padding: 4px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-base), color var(--transition-base),
              border-color var(--transition-base), transform var(--transition-fast);
  user-select: none;
  line-height: 1.3;
}
.filter-bar span.chip:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}
.filter-bar span.chip.active {
  background: var(--jh-red);
  color: #fff;
  border-color: var(--jh-red);
  font-weight: 500;
}
.filter-bar span.chip .count {
  opacity: .6;
  font-size: 11px;
}

/* ───────── RESULT BAR ───────── */
.result-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px auto 0;
  font-size: 13px;
  color: var(--text-secondary);
  flex-wrap: wrap;
  gap: 6px;
}
.result-bar strong { color: var(--text-primary); }

/* ───────── SKELETON LOADING ───────── */
.skeleton-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  padding: 14px;
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  margin-bottom: 8px;
  background: linear-gradient(90deg, #fff 25%, #f9f8f8 50%, #fff 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
.skeleton-card .sk-thumb {
  width: 52px; height: 52px; border-radius: var(--radius-sm);
  background: var(--border-light);
}
.skeleton-card .sk-lines {
  display: flex; flex-direction: column; gap: 7px;
  justify-content: center;
}
.skeleton-card .sk-lines .sk-line { height: 11px; border-radius: 5px; background: var(--border-light); }
.skeleton-card .sk-lines .w70 { width: 70%; }
.skeleton-card .sk-lines .w50 { width: 50%; }
.skeleton-card .sk-lines .w40 { width: 40%; }

/* ───────── NO RESULTS ───────── */
.no-results {
  text-align: center;
  padding: 60px 20px;
}
.no-results .nr-icon { font-size: 40px; margin-bottom: 12px; color: var(--text-tertiary); }
.no-results .nr-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.no-results .nr-sub { font-size: 13px; color: var(--text-tertiary); }

/* ───────── CARD GRID ───────── */
.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr));
  gap: 10px;
  margin: 0 auto;
}

/* ───────── CARD (§5.1) ───────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-card);
  padding: 14px;
  cursor: pointer;
  transition: transform var(--transition-base), box-shadow var(--transition-base),
              border-color var(--transition-base);
  opacity: 0;
  transform: translateY(8px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}
.card.visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}
.card:active { transform: translateY(0); }

.card .card-top {
  display: flex;
  gap: 12px;
}
.card .thumb {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  overflow: hidden;
  background: #F9F8F8;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1px solid var(--border-light);
}
.card .thumb img {
  width: 100%; height: 100%;
  object-fit: contain;
  transition: transform var(--transition-base);
}
.card:hover .thumb img { transform: scale(1.08); }
.card .thumb .placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: #ccc;
  font-size: 9px;
}
.card .thumb .placeholder svg { width: 24px; height: 24px; }

.card .card-info { min-width: 0; flex: 1; }
.card .row1 {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.card .artno {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}
.card .name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card .cat-badge {
  font-size: 10px;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  white-space: nowrap;
  margin-left: auto;
  flex-shrink: 0;
}

.card .tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 3px;
}
.card .tags span {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 6px;
  line-height: 1.3;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.card .tags .tag-compo {
  background: #f0f9f0;
  color: #166534;
  border: 1px solid #d1fae5;
}
.card .tags .tag-weight {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}
.card .tags .tag-spec {
  background: #f0f4ff;
  color: #3730a3;
  border: 1px solid #dbeafe;
}
.card .tags .tag-yarn {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.card .card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
  gap: 4px;
}
.card .card-footer .slk {
  color: var(--jh-red);
  font-weight: 600;
  font-size: 11px;
}

/* ───────── PAGINATION ───────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin: 16px auto;
  flex-wrap: wrap;
}
.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.pagination button:hover {
  background: var(--jh-red-light);
  border-color: var(--jh-red);
  color: var(--jh-red);
}
.pagination button.active {
  background: var(--jh-red);
  color: #fff;
  border-color: var(--jh-red);
}
.pagination button:disabled { opacity: .3; cursor: default; }
.pagination .page-info {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 0 6px;
}

/* ───────── MODAL (§2.3, §7) ───────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; }
.modal-overlay.show .modal-box {
  animation: modalIn 0.28s ease both;
}
.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform-origin: center;
}

.modal-header {
  padding: 18px 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.modal-header h2 {
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}
.modal-header .close-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: background var(--transition-fast), color var(--transition-fast);
  border: none;
  background: transparent;
  font-size: 18px;
  flex-shrink: 0;
}
.modal-header .close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Modal body: left image, right fields (desktop) */
.modal-body {
  padding: 14px 20px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.modal-photo {
  border-radius: var(--radius-md);
  background: #F9F8F8;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-tertiary);
  border: 1px dashed var(--border-light);
  overflow: hidden;
  position: relative;
}
.modal-photo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.modal-photo .ph-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #ccc;
}

.modal-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-content: start;
}
.modal-field .label {
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.modal-field .value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-top: 1px;
  word-break: break-word;
}
.modal-field.full { grid-column: 1 / -1; }

/* ───────── FOOTER ───────── */
.app-footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 16px auto 0;
  border-top: 1px solid var(--border-light);
  max-width: var(--max-width);
}

/* ───────── KEYFRAMES (§7) ───────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ───────── RESPONSIVE (§六) ───────── */
/* Tablet: 600-899px */
@media (max-width: 899px) {
  .card-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

/* Mobile: 0-599px */
@media (max-width: 599px) {
  .header { padding: 12px 4% 10px; }
  .header .brand-img { width: 32px; height: 32px; }
  .header .brand-text h1 { font-size: 18px; }
  .header .stats {
    font-size: 11px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .header .stats .stat-item:nth-child(n+3) { display: none; }
  .header-inner { gap: 8px; }

  .card-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .search-row { flex-wrap: wrap; }
  .search-row .btn-search { width: 100%; justify-content: center; }
  .btn-outline { padding: 8px 10px; font-size: 12px; }

  .search-section { padding: var(--space-md) 14px; }

  /* Mobile modal: full-screen, photo on top */
  .modal-overlay { padding: 0; background: rgba(0,0,0,0.5); }
  .modal-box {
    max-height: 100vh;
    max-width: 100%;
    border-radius: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
  }
  .modal-body {
    grid-template-columns: 1fr;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
  }
  .modal-photo {
    max-height: 50vh;
    min-height: 160px;
  }
  .modal-fields { grid-template-columns: 1fr; }

  .card { padding: 12px; }
  .card .thumb { width: 56px; height: 56px; }
  .card .artno { font-size: 14px; }
  .card .name { font-size: 12px; }

  .filter-bar .filter-group.collapsible {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }
  .filter-bar .filter-group.collapsible.open { max-height: 300px; }
}
