/* Microanimações V2 — leves, só CSS onde possível; respeita prefers-reduced-motion */

html[data-reduced-motion="1"] .company-logo--live .company-logo-image,
html[data-reduced-motion="1"] .company-logo--live .company-logo__media::before,
html[data-reduced-motion="1"] .company-logo--live .company-logo__media::after,
html[data-reduced-motion="1"] .btn--animated .btn__icon,
html[data-reduced-motion="1"] .btn--animated .nav-link__icon,
html[data-reduced-motion="1"] .chart-animate .chart-bars__bar,
html[data-reduced-motion="1"] .chart-animate .chart-hbar-fill,
html[data-reduced-motion="1"] .chart-animate .chart-user-track,
html[data-reduced-motion="1"] .chart-animate .chart-legend-row {
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .company-logo--live .company-logo-image,
  .company-logo--live .company-logo__media::before,
  .company-logo--live .company-logo__media::after,
  .btn--animated .btn__icon,
  .btn--animated .nav-link__icon,
  .chart-animate .chart-bars__bar,
  .chart-animate .chart-hbar-fill,
  .chart-animate .chart-user-track,
  .chart-animate .chart-legend-row {
    animation: none !important;
  }
}

/* --- Botões com ícone --- */

.btn-primary,
.btn-ghost,
.btn-cta,
.btn-sugestao-header,
.modal-sugestao__actions .btn-primary,
.modal-sugestao__actions .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42em;
  vertical-align: middle;
}

.btn-cta {
  display: flex;
  flex-direction: row;
}

.btn__icon {
  width: 1.05em;
  height: 1.05em;
  flex-shrink: 0;
  display: block;
  fill: none;
  stroke: currentColor;
  pointer-events: none;
}

.btn--animated {
  position: relative;
  overflow: hidden;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.12s ease;
}

.btn--animated::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  background: linear-gradient(
    105deg,
    transparent 42%,
    rgba(255, 255, 255, 0.14) 50%,
    transparent 58%
  );
  transform: translateX(-120%);
  pointer-events: none;
}

.btn-primary.btn--animated::after {
  background: linear-gradient(
    105deg,
    transparent 42%,
    rgba(255, 255, 255, 0.12) 50%,
    transparent 58%
  );
}

@media (hover: hover) {
  .btn--animated:hover::after {
    opacity: 1;
    animation: btn-shine 0.55s ease forwards;
  }

  .btn--animated:hover .btn__icon,
  .btn--animated:hover .nav-link__icon {
    animation: btn-icon-nudge 0.35s ease;
  }
}

.btn--animated:active {
  transform: scale(0.98);
}

.btn--animated:active .btn__icon,
.btn--animated:active .nav-link__icon {
  transform: scale(0.92);
}

@keyframes btn-shine {
  to {
    transform: translateX(120%);
  }
}

@keyframes btn-icon-nudge {
  0% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-2px);
  }
  100% {
    transform: translateY(0);
  }
}

.btn-primary.btn--animated:focus-visible,
.btn-ghost.btn--animated:focus-visible,
.btn-header-logout.btn--animated:focus-visible,
.nav-link--btn.btn--animated:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Menu superior: links como botões --- */

.app-topnav__grid .nav-link--btn {
  display: flex;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  min-height: var(--topnav-btn-min-h, 4.35rem);
  height: 100%;
  padding: 0.45rem 0.4rem;
  font-size: var(--topnav-font-size, 0.72rem);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--input-bg);
  box-shadow: 0 1px 0 #ffffff80 inset;
  text-align: center;
  box-sizing: border-box;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.app-topnav__grid .nav-link--btn:hover {
  background: var(--nav-hover-bg);
  color: var(--nav-active-text);
  border-color: #b8cae8;
}

.app-topnav__grid .nav-link--btn.is-active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent-deep);
  font-weight: 600;
  box-shadow: 0 2px 10px #009c3b28;
}

.nav-link__icon {
  width: 1.2rem;
  height: 1.2rem;
  flex-shrink: 0;
  display: block;
  fill: none;
  stroke: currentColor;
  pointer-events: none;
}

.app-topnav__grid .nav-link__icon {
  width: var(--topnav-icon-size, 1.125rem);
  height: var(--topnav-icon-size, 1.125rem);
  flex: 0 0 var(--topnav-icon-size, 1.125rem);
  flex-shrink: 0;
}

