/* =========================================================================
   Auth chrome — shared visual scaffolding for the login + password-reset
   pages (auth/loginv2.blade.php and auth/passwords/resetv2.blade.php).
   Page-specific bits (panels, captcha, card grid, reset intro, etc.) stay
   inline in their respective Blade files; everything in this file is the
   common gradient + cover + glass-card + form-field language.
   ========================================================================= */

/* Force a known root font-size so rem units match the design (1.5rem = 21px). */
html { font-size: 14px; }

/* Neutralize Vuexy content padding so the cover fills the viewport. */
body .app-content,
body .content-wrapper,
body .content-body {
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
}

.login-root {
    position: relative;
    min-height: 100vh;
    display: flex;
    /* The two radial gradients bake in the visual effect of the old
       filter-blurred `.login-blob` elements — same soft pastel wash in the
       top-left and bottom-right corners, but as a single static background
       paint with zero runtime blur cost. Firefox and Chrome both love this. */
    background:
        radial-gradient(circle at 0% 0%, rgba(216, 180, 254, 0.35), transparent 45%),
        radial-gradient(circle at 100% 100%, rgba(147, 197, 253, 0.35), transparent 45%),
        linear-gradient(135deg, #eef2ff 0%, #faf5ff 50%, #fdf2f8 100%);
    overflow: hidden;
    /* Tailwind font-sans stack (matches the Figma design) */
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans",
        sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
        "Segoe UI Symbol", "Noto Color Emoji";
}

/* === Background blobs ===
   The visual is now baked into `.login-root`'s background radial-gradients
   above. These leftover nodes stay in the DOM (loginv2.blade still renders
   them) but paint nothing — no filter, no animation, no size. Firefox does
   not have to composite them at all. */
.login-blob { display: none; }

/* === LEFT: building cover === */
.login-cover {
    display: none;
    position: relative;
    margin: 1.5rem;
    border-radius: 1.5rem;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    opacity: 0;
    animation: login-pop 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@media (min-width: 992px)  { .login-cover { display: flex; width: 50%; } }
@media (min-width: 1280px) { .login-cover { width: 60%; } }

.login-cover-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    /* `background-image` is set inline per page via Blade's asset() helper so
       the URL resolves correctly under any APP_URL/sub-path. */
}

.login-cover-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
        rgba(147, 51, 234, 0.2),
        rgba(37, 99, 235, 0.15),
        rgba(6, 182, 212, 0.2));
}

/* Floating particles */
.login-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    animation: login-float 4s ease-in-out infinite;
}

@keyframes login-float {
    0%, 100% { transform: translateY(0);     opacity: 0.2; }
    50%      { transform: translateY(-30px); opacity: 0.8; }
}

.login-cover-inner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3rem;
    color: #fff;
    width: 100%;
}

/* Row that holds the logo badge(s) at the top of the cover. */
.login-logo-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.login-logo-badge {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 0.75rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: fit-content;
    opacity: 0;
    animation: login-slide-down 0.8s 0.4s ease-out forwards;
}

.login-logo-badge img {
    height: 80px;
    display: block;
}

.login-headline-wrap {
    opacity: 0;
    animation: login-slide-right 0.8s 0.6s ease-out forwards;
}

.login-headline {
    font-size: 3.75rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    line-height: 1.1;
    color: #fff;
}

.login-headline span {
    display: block;
    background: linear-gradient(90deg, #fef08a, #fbcfe8, #a5f3fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.login-subtitle {
    font-size: 1.25rem;
    color: rgb(255, 255, 255);
    line-height: 1.6;
    margin-bottom: 2rem;
}

/* Wrapper for headline + cards inside the cover. The cards live OUTSIDE
   .login-headline-wrap so the wrap's opacity-fade animation doesn't promote
   a compositing layer that would isolate the cards' backdrop-filter. */
.login-middle {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 40rem;
}

.login-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    max-width: 32rem;
}

.login-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 1rem;
    padding: 1rem 1.5rem 1.75rem 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    /* Hover uses the separate `translate` + `scale` properties instead of
       `transform`, because the entrance keyframe ends at `transform: none`
       with animation-fill-mode: forwards — which sits above regular
       declarations in the cascade and would override `:hover { transform }`. */
    transition: background 0.3s, translate 0.3s, scale 0.3s, box-shadow 0.3s;
    opacity: 0;
    animation: login-slide-up 0.6s ease-out forwards;
    color: white !important;
}

.login-card:nth-child(1) { animation-delay: 0.8s; }
.login-card:nth-child(2) { animation-delay: 0.9s; }

