/* =====================================================================
   HARVEST — MOVIMENTO
   Todas as durações derivam de --hv-anim-duration.
   Desligamento global:  <html data-animations="off">  (preferência do
   usuário ou ThemeOptions.AnimationsEnabled = false).
   prefers-reduced-motion também é respeitado automaticamente.
   ===================================================================== */

@keyframes hv-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes hv-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes hv-fade-up {
    from { opacity: 0; transform: translate3d(0, calc(10px * var(--hv-motion-scale)), 0); }
    to { opacity: 1; transform: none; }
}

@keyframes hv-fade-down {
    from { opacity: 0; transform: translate3d(0, calc(-6px * var(--hv-motion-scale)), 0); }
    to { opacity: 1; transform: none; }
}

@keyframes hv-page-in {
    from { opacity: 0; transform: translate3d(0, calc(6px * var(--hv-motion-scale)), 0); }
    to { opacity: 1; transform: none; }
}

@keyframes hv-modal-in {
    from { opacity: 0; transform: translate3d(0, calc(16px * var(--hv-motion-scale)), 0) scale(0.97); }
    to { opacity: 1; transform: none; }
}

@keyframes hv-modal-out {
    from { opacity: 1; transform: none; }
    to { opacity: 0; transform: translate3d(0, calc(10px * var(--hv-motion-scale)), 0) scale(0.98); }
}

@keyframes hv-pop-in {
    from { opacity: 0; transform: translate3d(0, calc(-6px * var(--hv-motion-scale)), 0) scale(0.97); }
    to { opacity: 1; transform: none; }
}

@keyframes hv-toast-in {
    from { opacity: 0; transform: translate3d(calc(24px * var(--hv-motion-scale)), 0, 0); }
    to { opacity: 1; transform: none; }
}

@keyframes hv-shimmer {
    to { transform: translateX(100%); }
}

@keyframes hv-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* ---------- Entrada de página ---------- */
.hv-page {
    animation: hv-page-in var(--hv-anim-slow) var(--hv-ease-out) both;
}

/* ---------- Entrada escalonada ----------
   Blocos de primeiro nível das páginas, cards de estatística, colunas e
   cartões do kanban, e linhas de tabela entram em sequência. */
.hv-page > .container-fluid > *,
.hv-page > .container > *,
.hv-stagger > *,
.hv-stats > *,
.hv-kanban > *,
.hv-kanban-body > *,
.table > tbody > tr {
    animation: hv-fade-up var(--hv-anim-slow) var(--hv-ease-out) both;
    animation-delay: calc(var(--hv-stagger-step) * var(--hv-i, 0));
}

.table > tbody > tr {
    animation-name: hv-fade-in;
    animation-duration: var(--hv-anim-duration);
}

:is(.hv-page > .container-fluid, .hv-page > .container, .hv-stagger, .hv-stats, .hv-kanban, .hv-kanban-body, .table > tbody) > :nth-child(2) { --hv-i: 1; }
:is(.hv-page > .container-fluid, .hv-page > .container, .hv-stagger, .hv-stats, .hv-kanban, .hv-kanban-body, .table > tbody) > :nth-child(3) { --hv-i: 2; }
:is(.hv-page > .container-fluid, .hv-page > .container, .hv-stagger, .hv-stats, .hv-kanban, .hv-kanban-body, .table > tbody) > :nth-child(4) { --hv-i: 3; }
:is(.hv-page > .container-fluid, .hv-page > .container, .hv-stagger, .hv-stats, .hv-kanban, .hv-kanban-body, .table > tbody) > :nth-child(5) { --hv-i: 4; }
:is(.hv-page > .container-fluid, .hv-page > .container, .hv-stagger, .hv-stats, .hv-kanban, .hv-kanban-body, .table > tbody) > :nth-child(6) { --hv-i: 5; }
:is(.hv-page > .container-fluid, .hv-page > .container, .hv-stagger, .hv-stats, .hv-kanban, .hv-kanban-body, .table > tbody) > :nth-child(7) { --hv-i: 6; }
:is(.hv-page > .container-fluid, .hv-page > .container, .hv-stagger, .hv-stats, .hv-kanban, .hv-kanban-body, .table > tbody) > :nth-child(8) { --hv-i: 7; }
:is(.hv-page > .container-fluid, .hv-page > .container, .hv-stagger, .hv-stats, .hv-kanban, .hv-kanban-body, .table > tbody) > :nth-child(9) { --hv-i: 8; }
:is(.hv-page > .container-fluid, .hv-page > .container, .hv-stagger, .hv-stats, .hv-kanban, .hv-kanban-body, .table > tbody) > :nth-child(10) { --hv-i: 9; }
:is(.hv-page > .container-fluid, .hv-page > .container, .hv-stagger, .hv-stats, .hv-kanban, .hv-kanban-body, .table > tbody) > :nth-child(11) { --hv-i: 10; }
:is(.hv-page > .container-fluid, .hv-page > .container, .hv-stagger, .hv-stats, .hv-kanban, .hv-kanban-body, .table > tbody) > :nth-child(n+12) { --hv-i: 11; }

