/* Layout principal */
#cdm-downloads {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 20px;
  margin: 30px 0;
  font-family: sans-serif;
}

/* Sidebar */
.cdm-sidebar {
  width: 25%;
  flex-shrink: 0;
  background-color: #f7fafe;
  padding: 15px;
  border-radius: 20px;
  margin-bottom: 40px;
}

.cdm-sidebar--title {
  font-family: "Poppins", Sans-serif;
  font-weight: 600 !important;
  font-size: 18px !important;
}

.cdm-sidebar label {
  display: block;
  margin: 6px 0;
}

/* Conteúdo principal */
.cdm-content {
  flex: 1;
  min-width: 0;
}

/* Topbar com pesquisa e ordenação */
.cdm-topbar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 15px;
}

.cdm-topbar-selects {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.cdm-topbar-selects select,
.cdm-topbar-selects .cdm-idiomas-inline select {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  min-width: 180px;
}

/* Pesquisa */
.cdm-pesquisa-wrapper {
  position: relative;
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  border-radius: 40px;
  border: 1px solid #d6d6d6; /* fix ; */
  font-family: "Open Sans", Sans-serif !important;
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1);
  width: 100%;
  overflow: hidden;
}

#cdm-pesquisa {
  position: relative;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  width: 1%;
  padding: .5rem 1rem;
  font-size: var(--font-size-lg);
  line-height: 1.5;
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  border: 0 !important;
  box-shadow: none;
  height: 50px;
  margin-bottom: 0 !important;
  border-radius: 0 3px 3px 0;
}

.cdm-icon-lupa {
  display: flex;
  margin-left: -1px;
}

.cdm-icon-lupa button {
  margin: 0;
  font-family: inherit;
  overflow: visible;
  text-transform: none;
  -webkit-appearance: button;
  transition: all ease-in-out 300ms;
  border: 1px solid transparent;
  user-select: none;
  letter-spacing: 1px;
  text-align: center;
  vertical-align: middle;
  display: inline-block;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  z-index: 2;
  padding: .5rem 1rem;
  font-size: var(--font-size-lg);
  line-height: 1.5;
  border-radius: .3rem;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  color: #acc4db !important;
  background: #fff !important;
  box-shadow: none;
}

#cdm-ordenacao,
#cdm-idiomas { flex: 1; }

#cdm-idiomas select { width: 100%; }

/* Breadcrumbs */
.cdm-breadcrumbs--inner {
  margin-bottom: 10px;
  background-color: rgba(0, 0, 0, .02);
  border-top: 1px solid rgba(0, 0, 0, .06);
  padding: .75rem 1.25rem;
  color: #666;
  font-size: 12px;
  font: var(--the7-base-font-big);
}
#cdm-breadcrumbs span { font-weight: 600; }

/* Categorias sidebar */
#cdm-categorias { margin-top: 10px; }
.cdm-categorias-list { list-style: none !important; padding: 0 !important; margin: 0 !important; }
.cdm-categorias-list li { margin: 5px 0; }
.cdm-categorias-list a {
  font-family: "Poppins", Sans-serif !important;
  font-size: 14px !important;
  text-decoration: none;
  color: #333;
  padding: 4px 6px;
  display: inline-block;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}
.cdm-categorias-list a:hover { background: #f0f0f0; }
.cdm-categorias-list a.active { background: #007cdc !important; color: #fff; }

/* Listagem de ficheiros */
#cdm-listagem {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font: var(--the7-base-font-big);
}

.cdm-ficheiro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: #fff;
  padding: 12px 16px;
  transition: background 0.2s;
}

.cdm-ficheiro img { height: 28px; width: 28px; }
.cdm-icone { flex-shrink: 0; margin-right: 12px; }

.cdm-nome {
  font-weight: 600;
  font-size: 15px;
  flex-grow: 1;
  font-family: "Poppins", Sans-serif;
  word-break: break-word;
}

.cdm-categoria,
.cdm-data {
  font-size: 13px;
  color: #666;
  margin-right: 20px;
  white-space: nowrap;
}

