/* =========================================================
   GERENCIADOR DE TAREFAS (demonstração) — JS: js/tarefas.js
   Página: sites-sistemas.html
   Quadro kanban: barra de criação, busca e filtros, 3 colunas,
   cards com prioridade, anel de progresso e aviso de "desfazer".
   ========================================================= */

.tm-project { display: block; margin-top: 1.5rem; animation-delay: .6s; }

/* cores das prioridades */
.tm { --p-alta: #e5634a; --p-media: #e5a963; --p-baixa: #4fc9c0; position: relative; margin-top: 2.25rem; }
body.light-theme .tm { --p-alta: #c2412a; --p-media: #a35406; --p-baixa: #0a6b66; }

/* ---------- cabeçalho do projeto ---------- */
.tm-intro { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3rem; align-items: center; }
.tm-live { color: #2fbf71; background: rgba(47, 191, 113, .1); border-color: rgba(47, 191, 113, .35); }
.tm-live::before { background: #2fbf71; animation: tm-ping 1.8s ease-out infinite; }
@keyframes tm-ping { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.75); } }

.tm-progress { position: relative; width: 190px; text-align: center; }
.tm-progress svg { width: 150px; height: 150px; display: block; margin: 0 auto; transform: rotate(-90deg); }
.tm-ring-bg, .tm-ring { fill: none; stroke-width: 3.2; }
.tm-ring-bg { stroke: var(--border); }
.tm-ring { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .8s var(--ease-out); }
.tm-progress strong { position: absolute; top: 75px; left: 0; right: 0; transform: translateY(-50%); font-size: 2rem; font-weight: 800; letter-spacing: -.03em; }
.tm-progress span { display: block; margin-top: .75rem; font-family: var(--mono); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--gray); }

/* ---------- criar tarefa ---------- */
.tm-new { display: flex; gap: .6rem; }
.tm-new input, .tm-new select, .tm-bar input {
  font: inherit; font-size: .92rem; color: var(--cream);
  background: var(--dark); border: 1px solid var(--border); border-radius: .8rem;
  padding: .85rem 1rem; outline: none; transition: border-color .2s, box-shadow .2s;
}
.tm-new input { flex: 1; min-width: 0; }
.tm-new select { cursor: pointer; }
.tm-new input:focus, .tm-new select:focus, .tm-bar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.tm-new .btn-primary { border: 0; cursor: pointer; white-space: nowrap; }

/* ---------- busca, filtros e restaurar ---------- */
.tm-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin: .9rem 0 1.4rem; }
.tm-bar input { flex: 1 1 220px; padding: .6rem .9rem; font-size: .85rem; }
.tm-filters { display: flex; gap: .4rem; flex-wrap: wrap; }
.tm-chip, .tm-reset {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--gray); background: transparent; border: 1px solid var(--border); border-radius: 2rem;
  padding: .45rem .85rem; cursor: pointer; transition: color .2s, border-color .2s, background .2s;
}
.tm-chip:hover, .tm-reset:hover { color: var(--cream); border-color: var(--accent); }
.tm-chip.is-active { color: var(--dark); background: var(--cream); border-color: var(--cream); }
.tm-reset { margin-left: auto; border-style: dashed; }

/* ---------- quadro ---------- */
.tm-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.tm-col {
  background: color-mix(in srgb, var(--dark) 55%, transparent); border: 1px solid var(--border); border-radius: 1.2rem;
  padding: .9rem; min-height: 320px; display: flex; flex-direction: column;
  transition: border-color .2s, background .2s;
}
.tm-col.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--dark)); }
.tm-col header { display: flex; align-items: center; justify-content: space-between; padding: .2rem .3rem .8rem; }
.tm-col h3 { font-size: .8rem; font-family: var(--mono); font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--gray); display: flex; align-items: center; gap: .5rem; }
.tm-col h3::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--gray); }
.tm-col[data-col="doing"] h3::before { background: var(--accent); }
.tm-col[data-col="done"] h3::before { background: #2fbf71; }
.tm-count { font-family: var(--mono); font-size: .72rem; color: var(--gray); background: var(--border); padding: .15rem .55rem; border-radius: 1rem; }
.tm-list { list-style: none; display: flex; flex-direction: column; gap: .6rem; flex: 1; margin: 0; padding: 0; }

/* ---------- card ---------- */
.tm-card {
  position: relative; background: var(--mid); border: 1px solid var(--border); border-radius: .9rem;
  padding: .85rem .95rem .7rem 1.1rem; cursor: grab;
  transition: transform .2s, box-shadow .2s, border-color .2s, opacity .2s;
}
.tm-card::before { content: ''; position: absolute; left: 0; top: .8rem; bottom: .8rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--prio); }
.tm-card.prio-alta { --prio: var(--p-alta); }
.tm-card.prio-media { --prio: var(--p-media); }
.tm-card.prio-baixa { --prio: var(--p-baixa); }
.tm-card:hover { border-color: color-mix(in srgb, var(--prio) 45%, var(--border)); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); transform: translateY(-1px); }
.tm-card.is-dragging { opacity: .35; transform: scale(.98); }
.tm-card.is-new { animation: tm-in .45s var(--ease-out); }
@keyframes tm-in { from { opacity: 0; transform: translateY(-8px) scale(.97); } to { opacity: 1; transform: none; } }

