/**
 * PBC Documents — Product page tab, archive page, download buttons.
 *
 * BEM naming: pbc-docs__*, pbc-docs-archive__*
 * All values reference tokens.css custom properties (--pbc-*).
 *
 * @package PBC_Core
 * @since 1.2.0
 */

/* ==========================================================================
   Shared: Document Tables
   ========================================================================== */

.pbc-docs__table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #e6eaf0;
  border-radius: var(--pbc-border-radius, 8px);
}

.pbc-docs__table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: var(--pbc-text-small, 13px);
  line-height: var(--pbc-lh-small, 20px);
}

.pbc-docs__table thead {
  background: #f5f7fa;
  border-bottom: 2px solid #e6eaf0;
}

.pbc-docs__table th {
  padding: 10px 16px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6B7280;
  text-align: left;
  white-space: nowrap;
}

.pbc-docs__table td {
  padding: 12px 16px;
  color: var(--pbc-graphite, #2B3642);
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}

.pbc-docs__table tbody tr:last-child td {
  border-bottom: none;
}

.pbc-docs__table tbody tr:hover {
  background: rgba(10, 166, 180, 0.03);
}

.pbc-docs__table-actions {
  text-align: right !important;
  white-space: nowrap;
}

/* ==========================================================================
   Lot Number Code Badge
   ========================================================================== */

.pbc-docs__lot-code {
  display: inline-block;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  font-weight: 500;
  color: #1e40af;
  background: rgba(59, 130, 246, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Purity Value
   ========================================================================== */

.pbc-docs__purity-value {
  font-weight: 600;
  color: var(--pbc-graphite, #2B3642);
}

.pbc-docs__purity-value--high {
  color: #16a34a;
}

/* ==========================================================================
   QC Status Badge
   ========================================================================== */

.pbc-docs__status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.pbc-docs__status-badge--released {
  color: #16a34a;
  background: rgba(22, 163, 74, 0.1);
  border: 1px solid rgba(22, 163, 74, 0.2);
}

/* ==========================================================================
   Download Button
   ========================================================================== */

.pbc-docs__download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: 13px;
  font-weight: 600;
  color: var(--pbc-accessible-teal, #078A94);
  background: rgba(10, 166, 180, 0.08);
  border: 1px solid rgba(10, 166, 180, 0.2);
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: all 150ms ease;
}

.pbc-docs__download-btn:hover {
  color: #065d66;
  background: rgba(10, 166, 180, 0.14);
  border-color: rgba(10, 166, 180, 0.35);
  text-decoration: none;
}

.pbc-docs__download-btn:active {
  transform: translateY(1px);
}

.pbc-docs__download-btn svg {
  flex-shrink: 0;
}

.pbc-docs__file-size {
  font-weight: 400;
  font-size: 11px;
  color: #9ca3af;
}

.pbc-docs__no-file {
  font-size: 12px;
  color: #9ca3af;
  font-style: italic;
}

/* ==========================================================================
   Product Page: Documents Tab
   ========================================================================== */

.pbc-docs {
  max-width: 100%;
}

.pbc-docs__section {
  margin-bottom: 32px;
}

.pbc-docs__section:last-of-type {
  margin-bottom: 24px;
}

.pbc-docs__section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: 16px;
  font-weight: 700;
  line-height: 24px;
  color: var(--pbc-near-black, #0E1720);
  margin: 0 0 6px;
}

.pbc-docs__section-icon {
  flex-shrink: 0;
  color: var(--pbc-accessible-teal, #078A94);
}

.pbc-docs__section-desc {
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: var(--pbc-text-small, 13px);
  line-height: var(--pbc-lh-small, 20px);
  color: #6B7280;
  margin: 0 0 16px;
}

/* ==========================================================================
   COA Detail Expansion Row
   ========================================================================== */

.pbc-docs__row {
  cursor: pointer;
}

.pbc-docs__row:hover {
  background: rgba(10, 166, 180, 0.04);
}

.pbc-docs__detail-row td {
  padding: 0 16px 16px;
  background: #f9fafb;
  border-bottom: 1px solid #e6eaf0;
}

.pbc-docs__detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px 24px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid #e6eaf0;
  border-radius: 6px;
}

.pbc-docs__detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pbc-docs__detail-label {
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9ca3af;
}

.pbc-docs__detail-value {
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: 14px;
  font-weight: 500;
  color: var(--pbc-graphite, #2B3642);
}

/* ==========================================================================
   Product Page: Footer / Archive Link
   ========================================================================== */

.pbc-docs__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid #e6eaf0;
}

.pbc-docs__footer-text {
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: 12px;
  line-height: 18px;
  color: #9ca3af;
  margin: 0;
}

.pbc-docs__footer-text a {
  color: var(--pbc-accessible-teal, #078A94);
  text-decoration: none;
}

.pbc-docs__footer-text a:hover {
  text-decoration: underline;
}

.pbc-docs__archive-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: 13px;
  font-weight: 600;
  color: var(--pbc-accessible-teal, #078A94);
  text-decoration: none;
  white-space: nowrap;
  transition: color 150ms;
}

.pbc-docs__archive-link:hover {
  color: #065d66;
  text-decoration: none;
}

/* ==========================================================================
   Archive Page: Layout
   ========================================================================== */

.pbc-docs-archive {
  max-width: var(--pbc-wide-width, 1200px);
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.pbc-docs-archive__inner {
  max-width: 960px;
  margin: 0 auto;
}

/* ==========================================================================
   Archive Page: Header
   ========================================================================== */

.pbc-docs-archive__header {
  margin-bottom: 32px;
  text-align: center;
}

.pbc-docs-archive__title {
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: var(--pbc-text-h1, 36px);
  font-weight: 800;
  line-height: var(--pbc-lh-h1, 44px);
  color: var(--pbc-near-black, #0E1720);
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

.pbc-docs-archive__subtitle {
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: var(--pbc-text-body, 16px);
  line-height: var(--pbc-lh-body, 24px);
  color: #6B7280;
  margin: 0;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ==========================================================================
   Archive Page: Search Form
   ========================================================================== */

.pbc-docs-archive__search {
  margin-bottom: 32px;
}

.pbc-docs-archive__search-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.pbc-docs-archive__search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.pbc-docs-archive__search-icon {
  position: absolute;
  left: 14px;
  color: #9ca3af;
  pointer-events: none;
}

.pbc-docs-archive__search-input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: 15px;
  color: var(--pbc-graphite, #2B3642);
  border: 1px solid #d1d5db;
  border-radius: 8px;
  outline: none;
  transition: border-color 150ms, box-shadow 150ms;
  background: #ffffff;
}

.pbc-docs-archive__search-input:focus {
  border-color: var(--pbc-accessible-teal, #078A94);
  box-shadow: 0 0 0 3px rgba(10, 166, 180, 0.12);
}

.pbc-docs-archive__search-input::placeholder {
  color: #9ca3af;
}

.pbc-docs-archive__search-filters {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.pbc-docs-archive__type-select {
  padding: 10px 32px 10px 14px;
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: 14px;
  font-weight: 500;
  color: var(--pbc-graphite, #2B3642);
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%239CA3AF' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.pbc-docs-archive__type-select:focus {
  border-color: var(--pbc-accessible-teal, #078A94);
}

.pbc-docs-archive__search-btn {
  padding: 10px 24px;
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  background: var(--pbc-near-black, #0E1720);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms;
}

.pbc-docs-archive__search-btn:hover {
  background: #1a2d3d;
}

/* ==========================================================================
   Archive Page: Results
   ========================================================================== */

.pbc-docs-archive__results-count {
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: var(--pbc-text-small, 13px);
  color: #6B7280;
  margin: 0 0 16px;
}

.pbc-docs-archive__section {
  margin-bottom: 32px;
}

.pbc-docs-archive__section-title {
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--pbc-near-black, #0E1720);
  margin: 0 0 12px;
}

.pbc-docs__product-name a {
  color: var(--pbc-accessible-teal, #078A94);
  text-decoration: none;
  font-weight: 500;
}

.pbc-docs__product-name a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Archive Page: Empty State
   ========================================================================== */

.pbc-docs-archive__empty {
  text-align: center;
  padding: 48px 20px;
  color: #9ca3af;
}

.pbc-docs-archive__empty p {
  font-family: var(--pbc-font-ui, 'Inter', sans-serif);
  font-size: var(--pbc-text-body, 16px);
  line-height: var(--pbc-lh-body, 24px);
  margin: 16px 0 0;
}

/* ==========================================================================
   AJAX Loading State
   ========================================================================== */

.pbc-docs-archive__loading {
  text-align: center;
  padding: 32px 20px;
}

.pbc-docs-archive__spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid #e6eaf0;
  border-top-color: var(--pbc-accessible-teal, #078A94);
  border-radius: 50%;
  animation: pbc-spin 0.6s linear infinite;
}

@keyframes pbc-spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Responsive: Tablet
   ========================================================================== */

@media (max-width: 960px) {
  .pbc-docs-archive {
    padding: 32px 16px 48px;
  }

  .pbc-docs-archive__title {
    font-size: 28px;
    line-height: 36px;
  }
}

/* ==========================================================================
   Responsive: Mobile
   ========================================================================== */

@media (max-width: 768px) {
  /* Search form stacks vertically */
  .pbc-docs-archive__search-row {
    flex-direction: column;
    gap: 8px;
  }

  .pbc-docs-archive__search-filters {
    flex-direction: row;
  }

  .pbc-docs-archive__search-input {
    min-height: 44px;
    font-size: 16px; /* prevent iOS zoom */
  }

  .pbc-docs-archive__type-select {
    flex: 1;
    min-height: 44px;
    font-size: 16px;
  }

  .pbc-docs-archive__search-btn {
    min-height: 44px;
    flex: 1;
    font-size: 15px;
  }

  .pbc-docs-archive__title {
    font-size: 24px;
    line-height: 32px;
  }

  .pbc-docs-archive__subtitle {
    font-size: 14px;
  }

  /* Table: horizontal scroll with shadow hint */
  .pbc-docs__table-wrap {
    position: relative;
  }

  .pbc-docs__table th,
  .pbc-docs__table td {
    padding: 10px 12px;
    font-size: 12px;
  }

  /* Product tab footer stacks */
  .pbc-docs__footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* Section titles */
  .pbc-docs__section-title {
    font-size: 15px;
  }

  .pbc-docs__section-desc {
    font-size: 12px;
  }

  /* Detail grid */
  .pbc-docs__detail-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 16px;
    padding: 12px;
  }

  /* Download button — full width on mobile */
  .pbc-docs__download-btn {
    padding: 8px 12px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .pbc-docs__detail-grid {
    grid-template-columns: 1fr;
  }

  .pbc-docs-archive__search-filters {
    flex-direction: column;
  }
}
