/* =====================================================
   atividades.css — Lista e gerenciamento de atividades
   Prefixo: .atv-
   ===================================================== */

/* --- Layout ----------------------------------------- */
.atv-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* --- Cabeçalho da página ---------------------------- */
.atv-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.atv-page-head h1 {
  font-size: clamp(1.375rem, 3vw, 1.625rem);
  font-weight: 800;
  margin-bottom: 4px;
}

.atv-page-head > div > p {
  color: var(--text-muted);
  font-size: .875rem;
}

/* --- Botões ----------------------------------------- */
.atv-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: .875rem;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--t);
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
}
.atv-btn-primary:hover { background: var(--brand-dark); }
.atv-btn-primary svg   { width: 16px; height: 16px; flex-shrink: 0; }

.atv-btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 1.5px solid var(--line-dark);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--t), border-color var(--t);
}
.atv-btn-ghost:hover { background: var(--bg); border-color: var(--text-muted); }

.atv-btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: .875rem;
  font-weight: 600;
  color: #fff;
  background: var(--danger);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity var(--t);
}
.atv-btn-danger:hover    { opacity: .88; }
.atv-btn-danger:disabled { opacity: .55; cursor: not-allowed; }

/* --- Toolbar ---------------------------------------- */
.atv-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.atv-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}

/* Ícone lupa dentro do campo de busca */
.atv-search-wrap > svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-light);
  pointer-events: none;
}

.atv-search {
  width: 100%;
  padding: 8px 12px 8px 36px;
  font-size: .875rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--t);
  outline: none;
}
.atv-search:focus { border-color: var(--brand); }

/* --- Chips de tipo ---------------------------------- */
.atv-type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.atv-chip {
  padding: 5px 13px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 99px;
  cursor: pointer;
  transition: all var(--t);
}
.atv-chip:hover   { border-color: var(--line-dark); color: var(--text); }
.atv-chip--active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* --- Feedback --------------------------------------- */
.atv-feedback {
  padding: 48px 24px;
  text-align: center;
  font-size: .9375rem;
  color: var(--text-muted);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.atv-feedback--error { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }

/* --- Grade de cards --------------------------------- */
/* O grid é um <ul> — zera os estilos de lista */
ul.atv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
  list-style: none;
  padding: 0;
  margin: 0;
}

/*
 * Cada <li> é o container relativo dos action buttons.
 * Dentro do <li>: um <a class="atv-card"> + div.atv-card__actions
 */
ul.atv-grid > li {
  position: relative;
  display: flex;
}

/* --- Card ------------------------------------------- */
/*
 * O card é um <a> — toda a área é clicável e leva ao detalhe da atividade.
 * Os botões de edição ficam fora do <a>, absolutos no <li>,
 * garantindo que o clique neles não ative a navegação.
 */
.atv-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--t), transform var(--t), border-color var(--t);
}
.atv-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: var(--line-dark);
}

/* Imagem / placeholder */
.atv-card > figure {
  height: 130px;
  margin: 0;
  background: var(--bg);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.atv-card > figure > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Ícone placeholder quando não há imagem */
.atv-card > figure > svg {
  width: 36px;
  height: 36px;
  color: var(--text-light);
}

/* Corpo do card */
.atv-card > div {
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Linha de meta: badge de tipo + número de ordem */
.atv-card > div > header {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Badge de tipo de atividade (Ciclo UX, Diagnóstico, etc.) */
.atv-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-radius: 99px;
  color: var(--badge-color, var(--brand));
  background: color-mix(in srgb, var(--badge-color, var(--brand)) 12%, transparent);
}

.atv-card > div > header > small {
  font-size: .75rem;
  color: var(--text-light);
  font-weight: 500;
}

/* Nome da atividade */
.atv-card > div > h3 {
  font-size: .9375rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}

/* Descrição resumida (2 linhas) */
.atv-card > div > p {
  font-size: .8125rem;
  color: var(--text-muted);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Rodapé do card: contagem de tarefas + slug */
.atv-card > div > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

/* Contagem de tarefas */
.atv-task-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
}
.atv-task-count svg { width: 13px; height: 13px; flex-shrink: 0; }

/* Slug em fonte mono */
.atv-card__slug {
  font-size: .7rem;
  color: var(--text-light);
  font-family: 'Courier New', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Botões de ação (editar / excluir) -------------- */
/*
 * Ficam absolutamente posicionados no canto do <li> (container relativo).
 * z-index: 1 garante que ficam acima do <a> e recebem os cliques.
 */
.atv-card__actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--t);
  z-index: 1;
}
li:hover > .atv-card__actions { opacity: 1; }

.atv-action-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t);
  box-shadow: var(--shadow-sm);
}
.atv-action-btn svg           { width: 13px; height: 13px; }
.atv-action-btn:hover         { background: var(--bg); color: var(--text); border-color: var(--line-dark); }
.atv-action-btn--danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }

/* --- Overlay / Dialog ------------------------------- */
.atv-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.atv-overlay:not([hidden]) { pointer-events: auto; }
.atv-overlay--open         { opacity: 1; }

.atv-dialog {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.atv-dialog--sm { max-width: 440px; }

.atv-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
  flex-shrink: 0;
}

.atv-dialog__head > h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.atv-dialog__close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--t), color var(--t);
}
.atv-dialog__close:hover { background: var(--bg); color: var(--text); }
.atv-dialog__close svg   { width: 18px; height: 18px; }

.atv-dialog__body {
  overflow-y: auto;
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.atv-dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}

/* --- Campos do formulário --------------------------- */
.atv-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.atv-label {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.atv-required { color: var(--danger); }

.atv-input {
  padding: 9px 12px;
  font-size: .9375rem;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--t);
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}
.atv-input:focus      { border-color: var(--brand); background: var(--surface); }
.atv-input.atv-select { appearance: auto; cursor: pointer; }
.atv-textarea         { resize: vertical; min-height: 76px; }

.atv-hint { font-size: .75rem; color: var(--text-light); }

.atv-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* --- Pré-visualização de imagem --------------------- */
.atv-img-preview-wrap {
  margin-top: 8px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  max-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.atv-img-preview {
  max-width: 100%;
  max-height: 120px;
  object-fit: contain;
  display: block;
}

/* --- Erro de formulário ----------------------------- */
.atv-form-error {
  padding: 10px 14px;
  font-size: .875rem;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
}

/* --- Responsivo ------------------------------------- */
@media (max-width: 600px) {
  .atv-wrap { padding: 20px 16px 48px; }
  .atv-page-head { flex-direction: column; align-items: stretch; }
  .atv-btn-primary { width: 100%; justify-content: center; }
  ul.atv-grid { grid-template-columns: 1fr; }
  .atv-grid-2 { grid-template-columns: 1fr; }
  .atv-toolbar { flex-direction: column; align-items: stretch; }
  .atv-search-wrap { max-width: 100%; }
  .atv-dialog { max-height: 92dvh; }
  .atv-dialog__footer { flex-direction: column-reverse; }
  .atv-btn-ghost, .atv-btn-primary, .atv-btn-danger { width: 100%; justify-content: center; }
}