.cdm-download { display: flex; flex-shrink: 0; font-family: "Poppins", Sans-serif; }
.cdm-download a {
  padding: 8px 14px;
  background: #1d1d1d;
  color: #fff;
  text-decoration: none;
  border-radius: 999px;
  font-size: 12px;
}
.cdm-download a:hover { color: #FFF; background: #007cdc; }

/* Paginação */
#cdm-paginacao { margin-top: 20px; text-align: center; }
#cdm-paginacao button {
  margin: 0 5px;
  padding: 6px 12px;
  background: #eee;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: "Poppins", Sans-serif;
}
#cdm-paginacao button:hover { background: #e0e0e0; }
#cdm-paginacao button.active { background: #007cdc; color: #fff; }
#cdm-paginacao .cdm-ellipsis { display: inline-block; padding: 6px 10px; color: #999; font-size: 14px; }

/* ===== BREAKPOINTS ===== */

/* Laptops / small desktops (≤ 1200px) */
@media (max-width: 1200px) {
  .cdm-sidebar { width: 30%; }
  .cdm-categoria, .cdm-data { margin-right: 12px; }
}

/* Tablets (≤ 992px) */
@media (max-width: 992px) {
  .cdm-sidebar { width: 35%; }
  .cdm-content { width: calc(65% - 20px); }

  .cdm-topbar-selects { gap: 12px; }
  .cdm-topbar-selects select,
  .cdm-topbar-selects .cdm-idiomas-inline select {
    min-width: 140px;
    flex: 1 1 200px;
  }

  /* Card em grid: ícone + nome na 1ª linha, meta na 2ª, botão à direita */
  .cdm-ficheiro {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    grid-template-areas:
      "icon name btn"
      "icon meta btn";
    gap: 8px 12px;
    align-items: center;
  }
  .cdm-icone   { grid-area: icon; margin-right: 0; }
  .cdm-nome    { grid-area: name; font-size: 16px; margin: 0; }

  /* Meta numa só área, mas SEM sobreposição: usa wrapper “virtual” */
  .cdm-categoria,
  .cdm-data {
    grid-area: meta;
    display: inline-block;
    margin: 0 14px 0 0;
    color: #6b7280;
    white-space: nowrap;
  }

  .cdm-download { grid-area: btn; justify-self: end; align-self: center; }
}

/* Mobiles (≤ 768px) */
@media (max-width: 768px) {
  #cdm-downloads { flex-direction: column; }
  .cdm-sidebar { width: 100%; margin-bottom: 20px; }
  .cdm-content { width: 100%; }

  .cdm-topbar { gap: 14px; }
  .cdm-topbar-selects { flex-direction: column; gap: 10px; }
  #cdm-ordenacao, #cdm-idiomas { width: 100%; }

  /* Card em grid com áreas distintas (sem sobreposição) */
  .cdm-ficheiro {
    display: grid;
    grid-template-columns: 40px 1fr;
    grid-template-areas:
      "icon name"
      "icon cat"
      "icon date"
      "btn  btn";
    gap: 8px 12px;
    align-items: start;
  }

  .cdm-icone   { grid-area: icon; margin-right: 0; }
  .cdm-nome    { grid-area: name; font-size: 16px; margin: 0; }

  .cdm-categoria { grid-area: cat; margin: 0; color: #6b7280; font-size: 13px; white-space: normal; }
  .cdm-data     { grid-area: date; margin: 0; color: #6b7280; font-size: 13px; white-space: normal; }

  .cdm-download {
    grid-area: btn;
    grid-column: 2 / -1;       /* começa na coluna do texto */
    justify-self: end;       /* alinha à esquerda dessa coluna */
    margin-top: -40px;
  }
  .cdm-download a {
    width: 100%;
    text-align: center;
  }

  /* Paginação: mais “tap‑friendly” */
  #cdm-paginacao button {
    padding: 8px 14px;
    margin: 4px 4px;
    font-size: 12px;
  }
}

/* Mobiles pequenos (≤ 480px) */
@media (max-width: 480px) {
  .cdm-pesquisa-wrapper { border-radius: 12px; }
  #cdm-pesquisa { height: 44px; }
  .cdm-icon-lupa button { padding: .5rem .8rem; }

  .cdm-breadcrumbs--inner { font-size: 11px; padding: .5rem .75rem; }

  .cdm-nome { font-size: 15px; }
  .cdm-categoria, .cdm-data { font-size: 12px; }

  .cdm-download { grid-column: 2 / -1; justify-self: end; }
  .cdm-download a { width: auto; }

}

/* Acessibilidade: reduz movimentos se o utilizador preferir */
@media (prefers-reduced-motion: reduce) {
  .cdm-ficheiro, .cdm-categorias-list a { transition: none !important; }
}
