/* Archive + Modal styling (v4) */

:root {
  --pd-accent: #40d3b8;
  --pd-text: #1f2a37;
  --pd-muted: #6b7280;
  --pd-border: #e5e7eb;
  --pd-row-hover: #f5f7fa;
  --pd-input-bg: #ffffff;
}

.pd-archive-wrapper { color: var(--pd-text); }
.pd-toolbar { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }

.pd-searchbar { display: grid; grid-template-columns: 1fr 120px; gap: 12px; }
.pd-search {
  width: 100%; padding: 14px 16px !important; border: 1px solid var(--pd-border);
  border-radius: 8px; background: var(--pd-input-bg); color: var(--pd-text);
}
.pd-search::placeholder { color: #9ca3af; }
.pd-search-btn { border: none; border-radius: 8px; padding: 14px 16px; background: var(--pd-accent); color: #fff; font-weight: 600; cursor: pointer; }
.pd-search-btn:hover { opacity: .95; }

.pd-filters-row { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.pd-filter .pd-label { display: block; font-weight: 700; margin-bottom: 8px; color: var(--pd-text); }
.pd-select-wrap { position: relative; }
.pd-select { width: 100%; padding: 12px 40px 12px 14px; border: 1px solid var(--pd-border); border-radius: 8px; appearance: none; background: var(--pd-input-bg); color: var(--pd-text); }
.pd-select-wrap::after{ content: ''; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 6px solid #9ca3af; pointer-events: none; }

.pd-results { margin-top: 8px; }
.pd-archive-list { list-style: none; margin: 0; padding: 0; }
.pd-row { display: grid; grid-template-columns: 260px 1fr 1fr 160px; align-items: center; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--pd-border); transition: background .15s ease; cursor: pointer; }
.pd-row:hover { background: var(--pd-row-hover); }

/* Logo tile and image sizing to avoid stretching */
.pd-col-logo { width: 260px; }
.pd-logo-tile { width: 232px; height: 64px; background: #f3f4f6; border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pd-logo-img {
  display: block;
  /* Keep intrinsic aspect ratio; never stretch */
  width: auto;
  height: auto;
  max-width: 180px;
  max-height: 40px;
  object-fit: contain;
  filter: grayscale(16%) contrast(1.02);
  opacity: .95;
}
.pd-logo-img.placeholder { width: 180px; height: 40px; background: #e5e7eb; border-radius: 6px; }
.underline-sm { text-decoration: underline !important;}

.pd-name { font-weight: 600; color: var(--pd-text); }
.pd-cats { color: var(--pd-muted); }
.pd-col-action { text-align: right; }
.pd-learn { display: inline-block; font-weight: 600; color: #111827; text-decoration: none; }
.pd-learn:hover { text-decoration: underline; }
.pd-learn.disabled { color: #9ca3af; pointer-events: none; }

.pd-empty { color: var(--pd-muted); margin: 12px 0; }

.pd-archive-wrapper.pd-loading .pd-results { position: relative; min-height: 40px; }
.pd-archive-wrapper.pd-loading .pd-results::after { content: 'Loading...'; position: absolute; top: 12px; right: 12px; font-size: 12px; color: var(--pd-muted); }

/* Modal */
.pdm-overlay {
  position: fixed; inset: 0; background: rgba(17,24,39,.55);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .15s ease;
  z-index: 9999;
}
.pdm-overlay.is-open { opacity: 1; pointer-events: auto; }
.pdm-modal {
  position: relative;
  width: 100%; max-width: 600px; background: #fff; border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  padding: 24px 28px 28px;
}
.pdm-close { position: absolute; top: 14px; right: 18px; width: 32px; height: 32px; border: none; background: transparent; font-size: 24px; line-height: 1; cursor: pointer; color: #111827; }
.pdm-logo-wrap { display: flex; justify-content: center; margin: 8px 0 8px; }
.pdm-logo { max-width: 260px; max-height: 72px; object-fit: contain; }

.pdm-body .pdm-field { margin: 12px 0; }
.pdm-body .pdm-field strong { display: block; margin-bottom: 4px; }
.pdm-body a { color: #111827; word-break: break-word; }

.pdm-actions { display: flex; justify-content: center; margin-top: 10px; }
.pdm-learn { display: inline-block; padding: 12px 18px; border-radius: 10px; background: #e5e7eb; color: #111827; font-weight: 700; text-decoration: none; }
.pdm-learn:hover { background: #d9dbe1; }

/* Responsive modal */
@media (max-width: 760px){
  .pdm-modal { margin: 12px; padding: 20px; max-width: calc(100% - 24px); }
  .pdm-logo { max-width: 200px; }
}

/* Responsive */
@media (max-width: 960px){
  .pd-row { grid-template-columns: 200px 1fr 1fr 120px; }
  .pd-col-logo { width: 200px; }
  .pd-logo-tile { width: 180px; }
}
@media (max-width: 720px){
  .pd-filters-row { grid-template-columns: 1fr; }
  .pd-row { grid-template-columns: 1fr; gap: 10px; }
  .pd-col-action { text-align: left; }
}


/* ===== Mobile layout (no logos) ===== */
@media (max-width: 720px){
  /* Keep the toolbar exactly as-is already (searchbar then filters), just tweak spacing if needed */
  .pd-toolbar { gap: 12px; }

  /* Hide the logo column entirely */
  .pd-col-logo { display: none !important; }

  /* Reflow rows into three columns: Name | Category | Learn More */
  .pd-row {
    grid-template-columns: 1fr 1fr auto !important;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
  }

  /* Keep "Learn More" right-aligned */
  .pd-col-action { text-align: right; }

  /* Name slightly bolder and tighter for mobile */
  .pd-name { font-size: 16px; font-weight: 700; }

  /* Category in muted tone, single line if possible */
  .pd-cats { font-size: 14px; color: var(--pd-muted); }

  /* Reduce divider spacing */
  .pd-archive-list .pd-row + .pd-row { }

  /* Ensure tiles don't occupy space when hidden */
  .pd-logo-tile { display: none !important; }
}


/* ===== Mobile spacing & wrapping refinements (v5.1) ===== */
@media (max-width: 720px){
  /* Keep filters as in v5 (two columns) */

  /* Rows: allow multi-line title/category and give them room */
  .pd-row{
    grid-template-columns: 1.2fr 1fr auto !important; /* Name | Category | Learn More */
    align-items: flex-start !important;
    padding: 16px 12px !important;
    row-gap: 2px;
    column-gap: 14px !important;
  }

  /* Name & Category wrap naturally (no ellipsis here) */
  .pd-name{
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
  .pd-cats{
    font-size: 14px;
    line-height: 1.35;
    color: var(--pd-muted);
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  /* Keep Learn More on a single line, right aligned */
  .pd-col-action{ text-align: right !important; }
  .pd-col-action .pd-learn{
    white-space: nowrap !important;
    display: inline-block;
    padding-top: 2px; /* optical alignment when text wraps */
  }
}