.login-card:hover {
    background: rgba(255, 255, 255, 0.3);
    translate: 0 -4px;
    scale: 1.02;
    box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.35);
}

.login-card-big {
    font-size: 2.25rem;
    font-weight: 700;
}

.login-card-small {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
}

/* === RIGHT: form column === */
.login-form-col {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
    opacity: 0;
    --from-y: 50px;
    animation: login-slide-up 0.8s 0.3s ease-out forwards;
}

@media (min-width: 992px)  { .login-form-col { width: 50%; padding: 3rem; } }
@media (min-width: 1280px) { .login-form-col { width: 40%; } }

.login-form-wrap {
    width: 100%;
    max-width: 32rem;
}

.login-card-form {
    background: rgba(255, 255, 255, 0.7);
    /* 12px is visually indistinguishable from 24px behind a 0.7-opaque white
       surface but roughly a quarter of the fragment-shader cost — matters a
       lot in Firefox, where backdrop-filter isn't as GPU-optimized. */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.6);
    overflow: hidden;
    opacity: 0;
    --from-scale: 0.9;
    animation: login-pop 0.6s 0.5s ease-out forwards;
}

.login-card-header {
    position: relative;
    height: 8rem;
    background: linear-gradient(90deg, #9333ea, #2563eb, #06b6d4);
    overflow: hidden;
}

.login-card-header .shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: login-shimmer 3s linear infinite;
    will-change: transform;
}

.login-card-header .inner {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
}

.login-card-header .inner img {
    background: rgba(255, 255, 255, 0.6);
    padding: 1rem;
    height: 100px;
    width: auto;
    border-radius: 1rem;
}

.login-card-header img {
    height: 4rem;
    display: block;
}

.login-card-body {
    position: relative;
    padding: 1rem 2rem 2rem 2rem;
}

@media (max-width: 575.98px) { .login-card-body { padding: 2rem; } }

/* Loading overlay shown over the card body while AJAX requests are pending */
.login-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(6px);
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    color: #374151;
    font-weight: 600;
    font-size: 0.9375rem;
    letter-spacing: 0.02em;
}

.login-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.login-overlay-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(147, 51, 234, 0.2);
    border-top-color: #9333ea;
    border-radius: 50%;
    animation: login-spin 0.8s linear infinite;
}

/* === Form fields === */
.login-field + .login-field { margin-top: 1.25rem; }

.login-label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.75rem;
}

.login-label .ic {
    width: 16px;
    height: 16px;
    color: #2563eb; /* default — variants below override */
}

