/* AuthMantra UI system, life. Loaded last. A page should feel awake: content arrives in a ripple, numbers count up, tiles lift under the pointer, buttons answer,
   the page shows that it is working, and a slow wash of colour drifts behind the content. Everything is CSS or a few lines of ui-live.js, nothing blocks a click,
   and it all stands still for people who ask their system for reduced motion. Never put a transform or a blur on an element that can hold a menu. */
:root {
  --lv-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --lv-glide: cubic-bezier(0.22, 0.9, 0.3, 1);
  --lv-teal: 10, 191, 188;
  --lv-blue: 47, 95, 196;
}

@media (prefers-reduced-motion: no-preference) {
  /* ── A slow wash of colour behind the page ─────────────────────────────────────────────────────── */
  .ui-main {
    background-image:
      radial-gradient(520px 260px at 12% 6%, rgba(var(--lv-teal), 0.16), transparent 70%),
      radial-gradient(620px 300px at 78% 0%, rgba(var(--lv-blue), 0.12), transparent 70%),
      radial-gradient(480px 240px at 48% 30%, rgba(var(--lv-teal), 0.07), transparent 70%);
    background-repeat: no-repeat; background-size: 140% 560px; background-position: 0% 0; animation: lv-drift 28s ease-in-out infinite alternate;
  }
  @keyframes lv-drift { from { background-position: 0% 0; } to { background-position: 22% 0; } }

  /* ── Arrival: the page, then each tile and card in turn ────────────────────────────────────────── */
  .ui-pam-hero > *, .ui-grid-stats > *, .ui-grid-2 > *, .integration-grid > * { animation: lv-rise 560ms var(--lv-glide) backwards; }
  .ui-pam-hero > :nth-child(1), .ui-grid-stats > :nth-child(1), .ui-grid-2 > :nth-child(1), .integration-grid > :nth-child(1) { animation-delay: 40ms; }
  .ui-pam-hero > :nth-child(2), .ui-grid-stats > :nth-child(2), .ui-grid-2 > :nth-child(2), .integration-grid > :nth-child(2) { animation-delay: 100ms; }
  .ui-pam-hero > :nth-child(3), .ui-grid-stats > :nth-child(3), .ui-grid-2 > :nth-child(3), .integration-grid > :nth-child(3) { animation-delay: 160ms; }
  .ui-pam-hero > :nth-child(4), .ui-grid-stats > :nth-child(4), .ui-grid-2 > :nth-child(4), .integration-grid > :nth-child(4) { animation-delay: 220ms; }
  .ui-pam-hero > :nth-child(5), .ui-grid-stats > :nth-child(5), .ui-grid-2 > :nth-child(5), .integration-grid > :nth-child(5) { animation-delay: 280ms; }
  .ui-pam-hero > :nth-child(n+6), .ui-grid-stats > :nth-child(n+6), .ui-grid-2 > :nth-child(n+6), .integration-grid > :nth-child(n+6) { animation-delay: 340ms; }
  .ui-main .ui-card { animation: lv-rise 600ms var(--lv-glide) backwards; }
  .ui-main .ui-card:nth-of-type(2) { animation-delay: 80ms; } .ui-main .ui-card:nth-of-type(3) { animation-delay: 150ms; } .ui-main .ui-card:nth-of-type(n+4) { animation-delay: 210ms; }
  @keyframes lv-rise { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
  .ui-table tbody tr { animation: lv-row 420ms var(--lv-glide) backwards; }
  .ui-table tbody tr:nth-child(1) { animation-delay: 60ms; } .ui-table tbody tr:nth-child(2) { animation-delay: 100ms; } .ui-table tbody tr:nth-child(3) { animation-delay: 140ms; }
  .ui-table tbody tr:nth-child(4) { animation-delay: 180ms; } .ui-table tbody tr:nth-child(5) { animation-delay: 220ms; } .ui-table tbody tr:nth-child(n+6) { animation-delay: 260ms; }
  @keyframes lv-row { from { opacity: 0; } to { opacity: 1; } }

  /* ── Tiles answer the pointer. (Tiles never hold menus, so lifting them is safe.) ──────────────── */
  .ui-stat { transition: transform 220ms var(--lv-glide), box-shadow 220ms var(--lv-glide), border-color 220ms; position: relative; overflow: hidden; }
  .ui-stat:hover { transform: translateY(-3px); box-shadow: 0 14px 28px -12px rgba(16, 24, 40, 0.22), 0 0 0 1px rgba(var(--lv-teal), 0.35); border-color: rgba(var(--lv-teal), 0.5); }
  .ui-stat__icon { transition: transform 360ms var(--lv-spring); }
  .ui-stat:hover .ui-stat__icon { transform: rotate(-8deg) scale(1.14); }
  .ui-stat--brand::after, a.ui-stat::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; transform: translateX(-120%);
    background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.55) 50%, transparent 65%); animation: lv-sheen 7s ease-in-out 1.2s infinite;
  }
  @keyframes lv-sheen { 0%, 78% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
  .ui-stat__value { font-variant-numeric: tabular-nums; }

  /* Cards that sit in a grid lift and glow under the pointer, and tabs light up. (Cards holding an open menu stay put.) */
  .ui-grid-stats > .ui-card, .ui-grid-2 > .ui-card, .integration-grid .conn-card, .integration-grid > .ui-card { transition: transform 240ms var(--lv-glide), box-shadow 240ms var(--lv-glide), border-color 240ms; }
  .ui-grid-stats > .ui-card:hover:not(:has(.ui-menu, details[open])), .ui-grid-2 > .ui-card:hover:not(:has(.ui-menu, details[open])), .integration-grid .conn-card:hover:not(:has(.ui-menu, details[open])) {
    transform: translateY(-4px); box-shadow: 0 16px 30px -14px rgba(16, 24, 40, 0.28); border-color: rgba(var(--lv-teal), 0.55); }
  .ui-tab { transition: color 160ms, background-color 160ms, box-shadow 220ms var(--lv-glide); }
  .ui-tab:hover { box-shadow: inset 0 -2px 0 0 rgba(var(--lv-teal), 0.55); }
  .ui-badge { transition: transform 200ms var(--lv-spring); } .ui-badge:hover { transform: scale(1.06); }

  /* ── Cards that take action wear a living line ─────────────────────────────────────────────────── */
  .ui-card:has(form)::before { background-size: 220% 100%; animation: lv-flow 9s linear infinite; }
  @keyframes lv-flow { from { background-position: 0% 0; } to { background-position: -220% 0; } }
  .ui-card { transition: box-shadow 240ms var(--lv-glide), border-color 240ms; }
  .ui-card:hover { box-shadow: 0 10px 26px -14px rgba(16, 24, 40, 0.22); border-color: var(--ui-border-strong); }

  /* ── Buttons: the gradient travels, a press sinks, a busy button spins ─────────────────────────── */
  .ui-btn--primary { background-size: 220% 100%; background-position: 0% 0; transition: background-position 420ms var(--lv-glide), box-shadow 240ms, transform 160ms; }
  .ui-btn--primary:hover { background-position: 100% 0; box-shadow: 0 8px 18px -8px rgba(var(--lv-teal), 0.7); }
  .ui-btn:active { transform: scale(0.97); }
  .ui-btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
  .ui-btn.is-busy::after { content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
    border: 2px solid rgba(26, 35, 50, 0.25); border-top-color: #1A2332; animation: lv-spin 640ms linear infinite; }
  @keyframes lv-spin { to { transform: rotate(360deg); } }

  /* ── Rows, switches, ticks ─────────────────────────────────────────────────────────────────────── */
  .ui-table tbody tr td { transition: background-color 160ms; }
  .ui-table tbody tr:hover td { background-color: rgba(var(--lv-teal), 0.07); }
  .ui-table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 0 rgb(var(--lv-teal)); }
  .ui-field > input[type="checkbox"] { transition: background-color 260ms var(--lv-glide), background-position 320ms var(--lv-spring); }
  .ui-nav__item { transition: background-color 160ms, color 160ms, transform 200ms var(--lv-glide), padding-left 200ms var(--lv-glide); }
  .ui-nav__item:hover { transform: translateX(3px); }
  .ui-empty__art { animation: lv-float 5s ease-in-out infinite; }
  @keyframes lv-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

  /* ── Messages slide in; a good result leaves on its own ────────────────────────────────────────── */
  .ui-alert { animation: lv-slide 420ms var(--lv-spring) backwards; }
  @keyframes lv-slide { from { opacity: 0; transform: translateY(-10px) scale(0.98); } to { opacity: 1; transform: none; } }
  .ui-alert.is-leaving { opacity: 0; transform: translateY(-8px); max-height: 0; padding-top: 0; padding-bottom: 0; margin: 0; border-width: 0; overflow: hidden;
    transition: opacity 360ms, transform 360ms, max-height 420ms 120ms, padding 420ms 120ms, margin 420ms 120ms; }

  /* ── The thin bar that says "working" ──────────────────────────────────────────────────────────── */
  .ui-progress { position: fixed; left: 0; top: 0; right: 0; height: 3px; z-index: 9999; pointer-events: none; opacity: 0; transition: opacity 200ms; }
  .ui-progress.is-on { opacity: 1; }
  .ui-progress i { display: block; height: 100%; width: 35%; background: linear-gradient(90deg, #0ABFBC, #2F5FC4, #0ABFBC); background-size: 200% 100%;
    border-radius: 0 3px 3px 0; box-shadow: 0 0 10px rgba(var(--lv-teal), 0.8); animation: lv-bar 1.1s ease-in-out infinite, lv-bar-colour 1.6s linear infinite; }
  @keyframes lv-bar { 0% { margin-left: -35%; width: 35%; } 60% { margin-left: 40%; width: 55%; } 100% { margin-left: 100%; width: 35%; } }
  @keyframes lv-bar-colour { to { background-position: -200% 0; } }
}


@media (prefers-reduced-motion: reduce) { .ui-progress { display: none; } }

/* Phones: no entrance animations or drifting background. On a small, slower screen they read as a half-drawn page; content appears at once. */
@media (max-width: 640px) {
  .ui-main > *, .ui-main .ui-card, .ui-table tbody tr, .ui-pam-hero > *, .ui-grid-stats > *, .ui-grid-2 > *, .integration-grid > * { animation: none !important; }
  .ui-body, .ui-main, .ui-page { animation: none !important; background-attachment: scroll !important; }
}
