/**
 * Pulmo — progresso dos vídeos em processamento no #/calendar (components/video-progress.js).
 * Desktop: painel no canto inferior direito. Celular (≤ 768px): botão flutuante acima da barra inferior
 * e lista numa folha. Abaixo dos modais (z-index 1040+) e acima do calendário ampliado (950).
 */
.vp {
  --vp-ink: #0f2a26;
  --vp-text: #44524f;
  --vp-muted: #6f7c78;
  --vp-line: #e3e9e7;
  --vp-surface: #ffffff;
  --vp-surface-2: #f2f6f5;
  --vp-primary: #004343;
  --vp-accent: #e8a33d;
  --vp-ok: #157a3c;
  --vp-ok-bg: #e2f7ea;
  --vp-err: #b42318;
  --vp-err-bg: #fdecea;
  --vp-shadow: 0 1px 2px rgba(15, 42, 38, 0.06), 0 22px 48px -20px rgba(15, 42, 38, 0.38);
  --vp-font: 'Plus Jakarta Sans', 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-family: var(--vp-font);
}
html[data-theme="dark"] .vp {
  --vp-ink: #f3f5f4;
  --vp-text: #c9d1cf;
  --vp-muted: #93a09c;
  --vp-line: #2c3533;
  --vp-surface: #1b2220;
  --vp-surface-2: #242d2b;
  --vp-primary: #6fd0c8;
  --vp-accent: #f6c36b;
  --vp-ok: #6fdc9b;
  --vp-ok-bg: rgba(111, 220, 155, 0.14);
  --vp-err: #ff8a80;
  --vp-err-bg: rgba(255, 138, 128, 0.14);
  --vp-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 22px 48px -20px rgba(0, 0, 0, 0.7);
}
.vp[hidden] { display: none !important; }
.vp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── painel ── */
.vp-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 960;
  width: 340px;
  max-height: min(60vh, 460px);
  display: flex;
  flex-direction: column;
  background: var(--vp-surface);
  border: 1px solid var(--vp-line);
  border-radius: 18px;
  box-shadow: var(--vp-shadow);
  overflow: hidden;
  animation: vpIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes vpIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.vp-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 12px 14px;
  border-bottom: 1px solid var(--vp-line);
}
.vp.is-collapsed .vp-head { border-bottom: 0; }
.vp-head-icon {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--vp-ok);
  background: var(--vp-ok-bg);
}
.vp-head-icon.is-busy {
  background: none;
  border: 2.5px solid var(--vp-line);
  border-top-color: var(--vp-primary);
  animation: vpSpin 0.8s linear infinite;
}
@keyframes vpSpin { to { transform: rotate(360deg); } }
.vp-head-title { flex: 1; min-width: 0; color: var(--vp-ink); font-size: 0.9rem; font-weight: 800; }

.vp-icon-btn {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--vp-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.vp-icon-btn:hover { background: var(--vp-surface-2); color: var(--vp-ink); }
.vp-icon-btn:focus-visible, .vp-row-btn:focus-visible, .vp-fab:focus-visible { outline: 2px solid var(--vp-primary); outline-offset: 2px; }
.vp-collapse svg { transition: transform 0.25s; }
.vp.is-collapsed .vp-collapse svg { transform: rotate(180deg); }
.vp-close { display: none; }
.vp.is-collapsed .vp-list, .vp.is-collapsed .vp-foot { display: none; }

.vp-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.vp-row-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s;
}
.vp-row-btn:hover { background: var(--vp-surface-2); }
.vp-thumb {
  flex: none;
  width: 40px;
  height: 56px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: var(--vp-surface-2);
  color: var(--vp-muted);
}
.vp-thumb img { width: 100%; height: 100%; object-fit: cover; }
.vp-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.vp-row-title {
  overflow: hidden;
  color: var(--vp-ink);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.vp-row-stage { display: inline-flex; align-items: center; gap: 5px; color: var(--vp-primary); font-size: 0.76rem; font-weight: 700; }
.vp-row.is-done .vp-row-stage { color: var(--vp-ok); }
.vp-row.is-failed .vp-row-stage { color: var(--vp-err); }
.vp-row-hint {
  display: -webkit-box;
  overflow: hidden;
  color: var(--vp-muted);
  font-size: 0.72rem;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.vp-bar { position: relative; height: 4px; margin-top: 3px; overflow: hidden; border-radius: 99px; background: var(--vp-surface-2); }
.vp-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 40%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--vp-primary), var(--vp-accent));
  animation: vpBar 1.6s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