.login-label.is-user .ic { color: #9333ea; }
.login-label.is-lock .ic { color: #2563eb; }
.login-label.is-mail .ic { color: #9333ea; }

.login-input-wrap { position: relative; }

.login-input {
    width: 100%;
    height: 3rem;
    padding: 0 1.25rem;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #e9d5ff;
    border-radius: 0.75rem;
    color: #111827;
    outline: none;
    transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
    font-size: 1rem;
}

.login-input::placeholder { color: #9ca3af; }

.login-input.is-pw {
    padding-right: 3.5rem;
    border-color: #bfdbfe;
}

.login-input:focus {
    border-color: #9333ea;
    background: #fff;
    box-shadow: 0 10px 15px -3px rgba(216, 180, 254, 0.5);
}

.login-input.is-pw:focus {
    border-color: #2563eb;
    box-shadow: 0 10px 15px -3px rgba(191, 219, 254, 0.5);
}

.login-eye-btn {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #9ca3af;
    padding: 0.25rem;
    cursor: pointer;
    transition: color 0.2s;
}

.login-eye-btn:hover { color: #2563eb; }
.login-eye-btn svg { width: 20px; height: 20px; }

/* === Submit button === */
.login-submit {
    position: relative;
    width: 100%;
    height: 3.5rem;
    margin-top: 2rem;
    background: linear-gradient(90deg, #9333ea, #2563eb, #06b6d4);
    color: #fff;
    border: none;
    border-radius: 0.75rem;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.05em;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(147, 51, 234, 0.5);
    transition: transform 0.3s, box-shadow 0.3s, background 0.3s;
}

.login-submit:hover {
    transform: translateY(-2px) scale(1.02);
    background: linear-gradient(90deg, #7e22ce, #1d4ed8, #0891b2);
    box-shadow: 0 25px 50px -12px rgba(147, 51, 234, 0.6);
}

.login-submit:active { transform: scale(0.98); }

.login-submit .shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: login-shimmer 2s linear infinite;
    pointer-events: none;
    will-change: transform;
}

.login-submit .label {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.login-submit .arrow {
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.3s, transform 0.3s;
}

.login-submit:hover .arrow {
    opacity: 1;
    transform: translateX(0);
}

/* === Alerts inside the card body === */
.login-card-body .alert {
    border-radius: 0.75rem;
    /* Slide + fade in when freshly rendered (e.g. after a failed login swaps
       in a new alert block). Animation runs once on insert. */
    animation: login-alert-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    transform-origin: top center;
}

.login-card-body .alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #166534;
}

.login-card-body .alert-success .alert-body { color: #166534; }

/* Bullet list inside an alert when multiple validation errors are combined. */
.login-card-body .alert-list {
    margin: 0.25rem 0.25rem 0.5rem 0.25rem;
    padding-left: 1.25rem;
}

.login-card-body .alert-list li + li {
    margin-top: 0.25rem;
}

@keyframes login-alert-in {
    from { opacity: 0; transform: translateY(-12px) scaleY(0.9); }
    to   { opacity: 1; transform: none; }
}

/* === Entrance keyframes ===
   All end at `transform: none` so animated elements don't leave a persistent
   transform behind — in Chromium, a lingering transform on an ancestor
   promotes it to its own compositing layer and breaks `backdrop-filter` on
   descendants. */
@keyframes login-pop {
    from { transform: scale(var(--from-scale, 0.95)); }
    to   { opacity: 1; transform: none; }
}

@keyframes login-slide-down {
    from { transform: translateY(-50px); }
    to   { opacity: 1; transform: none; }
}

@keyframes login-slide-right {
    from { transform: translateX(-50px); }
    to   { opacity: 1; transform: none; }
}

@keyframes login-slide-up {
    from { transform: translateY(var(--from-y, 20px)); }
    to   { opacity: 1; transform: none; }
}

@keyframes login-fade-in {
    to { opacity: 1; }
}

@keyframes login-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes login-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

@keyframes login-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 1199.98px) {
    .login-headline { font-size: 3rem; }
}

/* === Performance guards ===
   Firefox handles `backdrop-filter` and large blur-filter surfaces far more
   expensively than Chromium, and repaints them on every animation frame.
   The rules below turn off the infinite eye-candy for users who asked for
   reduced motion, and swap `backdrop-filter` for a solid tint on browsers
   (or user prefs) where it's disabled entirely — so no one gets a jerky page
   or an unreadable transparent card. */

@media (prefers-reduced-motion: reduce) {
    .login-card-header .shimmer,
    .login-submit .shimmer,
    .login-particle,
    .login-overlay-spinner {
        animation: none !important;
    }
    .login-card-header .shimmer,
    .login-submit .shimmer {
        display: none;
    }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .login-card-form { background: rgba(255, 255, 255, 0.92); }
    .login-card      { background: rgba(255, 255, 255, 0.25); }
    .login-logo-badge{ background: rgba(255, 255, 255, 0.2); }
    .login-overlay   { background: rgba(255, 255, 255, 0.9); }
}

/* === Firefox-only overrides ===
   `@-moz-document url-prefix()` matches every page in Firefox and is ignored
   by every other engine — the last surviving Firefox-only CSS hook. We use
   it to switch off the continuous animations that Firefox's compositor
   handles far more expensively than Chromium's (each frame re-rasterizes a
   backdrop-filtered surface). Chrome, Edge, Safari keep the full look. */
@-moz-document url-prefix() {
    /* 15 particles animating opacity+translate simultaneously repaint the
       cover on every frame in Firefox. Freeze them as static sparkles. */
    .login-particle { animation: none !important; opacity: 0.5; }

    /* Both shimmer sweeps sit inside `.login-card-form`, which has
       backdrop-filter. A sliding gradient over a backdrop-filtered surface
       invalidates the blur every frame in Firefox. Hide them entirely. */
    .login-card-header .shimmer,
    .login-submit .shimmer { display: none; }

    /* Entrance animations — the transform/scale/opacity phases run on
       elements that ALSO carry backdrop-filter (`.login-card-form`,
       `.login-card`, `.login-logo-badge`), so Firefox re-rasterizes the
       blurred backdrop on every frame of the entrance. That's the janky
       "popup" the user sees on page load. Skipping the transform side of
       the entrance — while keeping a plain opacity fade so the page doesn't
       just flash in — costs almost nothing in Firefox's compositor. */
    .login-cover,
    .login-card-form,
    .login-card,
    .login-logo-badge,
    .login-headline-wrap,
    .login-form-col,
    .login-status-row,
    .login-footer {
        animation: login-fade-in 0.4s ease-out forwards !important;
        animation-delay: 0s !important;
        opacity: 0;
    }
}
