/* ============================================================
   companies.css — B2B companies directory: page head, search,
   category sidebar, company cards, pagination.
   Markup: includes/companies-middle.php
   ============================================================ */

/* ---- Page head + search ---- */
.page-head {
  background: linear-gradient(100deg, var(--blue-dark), var(--blue));
  color: #fff; padding: 34px 0;
}
.page-head h1 { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.page-head p { margin-top: 8px; font-size: 15px; color: #dbeafe; }

.dir-search {
  margin-top: 18px; display: flex; gap: 10px; max-width: 640px; flex-wrap: wrap;
}
.dir-search-field { position: relative; flex: 1 1 240px; min-width: 0; }
.dir-search input {
  width: 100%; height: 46px; border: none; border-radius: 8px;
  padding: 0 14px; font-size: 15px; outline: none; color: var(--text);
}
.dir-search button {
  height: 46px; border: none; border-radius: 8px; padding: 0 24px;
  background: var(--navy); color: #fff; font-size: 15px; font-weight: 600;
}
.dir-search button:hover { background: #0b1220; }
/* Live type-ahead dropdown styles are site-wide in header.css (.live-suggest). */

/* ---- Layout ---- */
.dir-layout {
  display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 22px;
  align-items: start; padding: 24px 0 8px;
}

/* ---- Category sidebar ---- */
.dir-cats {
  background: #fff; border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.dir-cats .cats-head {
  background: var(--blue); color: #fff; font-weight: 600; font-size: 15px; padding: 12px 16px;
}
.dir-cats ul { list-style: none; }
.dir-cats .cats-more {
  display: block; width: 100%; border: 0; cursor: pointer;
  padding: 11px 16px; font: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--blue); background: #f7f9ff;
  border-top: 1px solid #eef1f6; border-bottom: 1px solid #eef1f6;
}
.dir-cats .cats-more:hover:not(:disabled) { background: #eef4ff; }
.dir-cats .cats-more:disabled { opacity: .6; cursor: default; }
.dir-cats li a {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 16px; font-size: 13.5px; color: var(--text); border-bottom: 1px solid #f3f4f6;
}
.dir-cats li a:hover { background: #f0f5ff; color: var(--blue); }
.dir-cats li a.active { background: #eff4ff; color: var(--blue); font-weight: 700; }
.dir-cats li a .count {
  background: #eef2f7; color: var(--muted); border-radius: 999px;
  font-size: 11.5px; font-weight: 700; padding: 1px 8px;
}
.dir-cats .cats-all { display: block; padding: 11px 16px; font-size: 13.5px; font-weight: 600; color: var(--blue); }

/* ---- Result meta ---- */
.dir-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; flex-wrap: wrap; gap: 8px;
}
.dir-meta .count-text { font-size: 14px; color: var(--muted); }
.dir-meta .count-text strong { color: var(--navy); }
.dir-meta .active-filter {
  display: inline-flex; align-items: center; gap: 7px; background: #eff4ff; color: var(--blue);
  border: 1px solid #c7d2fe; border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600;
}
.dir-meta .active-filter a { color: var(--blue); font-weight: 800; }

/* ---- Company cards ---- */
.company-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.co-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  transition: box-shadow .15s, border-color .15s;
}
.co-card:hover { border-color: var(--blue); box-shadow: 0 6px 16px rgba(29,78,216,.10); }
.co-top { display: flex; align-items: flex-start; gap: 12px; }
.co-logo {
  width: 46px; height: 46px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 16px; background: var(--blue);
}
.co-head { min-width: 0; }
.co-name {
  font-size: 15.5px; font-weight: 700; color: var(--navy); line-height: 1.3;
  display: block; overflow: hidden; text-overflow: ellipsis;
}
.co-card:hover .co-name { color: var(--blue); }
.ws-browse { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.ws-browse .lbl { font-size: 13px; font-weight: 600; color: var(--muted, #6b7280); }
.prod-chip { font-size: 13px; font-weight: 600; text-decoration: none; background: #fff; color: var(--navy, #0f172a); border: 1px solid #dbe2ec; border-radius: 999px; padding: 5px 13px; }
.prod-chip:hover { border-color: var(--blue, #1d4ed8); color: var(--blue, #1d4ed8); }
.prod-chip.active { background: var(--blue, #1d4ed8); color: #fff; border-color: var(--blue, #1d4ed8); }
.prod-chip.clear { color: var(--muted, #6b7280); }
.co-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.co-tag { font-size: 12px; font-weight: 600; background: #eef4ff; color: var(--blue, #1d4ed8); border-radius: 6px; padding: 3px 9px; }
.co-tag.more { background: #eef1f5; color: var(--muted, #6b7280); }
.contact-locked { color: var(--muted, #6b7280); font-style: italic; }
.contact-locked a { color: var(--blue); font-style: normal; font-weight: 600; }
.cta-locked { background: #f3f4f6; color: #6b7280; border: 1px dashed #d1d5db; border-radius: 8px; padding: 10px 12px; font-size: 13px; text-align: center; }
.co-verified {
  display: inline-block; margin-left: 4px; width: 16px; height: 16px; line-height: 16px;
  text-align: center; font-size: 10px; color: #fff; background: #16a34a;
  border-radius: 50%; vertical-align: middle;
}
.co-type {
  display: inline-block; margin-top: 5px; font-size: 12px; font-weight: 600;
  color: var(--blue); background: #eef4ff; border-radius: 6px; padding: 2px 9px;
}
.co-lines { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.co-lines li { display: flex; gap: 9px; font-size: 13px; color: var(--text); line-height: 1.45; }
.co-lines li .ico { flex-shrink: 0; width: 16px; text-align: center; opacity: .8; }
.co-lines li a { color: var(--text); }
.co-lines li a:hover { color: var(--blue); }
.co-foot { margin-top: auto; }
.co-view {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600;
  color: var(--blue);
}

/* ---- Empty state ---- */
.dir-empty {
  background: #fff; border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 46px 20px; text-align: center; color: var(--muted);
}
.dir-empty .big { font-size: 40px; }
.dir-empty h3 { color: var(--navy); margin: 10px 0 4px; font-size: 18px; }

/* ---- Pagination ---- */
.pager { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; margin: 28px 0 8px; }
.pager a, .pager span {
  min-width: 40px; height: 40px; padding: 0 12px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; border: 1px solid var(--border); background: #fff; color: var(--text);
}
.pager a:hover { border-color: var(--blue); color: var(--blue); }
.pager .current { background: var(--blue); border-color: var(--blue); color: #fff; }
.pager .gap { border: none; background: none; min-width: 20px; }
.pager .disabled { opacity: .45; pointer-events: none; }

/* ============ COMPANY DETAIL ============ */
.crumb { font-size: 13px; color: #dbeafe; margin-bottom: 10px; }
.crumb a { color: #fff; font-weight: 600; }
.detail-head { display: flex; align-items: center; gap: 16px; }
.detail-head .co-logo { width: 60px; height: 60px; font-size: 22px; border-radius: 12px; }

.detail-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px;
  align-items: start; padding: 24px 0 8px;
}
.detail-card {
  background: #fff; border-radius: var(--radius); padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.detail-card h2 { font-size: 17px; color: var(--navy); margin-bottom: 16px; }
.detail-rows { list-style: none; }
.detail-rows li {
  display: flex; gap: 14px; padding: 13px 0; border-bottom: 1px solid #f3f4f6; font-size: 14.5px;
}
.detail-rows li:last-child { border-bottom: none; }
.detail-rows .r-ico {
  width: 40px; height: 40px; border-radius: 10px; background: #eef4ff; color: var(--blue);
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.detail-rows .r-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.detail-rows .r-value { font-size: 14.5px; color: var(--text); margin-top: 2px; word-break: break-word; }
.detail-rows .r-value a { color: var(--blue); }

.cta-card {
  background: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.cta-card h3 { font-size: 15px; color: var(--navy); margin-bottom: 12px; }
.cta-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 12px; border-radius: 8px; font-size: 14.5px; font-weight: 600; margin-bottom: 10px;
  border: 1px solid var(--border); color: var(--text); background: #fff;
}
.cta-btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.cta-btn.primary:hover { background: var(--blue-dark); }
.cta-btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.cta-btn:hover { border-color: var(--blue); }

.similar { list-style: none; }
.similar li a {
  display: block; padding: 11px 0; border-bottom: 1px solid #f3f4f6; font-size: 14px; color: var(--text);
}
.similar li:last-child a { border-bottom: none; }
.similar li a:hover { color: var(--blue); }
.similar .s-type { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .dir-layout { grid-template-columns: 1fr; }
  .dir-cats { order: 2; }
  .detail-layout { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .page-head { padding: 26px 0; }
  .page-head h1 { font-size: 24px; }
  .company-grid { grid-template-columns: 1fr; }
  .detail-head .co-logo { width: 50px; height: 50px; font-size: 18px; }
}

/* ---- A company's own products on its profile ---- */
/* Full width, below the info card and the sidebar. Tried pinning this to
   column 1 with the sidebar spanning both rows to close the gap under a short
   info card — it wrecked auto-placement (sidebar jumped to column 1). Full
   width is correct and gives the cards more room. */
.co-products { grid-column: 1 / -1; }
.co-products h2 { display: flex; align-items: center; gap: 9px; }
.co-pcount {
  font-size: 12px; font-weight: 700; color: var(--blue); background: #eef4ff;
  border-radius: 999px; padding: 2px 9px;
}
.cp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.cp-card {
  display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; text-decoration: none; color: inherit; background: #fff;
  transition: box-shadow .15s, border-color .15s;
}
.cp-card:hover { border-color: var(--blue); box-shadow: 0 6px 16px rgba(29,78,216,.10); }
.cp-img {
  position: relative; height: 132px; background: #f3f4f6; display: flex;
  align-items: center; justify-content: center; font-size: 44px;
}
.cp-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cp-tag {
  position: absolute; top: 7px; left: 7px; font-size: 10px; font-weight: 700;
  border-radius: 5px; padding: 2px 7px; color: #fff; letter-spacing: .3px;
}
.cp-tag.shop { background: var(--blue); }
.cp-tag.b2b { background: #6d28d9; }
.cp-body { padding: 11px 12px 13px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.cp-name { font-size: 13.5px; font-weight: 700; color: var(--navy); line-height: 1.35; }
.cp-cat { font-size: 11.5px; color: var(--muted); }
.cp-price { font-size: 14.5px; font-weight: 800; color: var(--price); margin-top: 3px; }
.cp-unit { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.cp-stock { font-size: 11.5px; color: var(--green); margin-top: auto; padding-top: 5px; }
.cp-stock.out { color: var(--red); }
.cp-more { font-size: 12.5px; color: var(--muted); margin-top: 14px; }
.cp-more a { color: var(--blue); font-weight: 600; }

@media (max-width: 760px) { .cp-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }

/* ============================================================
   Alibaba-style directory features: filters, gold badge,
   card product thumbnails, supplier-inquiry form.
   ============================================================ */

/* --- Advanced filters (sidebar) --- */
.dir-filters {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 14px 16px; margin-bottom: 18px; background: #fff;
}
.dir-filters .cats-head { margin: 0 0 10px; }
.filt-check {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  font-size: 13.5px; color: var(--text); padding: 5px 0; font-weight: 600;
}
.filt-check input { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }
.filt-loc { margin: 10px 0 4px; }
.filt-loc input {
  width: 100%; box-sizing: border-box; padding: 9px 11px; font-size: 13.5px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.filt-loc input:focus { outline: none; border-color: var(--blue); }
.filt-actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.filt-actions button {
  flex: 1; padding: 9px 12px; font-size: 13.5px; font-weight: 700; cursor: pointer;
  color: #fff; background: var(--blue); border: 0; border-radius: 8px;
}
.filt-actions button:hover { background: var(--blue-dark); }
.filt-clear { font-size: 13px; color: var(--muted); font-weight: 600; }
.filt-clear:hover { color: var(--red); }

/* --- Gold / featured supplier --- */
.co-card { position: relative; }
.co-card.featured { border-color: #f0c000; box-shadow: 0 4px 16px rgba(217,164,6,.14); }
.co-gold {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .3px;
  color: #7a5b00; background: linear-gradient(90deg,#ffe680,#f7c948);
  border-radius: 6px; padding: 2px 8px; vertical-align: middle;
}
.co-card > .co-gold { position: absolute; top: 10px; right: 10px; z-index: 1; }
h1 .co-gold { font-size: 13px; margin-left: 8px; }

/* --- Product thumbnails on directory cards --- */
.co-thumbs { display: flex; gap: 7px; margin: 10px 0 2px; }
.co-thumb {
  width: 54px; height: 54px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); flex: 0 0 auto; background: #f3f4f6;
}
.co-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* --- Card footer: view + inquire --- */
.co-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.co-inquire {
  font-size: 13px; font-weight: 700; color: var(--blue); text-decoration: none;
  border: 1px solid var(--blue); border-radius: 8px; padding: 6px 11px; white-space: nowrap;
}
.co-inquire:hover { background: var(--blue); color: #fff; }

/* --- Supplier inquiry form (company detail) --- */
.inquiry-card { grid-column: 1 / -1; scroll-margin-top: 90px; }
.inquiry-card .form-intro { font-size: 14px; color: var(--muted); margin: 4px 0 18px; }
.inquiry-card .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.inquiry-card .field { margin-bottom: 16px; }
.inquiry-card .field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.inquiry-card .field input,
.inquiry-card .field textarea {
  width: 100%; box-sizing: border-box; padding: 11px 13px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px; font-family: inherit; background: #fff;
}
.inquiry-card .field input:focus,
.inquiry-card .field textarea:focus { outline: none; border-color: var(--blue); }
.inquiry-card .field textarea { resize: vertical; min-height: 120px; }
.inquiry-card .field input.invalid,
.inquiry-card .field textarea.invalid { border-color: var(--red); background: #fef2f2; }
.inquiry-card .field-error { color: var(--red); font-size: 12.5px; margin-top: 5px; }
.inquiry-card .submit-btn {
  padding: 12px 26px; font-size: 15px; font-weight: 700; color: #fff; cursor: pointer;
  background: var(--blue); border: 0; border-radius: 8px;
}
.inquiry-card .submit-btn:hover { background: var(--blue-dark); }
/* Honeypot — MUST stay hidden (companies.css is loaded here, contact.css is not). */
.inquiry-card .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.inquiry-card .alert { padding: 12px 15px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.inquiry-card .alert.success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.inquiry-card .alert.error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* --- Inquiry modal: hidden until the CTA sets #inquiry (pure-CSS :target) --- */
.inq-modal { display: none; }
/* .open is JS-driven; :target is the no-JS fallback and is switched off once
   company.js flags <html class="inq-js"> (see js/company.js). */
.inq-modal.open,
html:not(.inq-js) .inq-modal:target {
  display: flex; position: fixed; inset: 0; z-index: 1000;
  align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.inq-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  -webkit-tap-highlight-color: transparent;
}
.inq-dialog {
  position: relative; z-index: 1; width: 100%; max-width: 620px; margin: auto;
}
.inq-close {
  position: absolute; top: 10px; right: 12px;
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  font-size: 26px; line-height: 1; color: var(--muted); text-decoration: none;
  border-radius: 8px;
}
.inq-close:hover { background: #f1f5f9; color: var(--text); }
.inq-dialog h2 { padding-right: 34px; }
body.inq-open { overflow: hidden; }

@media (max-width: 760px) {
  .inquiry-card .form-row { grid-template-columns: 1fr; gap: 0; }
  .co-foot { flex-direction: column; align-items: stretch; }
  .co-inquire { text-align: center; }
  .inq-modal.open,
  html:not(.inq-js) .inq-modal:target { padding: 20px 12px; }
}