@keyframes vpBar { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.vp-row-cta {
  flex: none;
  padding: 6px 12px;
  border-radius: 99px;
  background: var(--vp-ok-bg);
  color: var(--vp-ok);
  font-size: 0.76rem;
  font-weight: 800;
}
.vp-row.is-failed .vp-row-cta { background: var(--vp-err-bg); color: var(--vp-err); }
.vp-foot { margin: 0; padding: 8px 14px 12px; border-top: 1px solid var(--vp-line); color: var(--vp-muted); font-size: 0.72rem; line-height: 1.4; }

/* toasts sobem acima do painel (--vp-offset vem do JS) */
@media (min-width: 769px) {
  html.vp-on .toast { bottom: calc(24px + var(--vp-offset, 0px) + 12px); }
}

/* ── botão flutuante (celular) ── */
.vp-fab { display: none; }
.vp-backdrop { display: none; }

@media (max-width: 768px) {
  .vp-fab {
    position: fixed;
    right: 16px;
    bottom: calc(var(--bottom-nav-height, 64px) + 24px + env(safe-area-inset-bottom, 0px));
    z-index: 960;
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--vp-primary);
    color: #fff;
    box-shadow: var(--vp-shadow);
    cursor: pointer;
    animation: vpPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    -webkit-tap-highlight-color: transparent;
  }
  html[data-theme="dark"] .vp-fab { color: #0f2a26; }
  .vp-fab:active { transform: scale(0.94); }
  .vp-fab.is-done { background: var(--vp-ok); color: #fff; }
  .vp-fab.is-failed { background: var(--vp-err); color: #fff; }
  .vp-fab-ring {
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    border: 2.5px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    animation: vpSpin 1s linear infinite;
  }
  html[data-theme="dark"] .vp-fab.is-busy .vp-fab-ring { border-color: rgba(15, 42, 38, 0.2); border-top-color: #0f2a26; }
  .vp-fab:not(.is-busy) .vp-fab-ring { display: none; }
  .vp-fab-count {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    padding: 0 5px;
    border: 2px solid var(--vp-surface);
    border-radius: 99px;
    background: var(--vp-accent);
    color: #0f2a26;
    font-size: 0.7rem;
    font-weight: 800;
  }
  @keyframes vpPop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }

  /* folha com a lista */
  .vp-panel {
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1035;
    width: auto;
    max-height: 75vh;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-width: 1px 0 0;
    border-radius: 22px 22px 0 0;
    animation: vpSheet 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  @keyframes vpSheet { from { transform: translateY(100%); } to { transform: none; } }
  .vp:not(.is-sheet) .vp-panel { display: none; }
  .vp.is-sheet .vp-fab { visibility: hidden; }
  .vp-backdrop:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 1034;
    display: block;
    background: rgba(10, 20, 18, 0.45);
    animation: vpFade 0.25s ease;
  }
  @keyframes vpFade { from { opacity: 0; } to { opacity: 1; } }
  .vp-head { padding: 14px 12px 12px 18px; }
  .vp-head::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    width: 36px;
    height: 4px;
    margin-left: -18px;
    border-radius: 99px;
    background: var(--vp-line);
  }
  .vp-collapse { display: none; }
  .vp-close { display: grid; }
  .vp.is-collapsed .vp-list, .vp.is-collapsed .vp-foot { display: block; }
  .vp.is-collapsed .vp-head { border-bottom: 1px solid var(--vp-line); }
  .vp-row-btn { padding: 10px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .vp-panel, .vp-fab, .vp-backdrop:not([hidden]) { animation: none; }
  .vp-head-icon.is-busy, .vp-fab-ring { animation-duration: 2.4s; }
  .vp-bar i { animation: none; width: 100%; opacity: 0.5; }
}
