/* ==========================================================================
   SmartPharmacy — Authentication screens (User Login + Building Login)
   Shared with Views/Login/Index.cshtml and Views/LoginBuilding/Index.cshtml.
   Presentation only — built on the same design tokens as the app shell
   (wwwroot/css/design-system/tokens.css) so the login experience reads as
   the same product as the dashboard.
   ========================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

/* This stylesheet only ever loads on the two auth pages, so it's safe to
   size <html> directly (no :has()/specificity gymnastics needed). */
html {
    height: 100%;
}

body.auth-body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--ds-font);
    color: var(--ds-text);
    background: var(--ds-bg);
}

.auth-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Desktop split layout is pinned to exactly one viewport — no page scroll.
   (Mobile/tablet below 992px stack vertically and keep natural min-height
   scrolling, since a phone's viewport + on-screen keyboard is too
   unpredictable to hard-pin.) */
@media (min-width: 992px) {
    body.auth-body {
        height: 100%;
        overflow: hidden;
    }

    .auth-wrapper {
        height: 100vh;
        min-height: 0;
    }
}

/* --------------------------------------------------------------------------
   Left — branding panel (_AuthBrandingPanel.cshtml)
   Background is the app's own live theme color (--ds-primary and friends),
   not a fixed brand palette — it follows accent-preset and dark-mode changes
   automatically, same as the rest of the app.
   -------------------------------------------------------------------------- */
.auth-branding {
    position: relative;
    flex: 1 1 58%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-6) var(--space-7);
    background: linear-gradient(160deg, var(--ds-primary-active) 0%, var(--ds-primary) 55%, var(--ds-primary-hover) 100%);
    color: #fff;
    transition: background .3s ease;
}

/* Enterprise fine-grid background (Option A) — ~3% opacity, no circles/blobs. */
.auth-branding-gridpattern {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .08) 1px, transparent 1px);
    background-size: 40px 40px;
    -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 12%, #000 88%, transparent 100%);
    mask-image: linear-gradient(180deg, transparent 0%, #000 12%, #000 88%, transparent 100%);
    pointer-events: none;
}

.auth-branding-inner {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-6);
}

.auth-branding-footer {
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.auth-branding-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    text-align: center;
}

/* --------------------------------------------------------------------------
   Brand hero — per-tenant logo (or the platform's own MUT-PIS
   mark before a building is selected) in a white badge, with a slow-rotating
   ring for depth (the "unique touch" — a conic sweep, not a static glow).
   -------------------------------------------------------------------------- */
.auth-brand-hero {
    position: relative;
    width: 150px;
    height: 150px;
    margin-bottom: var(--space-2);
}

.auth-brand-hero-ring {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, rgba(255, 255, 255, .9), transparent 30%, transparent 70%, rgba(255, 255, 255, .9));
    animation: authRingSpin 6s linear infinite;
}

.auth-brand-hero-ring::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--ds-primary);
}

.auth-brand-hero-badge {
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 10px;
}

.auth-brand-hero-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@keyframes authRingSpin {
    to {
        transform: rotate(360deg);
    }
}

.auth-branding-title {
    font-size: 1.625rem;
    font-weight: 800;
    line-height: 1.25;
    margin: 0;
}

.auth-branding-tagline {
    font-size: .9375rem;
    font-weight: 600;
    line-height: 1.4;
    opacity: .85;
    margin: 0;
}

.auth-rotating-highlight {
    font-size: .8125rem;
    font-weight: 500;
    line-height: 1.4;
    color: rgba(255, 255, 255, .7);
    margin: 0;
    min-height: 1.4em;
    transition: opacity .22s ease;
}

.auth-rotating-highlight.is-fading {
    opacity: 0;
}

.auth-rotating-highlight::before {
    content: "\2192\a0";
}

@media (prefers-reduced-motion: reduce) {
    .auth-brand-hero-ring {
        animation: none;
    }
}

/* --------------------------------------------------------------------------
   System benefits
   -------------------------------------------------------------------------- */
.auth-branding-features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.auth-branding-features li {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: .9375rem;
    font-weight: 500;
}