.tm-card-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.tm-prio { font-family: var(--mono); font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; color: var(--prio); }
.tm-card time { font-family: var(--mono); font-size: .62rem; color: var(--gray); }
.tm .tm-title { margin: .45rem 0 .55rem; font-size: .92rem; line-height: 1.45; color: var(--cream); word-break: break-word; outline: none; border-radius: .35rem; }
.tm .tm-title:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.tm .tm-title[contenteditable] { cursor: text; background: var(--dark); box-shadow: 0 0 0 2px var(--accent); padding: .15rem .3rem; margin-left: -.3rem; margin-right: -.3rem; }
.tm .tm-col[data-col="done"] .tm-title { color: var(--gray); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--gray) 60%, transparent); }

/* ações aparecem no hover (sempre visíveis no toque) */
.tm-actions { display: flex; gap: .3rem; justify-content: flex-end; opacity: 0; transition: opacity .2s; }
.tm-card:hover .tm-actions, .tm-card:focus-within .tm-actions { opacity: 1; }
@media (hover: none), (pointer: coarse) { .tm-actions { opacity: 1; } }
.tm-actions button {
  width: 28px; height: 28px; display: grid; place-items: center; font-size: .85rem; line-height: 1;
  color: var(--gray); background: transparent; border: 1px solid var(--border); border-radius: .5rem; cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.tm-actions button:hover:not(:disabled) { color: var(--cream); border-color: var(--accent); }
.tm-actions button[data-act="del"]:hover { color: #fff; background: var(--p-alta); border-color: var(--p-alta); }
.tm-actions button:disabled { opacity: .3; cursor: default; }

/* lugar onde a tarefa arrastada vai cair */
.tm-marker { height: 3px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 12px var(--accent-glow); margin: -.15rem 0; }
.tm-empty {
  flex: 1; display: grid; place-items: center; text-align: center; min-height: 120px; padding: 1rem;
  border: 1.5px dashed var(--border); border-radius: .9rem; color: var(--gray); font-size: .8rem;
}

/* ---------- aviso "tarefa excluída · desfazer" ---------- */
.tm-toast {
  position: absolute; left: 50%; bottom: -1rem; transform: translate(-50%, 120%); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 1rem; padding: .7rem .8rem .7rem 1.1rem; border-radius: 2rem;
  background: var(--cream); color: var(--dark); font-size: .85rem; box-shadow: 0 12px 30px rgba(0, 0, 0, .3);
  transition: transform .35s var(--ease-out), opacity .35s; z-index: 5;
}
.tm-toast.is-on { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.tm-toast button { font: inherit; font-weight: 700; color: var(--accent); background: none; border: 0; cursor: pointer; padding: .2rem .4rem; }
body.light-theme .tm-toast button { color: #f2b27a; }

body.light-theme .tm-col { background: color-mix(in srgb, var(--dark) 70%, #fff); }
body.light-theme .tm-card { box-shadow: 0 1px 2px rgba(30, 50, 45, .05); }

/* ---------- telas menores ---------- */
@media (max-width: 900px) {
  .tm-intro { grid-template-columns: 1fr; gap: 1.5rem; }
  .tm-progress { width: auto; display: flex; align-items: center; gap: 1rem; text-align: left; }
  .tm-progress svg { width: 64px; height: 64px; margin: 0; flex: 0 0 auto; }
  .tm-progress strong { position: static; transform: none; font-size: 1.5rem; }
  .tm-progress span { margin: 0; }
  .tm-board { grid-template-columns: 1fr; }
  .tm-col { min-height: 0; }
  .tm-empty { min-height: 70px; }
  .tm-reset { margin-left: 0; }
}
@media (max-width: 520px) {
  .tm-new { flex-wrap: wrap; }
  .tm-new input { flex: 1 1 100%; }
  .tm-new select { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .tm-ring, .tm-card, .tm-toast { transition: none; }
}
