/* ==========================================================================
   Sign-in pages (login, forgot password, verify OTP, reset password).
   Split layout: the stage on the left and the form card on the right. One
   cubicle curtain hangs from a ceiling track across the whole page and is
   drawn aside on load.
   Colours and fonts come from theme.css.
   ========================================================================== */

body.auth-page {
    margin: 0;
    min-height: 100vh;
    background: var(--cl-background);
}

.auth-shell {
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100vh;
}

@media (min-width: 992px) {
    .auth-shell {
        grid-template-columns: 1fr 1fr;
    }
}

.auth-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem 2rem;
    z-index: 30;
    pointer-events: none;
}

.auth-header a {
    pointer-events: auto;
    display: inline-block;
}

.auth-header img {
    height: 44px;
    width: auto;
}

/* ------------------------------------------------------------------------
   Left: the stage.
   ------------------------------------------------------------------------ */
.auth-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 120px 8vw 70px;
    overflow: hidden;
    color: var(--cl-background);
    background-color: #2a2740;
    background-image:
        radial-gradient(90% 70% at 15% 0%, rgba(144, 122, 169, .45), transparent 60%),
        radial-gradient(80% 70% at 100% 100%, rgba(180, 99, 122, .35), transparent 60%);
}

/* Stage floor: boards receding into the distance. */
.auth-stage::before {
    content: "";
    position: absolute;
    left: -50%;
    right: -50%;
    bottom: -12%;
    height: 58%;
    background-image:
        linear-gradient(rgba(250, 244, 237, .18) 1px, transparent 1px),
        linear-gradient(90deg, rgba(250, 244, 237, .12) 1px, transparent 1px);
    background-size: 46px 46px;
    transform: perspective(420px) rotateX(62deg);
    transform-origin: 50% 100%;
    -webkit-mask-image: linear-gradient(to top, #000 15%, transparent 95%);
    mask-image: linear-gradient(to top, #000 15%, transparent 95%);
    pointer-events: none;
}

/* Spotlight that brightens as the curtain is drawn. */
.auth-stage::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(60% 55% at 42% 48%, rgba(250, 244, 237, .16), transparent 70%);
    opacity: 0;
    animation: stageLight .9s ease .55s forwards;
    pointer-events: none;
}

@keyframes stageLight {
    to { opacity: 1; }
}

.auth-stage > .stage-content {
    position: relative;
    z-index: 2;
    opacity: 0;
    transform: translateY(14px);
    animation: stageContentIn .7s cubic-bezier(.2, .8, .2, 1) .5s forwards;
}

@keyframes stageContentIn {
    to { opacity: 1; transform: none; }
}

.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    width: fit-content;
    margin-bottom: 1rem;
    padding: .3rem .8rem;
    border-radius: var(--cl-radius);
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    background: var(--cl-destructive);
    color: #fff;
    box-shadow: var(--cl-shadow-lg);
}

.auth-stage h2 {
    color: var(--cl-background);
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    font-weight: 700;
    line-height: 1.15;
    margin: 0;
}

.auth-stage h2 span {
    color: #ebbcba;
}

.auth-stage p {
    color: rgba(250, 244, 237, .85);
    font-size: 1.1rem;
    line-height: 1.6;
    max-width: 32rem;
    margin: 1rem 0 0;
}

/* A curtain label with its barcode being scanned. */
.stage-label {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    gap: .35rem;
    margin-top: 1.6rem;
    padding: .9rem 1rem .8rem;
    width: 230px;
    border-radius: var(--cl-radius);
    background: var(--cl-card);
    color: var(--cl-foreground);
    box-shadow: var(--cl-shadow-lg);
    overflow: hidden;
    transform: rotate(-2deg);
}

.stage-label small {
    font-family: var(--cl-font-mono);
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--cl-muted-foreground);
}