.auth-branding-features i {
    color: #fff;
    opacity: .85;
    font-size: 1rem;
}

/* --------------------------------------------------------------------------
   Unique touch — compact system-health strip. Replaces the old stat/metric
   grid with one quiet, believable "always-on" signal instead of a wall of
   marketing numbers.
   -------------------------------------------------------------------------- */
.auth-pulse-strip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: .75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, .8);
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 999px;
    padding: 6px 14px;
}

.auth-pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .35);
    animation: authLivePulse 1.8s ease-in-out infinite;
}

@keyframes authLivePulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: .4;
        transform: scale(1.3);
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-pulse-dot {
        animation: none;
    }
}

/* --------------------------------------------------------------------------
   Footer branding — "Powered by" credit (the one legitimate literal use of
   logo.png). Version/theme toggle live in _AuthTopBar.cshtml.
   -------------------------------------------------------------------------- */
.auth-branding-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: var(--space-3);
    border-top: 1px solid rgba(255, 255, 255, .1);
}

.auth-powered-by {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: .75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, .55);
    letter-spacing: .01em;
}

.auth-powered-by-logo {
    height: 15px;
    width: auto;
    /* The source PNG has its own gray/green art plus a white background.
       multiply drops the white (multiply-with-white = background shows
       through) while keeping the darker artwork visible - screen would do
       the opposite and render the white background as a solid white box. */
    mix-blend-mode: multiply;
    opacity: .9;
}

/* --------------------------------------------------------------------------
   Right — login form
   -------------------------------------------------------------------------- */
.auth-form-section {
    position: relative;
    flex: 1 1 42%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--space-6);
    /* Safety net only (e.g. a very short viewport + "large" font-size
       setting) — content is sized to fit without it in the common case. */
    overflow-y: auto;
    scrollbar-width: thin;
}

.auth-form-container {
    width: 100%;
    max-width: 460px;
}

/* --------------------------------------------------------------------------
   Top bar — theme toggle + version (right), mobile brand (left, <992px)
   -------------------------------------------------------------------------- */
.auth-topbar {
    position: absolute;
    top: 0;
    inset-inline: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    z-index: 2;
}

.auth-topbar-utilities {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-inline-start: auto;
}

.auth-version {
    font-size: .6875rem;
    font-weight: 600;
    color: var(--ds-text-muted);
    background: var(--ds-bg);
    border: 1px solid var(--ds-border);
    border-radius: 999px;
    padding: 4px 10px;
    letter-spacing: .02em;
}

.auth-theme-toggle {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ds-border);
    background: var(--ds-surface);
    color: var(--ds-text-muted);
    border-radius: var(--radius-md);
    font-size: .9375rem;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.auth-theme-toggle:hover {
    background: var(--ds-hover);
    color: var(--ds-primary);
    border-color: var(--ds-primary);
}

.auth-theme-toggle:focus-visible {
    outline: 2px solid var(--ds-primary);
    outline-offset: 2px;
}

/* Mobile brand lockup — only surfaces when the branding panel is hidden. */
.auth-mobile-brand {
    display: none;
    align-items: center;
    gap: var(--space-2);
}

.auth-mobile-brand-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    background: var(--ds-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .9375rem;
}

.auth-mobile-brand-name {
    font-size: 1rem;
    font-weight: 800;
    color: var(--ds-text);
}

.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--ds-active);
    color: var(--ds-primary);
    font-size: .75rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 999px;
    margin-bottom: var(--space-4);
}

.auth-heading {
    font-size: 2rem;
    font-weight: 700;
    color: var(--ds-text);
    margin: 0 0 var(--space-2);
}

.auth-subtitle {
    font-size: .875rem;
    font-weight: 400;
    color: var(--ds-text-muted);
    margin: 0 0 var(--space-6);
}

.auth-card {
    position: relative;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: 20px;
    box-shadow: var(--ds-shadow-sm);
    padding: 40px;
    animation: authCardIn .3s ease-out;
    transition: box-shadow .2s ease;
}