.nav-link__label {
  flex: none;
  min-width: 0;
  width: 100%;
  line-height: 1.2;
  text-align: center;
}

.app-topnav__grid .nav-link__label {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  width: 100%;
  min-height: var(--topnav-label-lines, 2.35em);
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  overflow: visible;
  word-break: break-word;
  hyphens: auto;
}

.app-topnav__grid .nav-link--logout {
  margin-top: 0;
  border-top: 0;
  padding-top: 0.38rem;
}

html[data-theme="dark"] .app-topnav__grid .nav-link--btn {
  box-shadow: 0 1px 0 #ffffff0a inset;
}

html[data-theme="dark"] .app-topnav__grid .nav-link--btn:hover {
  border-color: #4d6a9a;
}

html[data-theme="dark"] .app-topnav__grid .nav-link--btn.is-active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 12px #47d17a35;
}

/* --- Logo dinâmica --- */

.company-logo--live .company-logo__media {
  isolation: isolate;
  overflow: visible;
}

.company-logo--live .company-logo__media::before {
  content: "";
  position: absolute;
  inset: -18% -10%;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    #1f4f9b38 0%,
    #2f5faa18 42%,
    transparent 72%
  );
  pointer-events: none;
  animation: logo-halo-pulse 4.5s ease-in-out infinite;
}

.company-logo--live .company-logo__media::after {
  content: "";
  position: absolute;
  inset: -4% -6%;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    108deg,
    transparent 38%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 62%
  );
  transform: translateX(-125%) skewX(-14deg);
  opacity: 0;
  animation: logo-shine-sweep 6.5s ease-in-out infinite;
  mix-blend-mode: soft-light;
}

.company-logo--live .company-logo-image {
  position: relative;
  z-index: 1;
  animation: logo-float-glow 5.5s ease-in-out infinite;
  transition: transform 0.35s ease, filter 0.35s ease;
}

.company-logo--live::after {
  content: "";
  display: block;
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -0.15rem;
  height: 2px;
  border-radius: 999px;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--brand) 18%,
    #2f5faa 50%,
    var(--accent) 82%,
    transparent 100%
  );
  opacity: 0.55;
  transform: scaleX(0.55);
  transform-origin: center;
  animation: logo-accent-line 4.5s ease-in-out infinite;
}

