/* ─────────────────────────────────────────────────────────────
   agenda.css — Aba Agenda do Claquete.

   Herda os tokens do painel (--primary, --card, --border, --muted,
   --text, --r) e o mesmo vocabulário visual: Inter no texto, JetBrains
   Mono em número/hora, raio 8-10px, tema claro. Nada de acento novo:
   a cor de cada item vem da categoria do compromisso, da cor do
   cliente (prazo de card) ou do azul do shell (post agendado).
   ───────────────────────────────────────────────────────────── */

#viewAgenda {
  --ag-h: 54px;            /* altura de 1 hora na grade da semana */
  --ag-gutter: 52px;       /* coluna das horas */
  --ag-post: #0d5b8f;      /* mesma do shell (--shell-accent) */
}

/* ── Resumo: uma faixa com três leituras, separadas por fio ── */
.ag-resumo {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; margin-bottom: 14px;
}
.ag-resumo__c { padding: 13px 16px; border-left: 1px solid var(--border); min-width: 0; }
.ag-resumo__c:first-child { border-left: none; }
.ag-resumo__k {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
}
.ag-resumo__v {
  display: flex; align-items: baseline; gap: 7px; margin-top: 5px;
  font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -.01em;
}
.ag-resumo__v b { font-family: 'JetBrains Mono', monospace; font-size: 23px; font-weight: 700; line-height: 1; }
.ag-resumo__v small { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.ag-resumo__c--alerta .ag-resumo__v b { color: #b91c1c; }
.ag-resumo__nada { font-size: 13px; color: var(--muted); margin-top: 7px; }

/* ── Barra de controle ── */
.ag-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ag-bar__left, .ag-bar__right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.ag-modes { display: inline-flex; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.ag-mode {
  border: none; background: transparent; cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 7px 14px; border-radius: 7px; transition: background-color .16s, color .16s;
}
.ag-mode:hover:not(.active) { background: var(--bg); color: var(--text); }
.ag-mode.active { background: #eef2ff; color: var(--primary); font-weight: 700; }

.ag-fontes { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.ag-fonte {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 5px 11px; font-family: inherit; font-size: 12px; font-weight: 600;
  transition: border-color .16s, color .16s, background-color .16s;
}
.ag-fonte i { width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--muted)); flex-shrink: 0; opacity: .35; }
.ag-fonte:hover { color: var(--text); }
.ag-fonte.on { color: var(--text); border-color: #cbd5e1; background: #f8fafc; }
.ag-fonte.on i { opacity: 1; }

/* ── [hidden] precisa vencer quem define display ──────────────
   Classe com display (.btn{inline-flex}, .ag-aviso{flex}) ganha do
   display:none que o navegador dá ao atributo hidden, e o elemento continua
   na tela "escondido". Deu a faixa de aviso vazia e, pior, os botões Excluir
   e Concluir num compromisso que ainda não existia. Vale para a aba e para o
   modal, que mora fora dela, no body. */
#viewAgenda [hidden], #agOverlay [hidden] { display: none !important; }

/* ── Aviso (lembrete sem Telegram vinculado) ── */
.ag-aviso {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px;
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px;
  padding: 11px 13px; font-size: 13px; color: #92400e; line-height: 1.5;
}
.ag-aviso a { color: #92400e; font-weight: 700; }

/* ── Grade da semana ── */
.ag-week { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.ag-week__scroll { overflow: auto; max-height: min(62vh, 620px); }
.ag-week__head, .ag-week__allday, .ag-grid {
  display: grid; grid-template-columns: var(--ag-gutter) repeat(7, minmax(0, 1fr));
  min-width: 680px;
}
.ag-week__head { border-bottom: 1px solid var(--border); background: #fbfcfe; position: sticky; top: 0; z-index: 3; }
.ag-week__allday { position: sticky; top: var(--ag-head-h, 44px); z-index: 2; }
.ag-week__corner { border-right: 1px solid var(--border); }
.ag-dow { padding: 8px 4px 9px; text-align: center; border-right: 1px solid var(--border); }
.ag-dow:last-child { border-right: none; }
.ag-dow span { display: block; font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.ag-dow b { display: block; font-family: 'JetBrains Mono', monospace; font-size: 16px; font-weight: 700; color: var(--text); margin-top: 3px; line-height: 1.1; }
.ag-dow.is-hoje { background: #eef2ff; }
.ag-dow.is-hoje b, .ag-dow.is-hoje span { color: var(--primary); }
.ag-dow.is-fds b { color: var(--muted); }

.ag-week__allday { border-bottom: 1px solid var(--border); background: #fdfdfe; }
.ag-week__allday .ag-ad {
  border-right: 1px solid var(--border); padding: 5px; display: flex; flex-direction: column; gap: 4px;
  min-height: 34px;
}
.ag-week__allday .ag-ad:last-child { border-right: none; }
.ag-week__allday .ag-adlbl {
  border-right: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end;
  padding-right: 7px; font-family: 'JetBrains Mono', monospace; font-size: 9.5px;
  font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
}

.ag-hours { border-right: 1px solid var(--border); }
.ag-hour {
  height: var(--ag-h); position: relative;
  font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--muted);
}
/* O rótulo fica logo ABAIXO da linha que nomeia. Acima dela, o primeiro
   sumiria atrás do cabeçalho grudado e a grade precisaria de uma folga no
   topo, que aparecia como uma emenda sem os riscos das colunas. */
.ag-hour span { position: absolute; top: 2px; right: 7px; }

.ag-day {
  position: relative; border-right: 1px solid var(--border);
  background: repeating-linear-gradient(
    to bottom,
    transparent 0, transparent calc(var(--ag-h) - 1px),
    var(--border) calc(var(--ag-h) - 1px), var(--border) var(--ag-h));
}
.ag-day:last-child { border-right: none; }
.ag-day.is-hoje { background-color: #fafbff; }
.ag-day.is-fds { background-color: #fcfcfd; }

.ag-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid #dc2626; z-index: 3; pointer-events: none; }
.ag-now::before { content: ""; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: #dc2626; }

/* ── Bloco de evento ── */
.ag-ev {
  position: absolute; border-radius: 7px; cursor: pointer; overflow: hidden;
  background: #fff; border: 1px solid var(--c, var(--border)); border-left: 3px solid var(--c, var(--primary));
  padding: 3px 6px; text-align: left; font-family: inherit; color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .07);
  transition: box-shadow .16s, transform .12s;
}
.ag-ev:hover { box-shadow: 0 4px 12px -2px rgba(15, 23, 42, .18); z-index: 4; }
.ag-ev:active { transform: scale(.985); }
.ag-ev:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.ag-ev__t { font-size: 11.5px; font-weight: 700; line-height: 1.25; letter-spacing: -.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-ev__h { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; color: var(--muted); margin-top: 1px; }
.ag-ev--curto { padding: 1px 6px; display: flex; align-items: center; gap: 5px; }
.ag-ev--curto .ag-ev__t { min-width: 0; flex: 1; }
.ag-ev--curto .ag-ev__h { margin-top: 0; white-space: nowrap; flex-shrink: 0; }
.ag-ev.is-feito { background: #f8fafc; border-color: var(--border); border-left-color: #cbd5e1; }
.ag-ev.is-feito .ag-ev__t { text-decoration: line-through; color: #94a3b8; font-weight: 600; }
.ag-ev--leitura { border-style: dashed; }

/* Chip (dia inteiro, mês, prazo) */
.ag-chip {
  display: flex; align-items: center; gap: 5px; width: 100%;
  border: 1px solid var(--border); border-left: 3px solid var(--c, var(--primary));
  background: #fff; border-radius: 6px; padding: 3px 6px; cursor: pointer;
  font-family: inherit; font-size: 11px; font-weight: 600; color: var(--text);
  text-align: left; min-width: 0;
}
.ag-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-chip time { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; color: var(--muted); flex-shrink: 0; }
.ag-chip:hover { border-color: #cbd5e1; background: #f8fafc; }
.ag-chip.is-feito span { text-decoration: line-through; color: #94a3b8; }
.ag-chip--leitura { border-style: dashed; }

/* ── Mês ── */
.ag-mes { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.ag-mes__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.ag-mes__dow { text-align: center; font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 2px 0 4px; }
.ag-mes__cell {
  min-height: 92px; border: 1px solid var(--border); border-radius: 9px; padding: 5px;
  display: flex; flex-direction: column; gap: 3px; background: var(--card); cursor: pointer;
  text-align: left; font-family: inherit;
}
.ag-mes__cell:hover { border-color: #cbd5e1; background: #fafbfc; }
.ag-mes__cell:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.ag-mes__cell.is-fora { background: #fafafb; border-color: #eef1f4; }
.ag-mes__cell.is-fora .ag-mes__n { color: #c3cbd6; }
.ag-mes__cell.is-hoje { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.ag-mes__cell.is-hoje .ag-mes__n { color: var(--primary); }
.ag-mes__cell.is-sel { background: #eef2ff; border-color: #c7d2fe; }
.ag-mes__n { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; font-weight: 700; color: var(--text); }
.ag-mes__mais { font-size: 10.5px; font-weight: 600; color: var(--muted); padding-left: 2px; }
.ag-mes__dia { margin-top: 14px; }

/* ── Lista ── */
.ag-lista { display: flex; flex-direction: column; gap: 18px; }
.ag-lista__g { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.ag-lista__hd {
  display: flex; align-items: baseline; gap: 9px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); background: #fbfcfe;
}
.ag-lista__hd b { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; color: var(--text); }
.ag-lista__hd span { font-size: 12px; color: var(--muted); }
.ag-lista__hd.is-hoje { background: #eef2ff; }
.ag-lista__hd.is-hoje b, .ag-lista__hd.is-hoje span { color: var(--primary); }

.ag-row { display: flex; align-items: flex-start; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--border); }
.ag-row:first-of-type { border-top: none; }
.ag-row__h {
  font-family: 'JetBrains Mono', monospace; font-size: 12.5px; font-weight: 700; color: var(--text);
  width: 44px; flex-shrink: 0; padding-top: 1px;
}
.ag-row__h small { display: block; font-size: 10px; font-weight: 500; color: var(--muted); }
.ag-row__bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--c, var(--primary)); flex-shrink: 0; }
.ag-row__b { flex: 1; min-width: 0; cursor: pointer; }
.ag-row__t { font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.ag-row__m { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 4px; font-size: 12px; color: var(--muted); }
.ag-row.is-feito .ag-row__t { text-decoration: line-through; color: #94a3b8; }
.ag-row__ok {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 7px; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--card); color: #94a3b8;
  display: grid; place-items: center; font-size: 13px; transition: border-color .15s, color .15s, background-color .15s;
}
.ag-row__ok:hover { border-color: #16a34a; color: #16a34a; background: #f0fdf4; }
.ag-row.is-feito .ag-row__ok { border-color: #16a34a; background: #dcfce7; color: #166534; }

.ag-tag {
  font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  border-radius: 5px; padding: 2px 6px; background: #f1f5f9; color: #475569;
}
.ag-tag--leitura { background: #fff; border: 1px dashed var(--border); color: var(--muted); }

/* ── Vazio / carregando / erro ── */
.ag-vazio {
  background: var(--card); border: 1px dashed var(--border); border-radius: 12px;
  padding: 40px 24px; text-align: center;
}
.ag-vazio__i { font-size: 30px; line-height: 1; }
.ag-vazio__t { font-size: 15px; font-weight: 700; color: var(--text); margin-top: 12px; }
.ag-vazio__s { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.55; max-width: 46ch; margin-left: auto; margin-right: auto; }
.ag-vazio .btn { margin-top: 16px; }
.ag-vazio--erro { border-style: solid; border-color: #fecaca; background: #fef2f2; }

.ag-skel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.ag-skel__l { height: 13px; border-radius: 6px; background: linear-gradient(90deg, #eef1f5 25%, #f6f8fa 50%, #eef1f5 75%); background-size: 200% 100%; animation: ag-sh 1.3s linear infinite; }
.ag-skel__l + .ag-skel__l { margin-top: 11px; }
.ag-skel__l:nth-child(2) { width: 72%; }
.ag-skel__l:nth-child(3) { width: 54%; }
@keyframes ag-sh { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .ag-skel__l { animation: none; }
  .ag-ev, .ag-mode, .ag-fonte, .ag-row__ok { transition: none; }
  .ag-ev:active { transform: none; }
}

/* ── Modal do compromisso ── */
.ag-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-cat {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--card); border-radius: 999px;
  padding: 6px 12px; font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.ag-cat i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.ag-cat:hover { color: var(--text); }
.ag-cat.on { border-color: var(--c); color: var(--text); background: #fbfcff; }
.ag-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ag-chk { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.ag-chk input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }
.ag-modal__foot { display: flex; align-items: center; gap: 10px; margin-top: 22px; }
.ag-modal__foot .ag-left { margin-right: auto; }
.ag-serie {
  font-size: 12px; color: var(--muted); background: #f8fafc; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 11px; line-height: 1.5; margin-bottom: 14px;
}

/* ── Telas estreitas ── */
@media (max-width: 760px) {
  #viewAgenda { --ag-h: 48px; --ag-gutter: 44px; }
  .ag-resumo { grid-template-columns: 1fr; }
  .ag-resumo__c { border-left: none; border-top: 1px solid var(--border); }
  .ag-resumo__c:first-child { border-top: none; }
  .ag-bar { gap: 9px; }
  .ag-bar__left, .ag-bar__right { width: 100%; }
  .ag-bar__right { justify-content: space-between; }
  .ag-modes { flex: 1; }
  .ag-mode { flex: 1; padding: 8px 6px; text-align: center; }
  .ag-mes__cell { min-height: 62px; padding: 3px; }
  .ag-mes__grid { gap: 4px; }
  .ag-row__h { width: 40px; font-size: 12px; }
}