/* ---------- Hover / press ---------- */
.btn {
    transition: color var(--hv-anim-fast) var(--hv-ease), background-color var(--hv-anim-fast) var(--hv-ease), border-color var(--hv-anim-fast) var(--hv-ease), box-shadow var(--hv-anim-fast) var(--hv-ease), transform var(--hv-anim-fast) var(--hv-ease);
}

    .btn:not(:disabled):not(.disabled):hover {
        transform: translateY(-1px);
    }

    .btn-primary:not(:disabled):not(.disabled):hover {
        box-shadow: 0 6px 14px -6px rgba(var(--hv-primary-rgb), 0.6);
    }

    .btn:not(:disabled):not(.disabled):active,
    .hv-popover > summary.btn:active {
        transform: translateY(0) scale(0.97);
    }

.btn-ghost:not(:disabled):hover,
.btn-link:not(:disabled):hover,
.hv-sidebar-collapse:not(:disabled):hover {
    transform: none;
}

.hv-page .card:hover {
    box-shadow: var(--hv-shadow-md);
}

/* ---------- Feedback / alertas ---------- */
.alert,
.validation-errors,
.hv-inline-error {
    animation: hv-fade-down var(--hv-anim-duration) var(--hv-ease-out) both;
}

.hv-busy {
    animation: hv-pulse calc(var(--hv-anim-duration) * 6) ease-in-out infinite;
}

/* ---------- Modais ---------- */
/* Ancestrais animados/transformados prendem position: fixed e o z-index da modal. */
.hv-page:has(.hv-modal),
.hv-page *:has(.hv-modal) {
    animation: none !important;
    transform: none !important;
}

.hv-modal .hv-modal-backdrop {
    animation: hv-fade-in var(--hv-anim-duration) var(--hv-ease) both;
}

.hv-modal .hv-modal-dialog {
    animation: hv-modal-in var(--hv-anim-slow) var(--hv-ease-out) both;
}

.hv-modal.is-closing .hv-modal-backdrop {
    animation: hv-fade-out calc(var(--hv-anim-duration) * 0.8) var(--hv-ease-in) both;
}

.hv-modal.is-closing .hv-modal-dialog {
    animation: hv-modal-out calc(var(--hv-anim-duration) * 0.8) var(--hv-ease-in) both;
}

/* ---------- Popovers / toasts / auth ---------- */
.hv-popover[open] > .hv-popover-panel {
    animation: hv-pop-in var(--hv-anim-duration) var(--hv-ease-out) both;
}

.hv-toast {
    animation: hv-toast-in var(--hv-anim-slow) var(--hv-ease-out) both;
}

.hv-auth-card {
    animation: hv-fade-up var(--hv-anim-slow) var(--hv-ease-out) both;
}

.hv-auth-hero > * {
    animation: hv-fade-up calc(var(--hv-anim-slow) * 1.4) var(--hv-ease-out) both;
}

    .hv-auth-hero > :nth-child(2) { animation-delay: calc(var(--hv-stagger-step) * 2); }
    .hv-auth-hero > :nth-child(3) { animation-delay: calc(var(--hv-stagger-step) * 4); }

.hv-auth-form > * {
    animation: hv-fade-up var(--hv-anim-slow) var(--hv-ease-out) both;
}

    .hv-auth-form > :nth-child(2) { animation-delay: calc(var(--hv-stagger-step) * 1); }
    .hv-auth-form > :nth-child(3) { animation-delay: calc(var(--hv-stagger-step) * 2); }
    .hv-auth-form > :nth-child(4) { animation-delay: calc(var(--hv-stagger-step) * 3); }
    .hv-auth-form > :nth-child(n+5) { animation-delay: calc(var(--hv-stagger-step) * 4); }

/* ---------- Acessibilidade: movimento reduzido ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 1ms !important;
        animation-delay: 0ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
        scroll-behavior: auto !important;
    }

    .btn:hover, .btn:active, .card:hover, .hv-stat:hover, .hv-kanban-card:hover, .card-interactive:hover {
        transform: none !important;
    }
}

/* ---------- Desligamento global ---------- */
:root[data-animations="off"] {
    scroll-behavior: auto;
}

    :root[data-animations="off"] *,
    :root[data-animations="off"] *::before,
    :root[data-animations="off"] *::after {
        animation: none !important;
        transition: none !important;
    }

    :root[data-animations="off"] .btn:hover,
    :root[data-animations="off"] .btn:active,
    :root[data-animations="off"] .card:hover,
    :root[data-animations="off"] .hv-stat:hover,
    :root[data-animations="off"] .hv-kanban-card:hover,
    :root[data-animations="off"] .card-interactive:hover {
        transform: none !important;
    }

    :root[data-animations="off"] .hv-modal.is-closing {
        display: none;
    }