.stage-label .bars {
    height: 44px;
    background: repeating-linear-gradient(90deg,
        #575279 0 2px, transparent 2px 4px, #575279 4px 7px, transparent 7px 9px,
        #575279 9px 10px, transparent 10px 13px, #575279 13px 16px, transparent 16px 18px,
        #575279 18px 19px, transparent 19px 23px);
}

.stage-label strong {
    font-family: var(--cl-font-mono);
    font-size: .85rem;
    letter-spacing: 1px;
}

.stage-label .scan {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    background: var(--cl-destructive);
    box-shadow: 0 0 12px var(--cl-destructive);
    animation: scanSweep 2.6s ease-in-out infinite;
}

@keyframes scanSweep {
    0%, 100% { top: 8%; }
    50% { top: 92%; }
}

.stage-label .chip {
    position: absolute;
    right: 10px;
    top: 10px;
    padding: .15rem .45rem;
    border-radius: var(--cl-radius);
    background: var(--cl-success);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    animation: chipBlink 2.6s ease-in-out infinite;
}

@keyframes chipBlink {
    0%, 40%, 100% { opacity: 0; }
    55%, 85% { opacity: 1; }
}

@media (max-width: 991.98px) {
    .auth-stage {
        padding: 110px 17% 48px;
        min-height: 60vh;
    }

    .auth-stage h2 {
        font-size: 1.6rem;
    }

    .auth-stage p {
        font-size: 1rem;
    }
}

@media (min-width: 992px) {
    .auth-stage {
        min-height: 100vh;
    }
}

/* ------------------------------------------------------------------------
   Right: the form panel. Soft pleats drift behind the card, which carries a
   small rail of its own.
   ------------------------------------------------------------------------ */
.auth-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
    overflow: hidden;
    background: var(--cl-background);
}

.auth-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(140% 90% at 50% -10%, rgba(144, 122, 169, .16), transparent 55%),
        radial-gradient(120% 80% at 100% 110%, rgba(180, 99, 122, .14), transparent 60%);
}

/* Drifting pleats: very low contrast, so the card still reads first. */
.auth-pleats {
    position: absolute;
    inset: -10% -20%;
    z-index: 0;
    pointer-events: none;
    background: repeating-linear-gradient(90deg,
        rgba(87, 82, 121, 0) 0px, rgba(87, 82, 121, .05) 30px, rgba(87, 82, 121, 0) 60px);
    animation: pleatsDrift 14s ease-in-out infinite;
}

@keyframes pleatsDrift {
    0%, 100% { transform: translateX(0) skewX(0deg); }
    50% { transform: translateX(28px) skewX(-1.5deg); }
}

.auth-card {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 28rem;
    padding: 2.4rem 2rem 2rem;
    text-align: center;
    background: var(--cl-card);
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius-lg);
    box-shadow: var(--cl-shadow-lg);
    overflow: hidden;
}

/* The card's own rail with rings. */
.card-rail {
    position: absolute;
    top: 14px;
    left: 18px;
    right: 18px;
    height: 5px;
    border-radius: 3px;
    background: linear-gradient(180deg, #e2dde0, #a8a1a9);
    z-index: 3;
}

.card-rail i {
    position: absolute;
    top: -4px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 3px solid #cfc9cf;
    background: var(--cl-card);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
    transition: left .6s cubic-bezier(.2, 1, .3, 1);
}

/* Rings sit gathered at the edges and spread a little while typing. */
.card-rail i:nth-child(1) { left: 2%; }
.card-rail i:nth-child(2) { left: 10%; }
.card-rail i:nth-child(3) { left: 18%; }
.card-rail i:nth-child(4) { left: 78%; }
.card-rail i:nth-child(5) { left: 86%; }
.card-rail i:nth-child(6) { left: 94%; }

.auth-card:focus-within .card-rail i:nth-child(3) { left: 24%; }
.auth-card:focus-within .card-rail i:nth-child(4) { left: 72%; }

/* The card settles into place as the curtain's edge passes it. */
.auth-card {
    opacity: 0;
    transform: translateY(18px) scale(.985);
    animation: cardIn .65s cubic-bezier(.2, .8, .2, 1) .8s forwards;
}

@keyframes cardIn {
    to { opacity: 1; transform: none; }
}

.auth-brand-id {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-family: var(--cl-font-mono);
    font-size: 10px;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--cl-destructive);
    font-weight: 700;
}

.auth-brand-id::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cl-destructive);
    box-shadow: 0 0 10px var(--cl-destructive);
}

.auth-title {
    margin: .75rem 0 0;
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--cl-foreground);
}

.auth-detail {
    margin: 1rem 0 0;
    font-size: 1rem;
    color: var(--cl-muted-foreground);
}

.auth-body {
    margin-top: 1.5rem;
    text-align: left;
}

.auth-card label {
    font-family: var(--cl-font-mono);
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--cl-muted-foreground);
    margin-bottom: .35rem;
}

.auth-group {
    margin-bottom: 1rem;
    transition: transform .4s cubic-bezier(.2, 1, .3, 1);
}

.auth-group:focus-within {
    transform: translateX(6px);
}

.auth-field {
    position: relative;
}

.auth-field > .auth-icon {
    position: absolute;
    left: .85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cl-muted-foreground);
    pointer-events: none;
}

