/* ========= SatDL — Pill search + AdSense + Categories Grid + Sticky Files (Desktop) ========= */

/* ---------- Vars ---------- */
:root{
  /* pill search */
  --pill-h: 46px;
  --pill-bg: #f3f3fa;
  --pill-radius: 999px;
  --pill-pad-x: 12px;
  --pill-font: 16px;
  --pill-fg: #333;
  --pill-ph: #9aa0a6;

  /* layout: navbar & sticky offsets */
  --nav-h: 72px; /* desktop navbar height */
}
@media (max-width:576px){
  :root{ --nav-h: 56px; }
}

/* ---------- Unified pill search (home + brand) ---------- */
:is(.star-series,.star-series_2,.all-brands,.all-brands_2) .title{
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:12px;
}
:is(.star-series,.star-series_2,.all-brands,.all-brands_2) .title .search-box{
  display:flex;
  align-items:center;
  gap:8px;
  height:var(--pill-h);
  background:var(--pill-bg);
  border-radius:var(--pill-radius);
  padding:0 var(--pill-pad-x);
  width:min(420px,100%);
  margin-left:auto;
  float:none !important;
}
:dir(rtl) :is(.star-series,.star-series_2,.all-brands,.all-brands_2) .title .search-box{
  margin-left:0;
  margin-right:auto;
}
:is(.star-series,.star-series_2,.all-brands,.all-brands_2) .title .search-box input{
  flex:1 1 auto;
  height:calc(var(--pill-h) - 12px);
  padding:0;
  border:0;
  outline:0;
  background:transparent;
  font-size:var(--pill-font);
  line-height:1.2;
  color:var(--pill-fg);
  min-width:0;
}
:is(.star-series,.star-series_2,.all-brands,.all-brands_2) .title .search-box input::placeholder{
  color:var(--pill-ph);
  opacity:1;
}
:is(.star-series,.star-series_2,.all-brands,.all-brands_2) .title .search-box:focus-within{
  box-shadow:0 0 0 2px rgba(60,90,240,.15);
}
:is(.star-series,.star-series_2,.all-brands,.all-brands_2) .title .search-box label{
  width:36px; height:36px;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  pointer-events:none;
}
@media (max-width:576px){
  :is(.star-series,.star-series_2,.all-brands,.all-brands_2) .title .search-box{
    width:100%;
    order:2;
  }
}

/* ---------- AdSense reserved space (prevent CLS) ---------- */
.ad-slot{
  margin:20px 0;
  min-height:clamp(120px, 22vw, 280px);
  visibility:visible !important;
}
.ad-slot > ins.adsbygoogle{
  display:block !important;
  width:100% !important;
}
.ad-slot > ins.adsbygoogle iframe{
  display:block;
  width:100%;
}
.ad-slot + .section-content,
.section-content + .ad-slot{ margin-top:12px; }
@media (max-width:992px){
  .ad-slot{
    min-height:clamp(90px, 30vw, 140px);
    margin:16px 0;
  }
}

/* ---------- Categories Grid ---------- */
.js-grid-categories .row{
  display:grid !important;
  grid-template-columns:repeat(auto-fit, minmax(180px, 1fr));
  gap:16px 20px;
  align-items:stretch;
}
.js-grid-categories .col,
.js-grid-categories [class*="col-"]{
  width:auto !important;
  max-width:none !important;
  flex:none !important;
}
.js-grid-categories .row > *{ min-width:0; }
.js-grid-categories .card,
.js-grid-categories .category-item{ height:100%; }
@media (max-width:1200px){
  .js-grid-categories .row{
    grid-template-columns:repeat(auto-fit, minmax(160px, 1fr));
  }
}
@media (max-width:576px){
  .js-grid-categories .row{ grid-template-columns:repeat(2, 1fr); }
}

/* ---------- Sticky Files block (Desktop) ---------- */
/* allow sticky to render correctly */
#files-list,
#files-list .newest-files,
#files-list .new-content{ overflow:visible; }

/* sticky: title + counters */
.files-sticky{
  position:sticky;
  top:var(--nav-h);
  z-index:30;
  background:#fff;
  border-radius:16px 16px 0 0;
  padding:16px 20px 0;
  will-change:transform;
}
.files-sticky.is-stuck{ box-shadow:0 6px 16px rgba(0,0,0,.08); }

/* ---------- Desktop-only sticky header row + alignment ---------- */
@media (min-width:992px){
  /* Sticky purple header just under the title/counters */
  .files-head-stick{
    position:sticky;
    top:calc(var(--nav-h) + 60px);           /* tweak 56–68 if needed */
    z-index:31;
    display:grid;
    grid-template-columns: 160px 220px 1fr 120px 160px 120px; /* MUST match table */
    background:#4f45a6;
    color:#fff;
    padding:12px 16px;                       /* match table cells */
    font-weight:600;
    box-sizing:border-box;
  }
  .files-head-stick > div{ white-space:nowrap; }

  /* Align text of sticky header same as table columns */
  .files-head-stick > div:nth-child(1),
  .files-head-stick > div:nth-child(4),
  .files-head-stick > div:nth-child(5),
  .files-head-stick > div:nth-child(6){ text-align:center; }
  .files-head-stick > div:nth-child(2),
  .files-head-stick > div:nth-child(3){ text-align:left; }

  /* Hide native thead to avoid double bars on desktop */
  .files-table thead{ display:none !important; }
  .files-table thead th{
    position:static !important;
    top:auto !important;
    background:transparent !important;
    box-shadow:none !important;
  }

  /* Make the table obey fixed column widths identical to the sticky header */
  .files-table table{
    table-layout: fixed !important;
    width: 100% !important;
    border-collapse: collapse !important;    /* critical for pixel-perfect align */
  }

  /* Uniform padding & alignment */
  .files-table thead th,
  .files-table tbody td{
    padding:12px 16px !important;
    box-sizing:border-box;
  }

  /* Column widths (match grid-template-columns order) */
  .files-table tbody td:nth-child(1){ width:160px !important; } /* BRAND (logo) */
  .files-table tbody td:nth-child(2){ width:220px !important; } /* PRODUCT */
  .files-table tbody td:nth-child(3){ width:auto  !important; } /* TITLE AND DESCRIPTION */
  .files-table tbody td:nth-child(4){ width:120px !important; } /* SIZE */
  .files-table tbody td:nth-child(5){ width:160px !important; } /* UPLOADER */
  .files-table tbody td:nth-child(6){ width:120px !important; } /* DATE */

  /* Center short/numeric columns in body */
  .files-table tbody td:nth-child(1),
  .files-table tbody td:nth-child(4),
  .files-table tbody td:nth-child(5),
  .files-table tbody td:nth-child(6){
    text-align:center;
    vertical-align:middle;
  }

  /* Left align product + title in body for readability */
  .files-table tbody td:nth-child(2),
  .files-table tbody td:nth-child(3){
    text-align:left;
    vertical-align:middle;
  }

  /* Prevent overflow on long titles */
  .files-table tbody td:nth-child(3){
    white-space:normal;
    word-break:break-word;
  }

  /* Keep brand logos from forcing column wider */
  .files-table tbody td:nth-child(1) img{
    max-width:120px;
    height:auto;
    display:block;
    margin:0 auto;
  }
}

/* Keep native thead on tablet/mobile for accessibility */
@media (max-width:991.98px){
  .files-head-stick{ display:none !important; }
}