.auth-card::before {
    content: "";
    position: absolute;
    top: 0;
    inset-inline: 40px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: linear-gradient(90deg, var(--ds-primary), var(--ds-primary-hover));
}

.auth-card:hover {
    box-shadow: var(--ds-shadow-md);
}

.auth-field {
    margin-bottom: var(--space-4);
}

.auth-field-label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--ds-text);
    margin-bottom: var(--space-2);
}

.auth-input-shell {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-shell > .auth-input-icon {
    position: absolute;
    inset-inline-start: 16px;
    color: var(--ds-text-muted);
    font-size: .9375rem;
    pointer-events: none;
    transition: color .2s ease;
}

.auth-input-shell:focus-within > .auth-input-icon {
    color: var(--ds-primary);
}

.auth-input-shell > .form-control {
    height: 52px;
    padding: 0 var(--space-4) 0 44px;
    border: 1px solid var(--ds-border);
    border-radius: 12px;
    font-size: .875rem;
    color: var(--ds-text);
    background: var(--ds-surface);
    width: 100%;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.auth-input-shell > .form-control:focus {
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 4px var(--ds-active);
    outline: none;
}

.auth-toggle-password {
    position: absolute;
    inset-inline-end: 6px;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--ds-text-muted);
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color .15s ease, color .15s ease;
}

.auth-toggle-password:hover {
    background: var(--ds-hover);
    color: var(--ds-primary);
}

.auth-toggle-password:focus-visible {
    outline: 2px solid var(--ds-primary);
    outline-offset: 2px;
}

.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
}

.auth-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: .8125rem;
    color: var(--ds-text);
    cursor: pointer;
}

.auth-check input {
    width: 16px;
    height: 16px;
    accent-color: var(--ds-primary);
    cursor: pointer;
}

.auth-link {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--ds-primary);
    text-decoration: none;
}

.auth-link:hover {
    text-decoration: underline;
}

.btn-auth {
    width: 100%;
    height: 52px;
    border: none;
    border-radius: 12px;
    background: var(--ds-primary);
    color: #fff;
    font-size: .9375rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    transition: background-color .15s ease, transform .15s ease;
}

.btn-auth:hover {
    background: var(--ds-primary-hover);
}

.btn-auth:active {
    transform: translateY(1px);
}

.btn-auth:focus-visible {
    outline: 3px solid var(--ds-active);
    outline-offset: 2px;
}

.auth-trust-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: var(--space-4);
    font-size: .75rem;
    color: var(--ds-text-muted);
}

.auth-trust-line i {
    color: var(--ds-success);
}

/* --------------------------------------------------------------------------
   Footer (shared _StackSolversLoginFooter.cshtml overrides its own bg color)
   -------------------------------------------------------------------------- */
.auth-footer-spacer {
    height: 56px;
}

@keyframes authCardIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-card {
        animation: none;
    }

    .btn-auth, .auth-toggle-password {
        transition: none;
    }
}

/* --------------------------------------------------------------------------
   Responsive — hide branding panel below 992px, full-width card
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .auth-branding {
        display: none;
    }

    /* Reserve top room for the now-visible top bar (brand + toggle). */
    .auth-form-section {
        padding: 88px var(--space-4) 72px;
        justify-content: flex-start;
    }

    .auth-mobile-brand {
        display: inline-flex;
    }
}

@media (max-width: 575.98px) {
    .auth-form-section {
        padding: 84px var(--space-3) 64px;
    }

    .auth-topbar {
        padding: var(--space-4) var(--space-4);
    }

    .auth-card {
        padding: var(--space-5);
    }

    .auth-heading {
        font-size: 1.625rem;
    }
}

/* Tablet — reduced complexity: tighten side padding a touch. */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .auth-branding {
        padding: var(--space-5) var(--space-6);
    }

    .auth-branding-inner {
        max-width: 400px;
    }
}

/* RTL: mirror the split so branding stays on the reading-start side */
:root[dir="rtl"] .auth-input-shell > .auth-input-icon {
    inset-inline-start: auto;
    inset-inline-end: 16px;
}
