/*
 * Sign-in screen.
 *
 * A split layout over the dental-clinic photo (images/login): a marketing
 * panel on the left and the sign-in card on the right, sharing the indigo
 * design system the rest of the admin uses (see app.css's token block -
 * these are the same values, just copied rather than shared, since this
 * page deliberately does not load Bootstrap or app.css: a visitor who is
 * not signed in should not have to download the whole admin stylesheet to
 * see it).
 *
 * The fonts are served from /assets/fonts, like every other asset here, so
 * the page also works on a clinic network with no internet connection.
 */

@font-face {
    font-family: 'Schibsted Grotesk';
    src: url('../fonts/schibsted-grotesk-latin.woff2') format('woff2');
    font-weight: 400 800;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('../fonts/ibm-plex-mono-400-latin.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('../fonts/ibm-plex-mono-500-latin.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

:root {
    --brand: #6366f1;
    --brand-strong: #4f46e5;
    --brand-deep: #4338ca;
    --brand-2: #8b5cf6;
    --brand-tint: #eef2ff;
    --brand-grad: linear-gradient(135deg, #6366f1, #8b5cf6);

    --ink: #1e1b2e;
    --body: #5c5972;
    --label: #4c4960;
    --muted: #9b98ac;

    --surface: #ffffff;
    --rule: #e2e0eb;
    --line: #efeef4;

    --ok: #10b981;
    --danger: #ef4444;
    --danger-text: #b91c1c;
    --danger-bg: #fee2e2;

    --sans: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

    --shadow-brand: 0 8px 18px -8px rgba(99, 102, 241, .55);
    --shadow-card: 0 30px 60px -30px rgba(30, 27, 46, .35);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: var(--sans);
    color: var(--ink);
}

body {
    background: #f4f5fc url('../images/login/Modern Dental Clinic Interior.png') center bottom / cover no-repeat fixed;
}

/* ------------------------------------------------------------------ */
/* Animations                                                          */
/* ------------------------------------------------------------------ */

@keyframes riseIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

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

/* ------------------------------------------------------------------ */
/* Page frame: hero on the left, card on the right                     */
/* ------------------------------------------------------------------ */

.login {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
    align-items: center;
    gap: 48px;
    max-width: 1680px;
    margin: 0 auto;
    padding: 40px clamp(24px, 10vw, 200px);
}

/* ------------------------------------------------------------------ */
/* Hero: brand, headline, feature tiles                                */
/* ------------------------------------------------------------------ */

.login__hero {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    padding-top: 96px;
    padding-bottom: clamp(32px, 12vh, 150px);
    animation: riseIn .6s cubic-bezier(.16, 1, .3, 1) both;
}

.login__brandmark {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    gap: 16px;
}

.login__mark {
    width: 56px;
    height: 56px;
    flex: none;
    border-radius: 16px;
    background: var(--brand-grad);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-brand);
}

.login__wordmark {
    font: 700 22px/1.2 var(--sans);
    color: var(--ink);
    letter-spacing: -0.02em;
}

.login__wordsub {
    margin-top: 4px;
    font: 500 11.5px var(--sans);
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--body);
}

.login__headline {
    margin: 0 0 22px;
    font: 800 clamp(36px, min(4.6vw, 8vh), 64px)/1.08 var(--sans);
    letter-spacing: -0.035em;
    color: #0f0d24;
}

.login__headline-accent {
    background: linear-gradient(90deg, #3b6cf6, #8b3cf0);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.login__tagline {
    max-width: 440px;
    margin: 0 0 40px;
    font: 400 18px/1.55 var(--sans);
    color: var(--body);
}

/* One row of four, always: the gap shrinks before anything wraps. Sits on
   a frosted white panel, sized to the tiles, so it reads over the photo. */
.login__features {
    display: grid;
    grid-template-columns: repeat(4, auto);
    justify-content: start;
    gap: 20px clamp(18px, 2.6vw, 44px);
    width: fit-content;
    max-width: 100%;
    margin: 0;
    padding: 22px 28px;
    list-style: none;
    background: rgba(255, 255, 255, .75);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 22px;
    box-shadow: 0 18px 40px -28px rgba(30, 27, 46, .3);
}

.login__feature {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.login__feature-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 10px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, .9);
    box-shadow: 0 6px 16px -8px rgba(30, 27, 46, .3);
}

/* Solid tints with deeper icon colours, so the tiles hold up over the photo. */
.login__feature-icon--blue   { background: #dbeafe; color: #1d4ed8; }
.login__feature-icon--pink   { background: #fce7f3; color: #db2777; }
.login__feature-icon--green  { background: #d1fae5; color: #059669; }
.login__feature-icon--violet { background: #ede9fe; color: #6d28d9; }

/* A soft white halo lifts the labels off the busier parts of the photo. */
.login__feature-name,
.login__feature-sub {
    white-space: nowrap;
    text-shadow: 0 0 6px rgba(255, 255, 255, .9), 0 0 2px rgba(255, 255, 255, .9);
}

.login__feature-name {
    font: 700 15.5px var(--sans);
    color: #0f0d24;
}

.login__feature-sub {
    font: 500 13px var(--sans);
    color: #3f3c55;
}

/* ------------------------------------------------------------------ */
/* The card                                                            */
/* ------------------------------------------------------------------ */

.login__panel {
    display: flex;
    justify-content: center;
}

.login__card {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 28px;
    box-shadow: var(--shadow-card);
    padding: 40px 44px 36px;
    overflow: hidden;
    animation: riseIn .6s cubic-bezier(.16, 1, .3, 1) .08s both;
}

.login__card-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 32px;
}

.login__card-brand .login__mark {
    margin-bottom: 14px;
}

.login__card-brand .login__wordsub {
    font-weight: 600;
    letter-spacing: 0.22em;
    /* letter-spacing also trails the last letter; pull it back so the
       line centres under the wordmark. */
    margin-right: -0.22em;
}

.login__subtitle {
    margin: 0 0 22px;
    font: 700 18px/1.5 var(--sans);
    color: var(--ink);
    text-align: center;
}

.login__form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login__field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login__label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.login__label {
    font: 600 14px var(--sans);
    color: var(--label);
}

.login__show-toggle {
    border: 0;
    background: none;
    padding: 0;
    font: 600 14px var(--sans);
    color: var(--brand-strong);
    cursor: pointer;
}

.login__show-toggle:hover,
.login__show-toggle:focus-visible {
    color: var(--brand-deep);
}

.login__input-wrap {
    position: relative;
}

.login__input-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--body);
    pointer-events: none;
}

.login__input {
    width: 100%;
    height: 52px;
    padding: 0 16px 0 52px;
    border: 1px solid var(--rule);
    border-radius: 11px;
    font-family: inherit;
    font-size: 15.5px;
    color: var(--ink);
    background: var(--surface);
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.login__input::placeholder {
    color: var(--muted);
}

.login__input:focus {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 3.5px rgba(99, 102, 241, .14);
}

.login__input[aria-invalid="true"] {
    border-color: var(--danger);
}

.login__input[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3.5px rgba(239, 68, 68, .13);
}

/* Chrome paints autofilled inputs light blue; keep the flat look. */
.login__input:-webkit-autofill {
    -webkit-text-fill-color: var(--ink);
    box-shadow: 0 0 0 1000px #fff inset;
}

.login__error {
    font: 400 12.5px var(--sans);
    color: var(--danger-text);
}

.login__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.login__check {
    display: flex;
    align-items: center;
    gap: 8px;
    font: 400 13px var(--sans);
    color: var(--body);
    user-select: none;
    cursor: pointer;
}

.login__check input {
    width: 15px;
    height: 15px;
    accent-color: var(--brand);
    margin: 0;
    cursor: pointer;
}

.login__link {
    font: 600 13px var(--sans);
    color: var(--brand-strong);
    text-decoration: none;
}

.login__link:hover,
.login__link:focus-visible {
    color: var(--brand-deep);
    text-decoration: underline;
}

/* ------------------------------------------------------------------ */
/* Submit button                                                       */
/* ------------------------------------------------------------------ */

.login__submit {
    height: 56px;
    margin-top: 6px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(90deg, #4f7cff, #8b5cf6);
    color: #fff;
    font: 700 17px var(--sans);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: var(--shadow-brand);
    transition: box-shadow .2s ease, transform .15s ease;
}

.login__submit:hover,
.login__submit:focus-visible {
    box-shadow: 0 10px 22px -8px rgba(99, 102, 241, .65);
}

.login__submit:active {
    transform: scale(.985);
}

.login__submit-idle {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* The busy state is swapped in by login.js while the form is submitting. */
.login__submit-busy {
    display: none;
    align-items: center;
    gap: 10px;
}

.login__submit.is-busy {
    cursor: progress;
}

.login__submit.is-busy .login__submit-idle {
    display: none;
}

.login__submit.is-busy .login__submit-busy {
    display: flex;
    animation: fadeIn .25s ease both;
}

.login__spinner {
    width: 15px;
    height: 15px;
    border: 1.5px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.login__progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--brand);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .9s cubic-bezier(.4, 0, .2, 1);
}

.login__progress.is-running {
    transform: scaleX(0.7);
}

/* ------------------------------------------------------------------ */
/* Floating success toast, top-right ("You have been signed out")      */
/* ------------------------------------------------------------------ */

@keyframes toastIn {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: none; }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(24px); }
}

.login-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 50;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: min(360px, calc(100vw - 32px));
    padding: 14px 14px 14px 16px;
    border-radius: 14px;
    border-left: 4px solid var(--ok);
    background: #fff;
    box-shadow: 0 18px 40px -16px rgba(30, 27, 46, .35), 0 2px 6px rgba(30, 27, 46, .06);
    overflow: hidden;
    animation: toastIn .45s cubic-bezier(.16, 1, .3, 1) .3s both;
}

/* Countdown line along the bottom edge. Its 5s matches TOAST_MS in
   login.js, and it pauses on hover just like the dismiss timer does. */
@keyframes toastTimer {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

.login-toast__timer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1.5px;
    background: var(--ok);
    opacity: .75;
    transform-origin: left;
    animation: toastTimer 5s linear .3s both;
}

.login-toast:hover .login-toast__timer {
    animation-play-state: paused;
}

.login-toast.is-leaving {
    animation: toastOut .3s ease forwards;
}

.login-toast__icon {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #d1fae5;
    color: #047857;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-toast__body {
    flex: 1;
    min-width: 0;
    padding-top: 1px;
}

.login-toast__label {
    display: block;
    margin-bottom: 2px;
    font: 600 10.5px var(--mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #047857;
}

.login-toast__body p {
    margin: 0;
    font: 400 14px/1.45 var(--sans);
    color: var(--ink);
}

.login-toast__close {
    flex: none;
    width: 28px;
    height: 28px;
    margin: -2px -2px 0 0;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color .15s ease, color .15s ease;
}

.login-toast__close:hover,
.login-toast__close:focus-visible {
    background: var(--line);
    color: var(--ink);
}

@media (max-width: 480px) {
    .login-toast {
        top: 16px;
        right: 16px;
    }
}

/* ------------------------------------------------------------------ */
/* Smaller screens                                                     */
/* ------------------------------------------------------------------ */

/* Laptops (and desktops at 125-150% display scaling) */
@media (max-width: 1440px) {
    .login {
        grid-template-columns: minmax(0, 1fr) minmax(0, 390px);
        gap: 32px;
        padding-inline: clamp(24px, 12vw, 180px);
    }

    .login__card {
        padding: 32px 30px 28px;
    }

    .login__tagline {
        font-size: 16.5px;
    }

    .login__feature-icon {
        width: 50px;
        height: 50px;
    }

    .login__feature-name {
        font-size: 14.5px;
    }

    .login__feature-sub {
        font-size: 12px;
    }

    .login__features {
        column-gap: clamp(14px, 1.8vw, 32px);
    }
}

/* Short windows: tighten everything vertically so the whole card fits
   without scrolling. */
@media (max-height: 820px) {
    .login {
        padding-block: 20px;
    }

    .login__hero {
        padding-top: 76px;
    }

    .login__mark {
        width: 46px;
        height: 46px;
        border-radius: 13px;
    }

    .login__mark svg {
        width: 22px;
        height: 22px;
    }

    .login__wordmark {
        font-size: 19px;
    }

    .login__tagline {
        margin-bottom: 28px;
    }

    .login__card {
        padding: 30px;
        border-radius: 24px;
    }

    .login__card-brand {
        margin-bottom: 24px;
    }

    .login__card-brand .login__mark {
        margin-bottom: 8px;
    }

    .login__subtitle {
        margin-bottom: 14px;
        font-size: 17px;
    }

    .login__form {
        gap: 13px;
    }

    .login__field {
        gap: 6px;
    }

    .login__input {
        height: 44px;
    }

    .login__submit {
        height: 48px;
        margin-top: 2px;
        font-size: 16px;
    }
}

@media (max-width: 1200px) {
    .login {
        gap: 32px;
        padding-inline: clamp(32px, 8vw, 96px);
    }

    .login__card {
        padding: 36px 40px 32px;
    }
}

/* Not enough width for one row of four beside the card: drop the tiles. */
@media (max-width: 1060px) {
    .login__features {
        display: none;
    }
}

/* Below this the hero would squeeze the card, so the card stands alone -
   complete, with its own copy of the brand - and only the hero's feature
   tiles stay, moved underneath it. */
@media (max-width: 860px) {
    .login {
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        align-content: center;
        gap: 28px;
        padding: 24px 20px;
    }

    .login__hero {
        order: 2;
        padding-block: 0;
    }

    .login__brandmark,
    .login__headline,
    .login__tagline {
        display: none;
    }

    .login__features {
        display: grid;
        justify-content: center;
        margin-inline: auto;
    }

    .login__feature {
        align-items: center;
        text-align: center;
    }

    .login__panel {
        width: 100%;
    }
}

/* A phone is too narrow for the four tiles in a row. */
@media (max-width: 560px) {
    .login__features {
        grid-template-columns: repeat(2, auto);
        column-gap: 40px;
    }
}

@media (max-width: 480px) {
    .login {
        padding: 24px 16px;
    }

    .login__card {
        padding: 28px 22px 26px;
        border-radius: 22px;
    }

    .login__row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* Respect the visitor's motion preference. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }

    /* The countdown line is a timer, not decoration: keep it running. */
    .login-toast__timer {
        animation-duration: 5s !important;
    }
}