.auth-field .form-control {
    height: 44px;
    padding-left: 2.5rem;
    padding-right: 2.5rem;
}

.auth-field .auth-eye {
    position: absolute;
    right: .85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cl-muted-foreground);
    cursor: pointer;
    background: none;
    border: 0;
    padding: 0;
}

.auth-field .auth-eye:hover {
    color: var(--cl-primary);
}

.auth-submit {
    width: 100%;
    height: 44px;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: transform .2s ease, box-shadow .2s ease, letter-spacing .3s ease, background-color .15s ease;
}

.auth-submit:hover {
    letter-spacing: 4px;
}

.auth-link {
    font-size: .875rem;
    font-weight: 500;
    color: var(--cl-destructive);
    text-decoration: none;
}

.auth-link:hover {
    color: var(--cl-destructive-hover);
    text-decoration: underline;
}

.auth-note {
    font-size: .875rem;
    color: var(--cl-muted-foreground);
}

/* ---- "Use demo credentials" ---- */
.demo-creds-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .65rem 1rem;
    margin-bottom: 1.5rem;
    border: 1px dashed var(--cl-primary);
    border-radius: var(--cl-radius);
    background: var(--cl-primary-soft);
    color: var(--cl-primary);
    font-family: var(--cl-font-mono);
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all .2s ease;
}

.demo-creds-btn:hover {
    border-style: solid;
    background: var(--cl-primary);
    color: var(--cl-primary-foreground);
}

.demo-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(42, 39, 64, .6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}

.demo-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.demo-dialog {
    width: 100%;
    max-width: 24rem;
    padding: 1.5rem;
    text-align: center;
    background: var(--cl-card);
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius-lg);
    box-shadow: var(--cl-shadow-lg);
    transform: translateY(8px) scale(.98);
    transition: transform .2s ease;
}

.demo-overlay.is-open .demo-dialog {
    transform: none;
}

.demo-dialog h3 {
    margin: .5rem 0 .25rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.demo-dialog > p {
    margin-bottom: 1.25rem;
    font-size: .875rem;
    color: var(--cl-muted-foreground);
}

.demo-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1rem;
    margin-bottom: .75rem;
    text-align: left;
    background: var(--cl-background);
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius);
    color: var(--cl-foreground);
    transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}

.demo-option:hover,
.demo-option:focus-visible {
    border-color: var(--cl-primary);
    background: var(--cl-primary-soft);
    box-shadow: var(--cl-shadow);
}

.demo-option-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--cl-radius);
    background: var(--cl-primary);
    color: var(--cl-primary-foreground);
    box-shadow: var(--cl-shadow);
    font-size: 1.1rem;
}

.demo-option-icon.is-secondary {
    background: var(--cl-destructive);
    color: #fff;
}

.demo-option-text {
    min-width: 0;
}

.demo-option-text strong {
    display: block;
    font-weight: 600;
}

.demo-option-text small {
    display: block;
    font-size: .75rem;
    color: var(--cl-muted-foreground);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.demo-option .demo-arrow {
    margin-left: auto;
    color: var(--cl-border);
}

.demo-option:hover .demo-arrow {
    color: var(--cl-primary);
}

.demo-cancel {
    margin-top: .25rem;
    background: none;
    border: 0;
    font-size: .875rem;
    color: var(--cl-muted-foreground);
}

.demo-cancel:hover {
    color: var(--cl-foreground);
}

/* ---- OTP boxes ---- */
.otp-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.otp-inputs input {
    width: 54px;
    height: 54px;
    text-align: center;
    font-family: var(--cl-font-mono);
    font-size: 22px;
    font-weight: 700;
    color: var(--cl-foreground);
    background: var(--cl-background);
    border: 1px solid var(--cl-input);
    border-radius: var(--cl-radius);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.otp-inputs input:focus {
    border-color: var(--cl-primary);
    box-shadow: 0 0 0 .2rem var(--cl-ring);
}

#countdown {
    font-family: var(--cl-font-mono);
    font-weight: 700;
    color: var(--cl-primary);
}

#countdown.is-expired {
    color: var(--cl-destructive);
}

@media (max-width: 576px) {
    .auth-card {
        padding: 2rem 1.25rem 1.5rem;
    }

    .otp-inputs input {
        width: 46px;
        height: 46px;
        font-size: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-pleats,
    .stage-label .scan,
    .stage-label .chip { animation: none; }
    .auth-stage > .stage-content,
    .auth-stage::after,
    .auth-card { animation: none; opacity: 1; transform: none; }
}