@media (hover: hover) {
  .company-logo--live:hover .company-logo-image {
    animation: none;
    transform: translateY(-2px) scale(1.045);
    filter:
      drop-shadow(0 8px 20px #1f4f9b40)
      drop-shadow(0 0 14px #009c3b33);
  }

  .company-logo--live:hover .company-logo__media::before {
    animation-duration: 2.8s;
    opacity: 1;
  }

  .company-logo--live:hover .company-logo__media::after {
    animation: logo-shine-sweep 1.8s ease-in-out infinite;
  }

  .company-logo--live:hover::after {
    animation-duration: 2.2s;
    opacity: 0.95;
  }
}

@keyframes logo-float-glow {
  0%,
  100% {
    transform: translateY(0) scale(1);
    filter: drop-shadow(0 2px 6px #1f4f9b14);
  }
  50% {
    transform: translateY(-3px) scale(1.025);
    filter:
      drop-shadow(0 8px 18px #1f4f9b32)
      drop-shadow(0 0 10px #009c3b28);
  }
}

@keyframes logo-halo-pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.9);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.08);
  }
}

@keyframes logo-shine-sweep {
  0%,
  72%,
  100% {
    transform: translateX(-125%) skewX(-14deg);
    opacity: 0;
  }
  78% {
    opacity: 0.65;
  }
  88% {
    transform: translateX(125%) skewX(-14deg);
    opacity: 0;
  }
}

@keyframes logo-accent-line {
  0%,
  100% {
    opacity: 0.35;
    transform: scaleX(0.45);
  }
  50% {
    opacity: 0.95;
    transform: scaleX(1);
  }
}

html[data-theme="dark"] .company-logo--live .company-logo__media::before {
  background: radial-gradient(
    ellipse at center,
    #6b8fc755 0%,
    #3d5f9830 45%,
    transparent 72%
  );
}

html[data-theme="dark"] .company-logo--live .company-logo-image {
  animation-name: logo-float-glow-dark;
}

html[data-theme="dark"] .company-logo--live:hover .company-logo-image {
  filter:
    drop-shadow(0 10px 24px #00000055)
    drop-shadow(0 0 16px #6b8fc766);
}

@keyframes logo-float-glow-dark {
  0%,
  100% {
    transform: translateY(0) scale(1);
    filter: drop-shadow(0 2px 8px #00000040);
  }
  50% {
    transform: translateY(-3px) scale(1.025);
    filter:
      drop-shadow(0 10px 22px #00000055)
      drop-shadow(0 0 14px #6b8fc744);
  }
}

.company-logo--header.company-logo--live .company-logo-image {
  animation-duration: 6.5s;
}

.company-logo--header.company-logo--live .company-logo__media::after {
  animation-duration: 7.5s;
}

/* Menu toggle — feedback tátil leve */

.menu-toggle {
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.menu-toggle:active {
  transform: scale(0.94);
}

/* Rodapé — faixa de acento animada */

@keyframes v2-footer-accent-shift {
  0%,
  100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@media (prefers-reduced-motion: no-preference) {
  html:not([data-reduced-motion="1"]) .app-footer::before {
    animation: v2-footer-accent-shift 8s ease-in-out infinite;
  }
}

/* --- Gráficos (dashboard e relatórios) --- */

@keyframes v2-chart-bar-rise {
  0% {
    transform: scaleY(0);
    opacity: 0.35;
  }
  100% {
    transform: scaleY(1);
    opacity: 1;
  }
}

@keyframes v2-chart-hbar-grow {
  0% {
    transform: scaleX(0);
    opacity: 0.45;
  }
  100% {
    transform: scaleX(1);
    opacity: 1;
  }
}

@keyframes v2-chart-track-grow {
  0% {
    transform: scaleX(0);
    opacity: 0.4;
  }
  100% {
    transform: scaleX(1);
    opacity: 1;
  }
}

@keyframes v2-chart-legend-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

html:not([data-reduced-motion="1"]) .chart-animate:not(.is-chart-animated) .chart-bars__bar {
  transform: scaleY(0);
  transform-origin: bottom center;
  opacity: 0;
}

html:not([data-reduced-motion="1"]) .chart-animate:not(.is-chart-animated) .chart-hbar-fill {
  transform: scaleX(0);
  transform-origin: left center;
  opacity: 0;
}

html:not([data-reduced-motion="1"]) .chart-animate:not(.is-chart-animated) .chart-user-track {
  transform: scaleX(0);
  transform-origin: left center;
  opacity: 0;
}

html:not([data-reduced-motion="1"]) .chart-animate.is-chart-animated .chart-bars__bar {
  animation: v2-chart-bar-rise 0.62s cubic-bezier(0.22, 1, 0.36, 1) both;
}

html:not([data-reduced-motion="1"]) .chart-animate.is-chart-animated .chart-hbar-fill {
  animation: v2-chart-hbar-grow 0.72s cubic-bezier(0.22, 1, 0.36, 1) both;
}

html:not([data-reduced-motion="1"]) .chart-animate.is-chart-animated .chart-user-track {
  animation: v2-chart-track-grow 0.68s cubic-bezier(0.22, 1, 0.36, 1) both;
}

html:not([data-reduced-motion="1"]) .chart-animate.is-chart-animated .chart-legend-row {
  animation: v2-chart-legend-in 0.45s ease both;
}

@media (hover: hover) {
  html:not([data-reduced-motion="1"]) .chart-bars__bar {
    transition: filter 0.18s ease, transform 0.18s ease;
  }

  html:not([data-reduced-motion="1"]) .chart-animate.is-chart-animated .chart-bars__bar:hover {
    filter: brightness(1.14);
    transform: scaleY(1.04);
    transform-origin: bottom center;
  }

  html:not([data-reduced-motion="1"]) .chart-animate.is-chart-animated .chart-hbar-fill {
    transition: filter 0.18s ease;
  }

  html:not([data-reduced-motion="1"]) .chart-animate.is-chart-animated .chart-hbar-row:hover .chart-hbar-fill {
    filter: brightness(1.1);
  }
}
