/* =========================================================
   admin-auth.html
   auth.css styles a card that holds a sign-in panel AND a sign-up panel
   (the forms-wrapper is 200% wide, sliding between them). This page has only
   the sign-in panel, so the wrapper is brought back to 100% and the card is
   given a sensible width. Load AFTER auth.css.
   ========================================================= */

.admin-auth-container {
    max-width: 480px;
    min-height: 0 !important;
    margin: 24px auto;
    border-radius: 16px;
}

.admin-auth-container .forms-wrapper {
    width: 100%;
}

.admin-auth-container .form-container {
    flex: 1 1 100%;
    width: 100%;
}

.admin-auth-error {
    margin: 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(169, 68, 66, 0.18);
    border: 1px solid var(--color-error);
    color: #ffd9d7;
    font-family: var(--font-primary);
    font-size: 13px;
    text-align: center;
}

.admin-auth-error[hidden] { display: none; }

.login-btn:disabled {
    opacity: 0.6;
    cursor: progress;
}

.eye-icon:focus-visible {
    outline: 2px solid var(--color-library-green);
    outline-offset: 2px;
}

/* Create-account panel: stacked fields. Hidden attribute must win over auth.css's display rules. */
.admin-auth-container .form-container[hidden] { display: none !important; }

.admin-auth-hint {
    color: var(--color-white);      /* the card is dark: the inherited black text was hard to read */
    margin: 0 0 4px;
    font-family: var(--font-primary);
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    opacity: 0.85;
}

.admin-auth-notice {
    margin: 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(76, 140, 74, 0.2);
    border: 1px solid var(--color-library-green);
    font-family: var(--font-primary);
    font-size: 13px;
    text-align: center;
}

.admin-auth-notice[hidden] { display: none; }


/* =========================================================
   Forgot password: the six code boxes, like the mobile app.
   One hidden number field sits on top of six cells, so typing, deleting,
   pasting a whole code and the phone's "fill from SMS" all work.
   ========================================================= */

.code-field { display: grid; gap: 8px; }

.code-label {
    font-family: var(--font-primary);
    font-size: 12px;
    letter-spacing: 0.5px;
    opacity: 0.85;
}

.code-box { position: relative; }

.code-cells {
    display: flex;
    justify-content: center;
    gap: clamp(4px, 1.8vw, 10px);
}

.code-cell {
    flex: 1 1 0;
    min-width: 0;
    max-width: 54px;
    aspect-ratio: 1 / 1.15;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-family: var(--font-primary);
    font-size: clamp(18px, 6vw, 26px);
    font-weight: 700;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.code-cell.filled { border-color: rgba(255, 255, 255, 0.65); }

/* The cell being typed in: green frame */
.code-cell.active {
    border-color: var(--color-library-green);
    box-shadow: 0 0 0 2px rgba(122, 202, 26, 0.35);
}

/* The real field: invisible, on top, so a tap anywhere on the cells types. */
.code-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    opacity: 0;
    cursor: text;
    font-size: 16px;            /* 16px stops iOS zooming in when it is focused */
    caret-color: transparent;
}

.code-count {
    text-align: center;
    font-family: var(--font-primary);
    font-size: 12px;
    opacity: 0.75;
}

/* Wrong code: red cells that shake */
.code-field.error .code-cell {
    border-color: #e5736f;
    background: rgba(169, 68, 66, 0.22);
}
.code-field.error .code-label { color: #ffd9d7; opacity: 1; }
.code-field.shake .code-cells { animation: code-shake 0.4s ease; }

@keyframes code-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

@media (prefers-reduced-motion: reduce) {
    .code-field.shake .code-cells { animation: none; }
}

.admin-auth-container [hidden] { display: none !important; }


/* =========================================================
   admin-auth.html: sliding card (sign in | forgot password | create account)
   Same slide as auth.html (0.6s ease-in-out). The three panels sit side by side in one track that is 300% wide;
   admin-auth.js sets data-panel on the card to say which one is in view, and sets the card's height to the
   height of that panel so a short panel (sign in) is not as tall as the longest one (create account).
   ========================================================= */

.admin-auth-slider .forms-wrapper {
    width: 300%;
    min-width: 300%;
    flex-shrink: 0;                 /* not "flex: 0 0 300%": on phones the card is a column and that would be a height */
    align-items: flex-start;
    transition: transform 0.6s ease-in-out;
    will-change: transform;
}

.admin-auth-slider .form-container {
    flex: 0 0 33.3333%;
    width: 33.3333%;
    height: auto;
}

.admin-auth-slider[data-panel="forgot"] .forms-wrapper   { transform: translateX(-33.3333%); }
.admin-auth-slider[data-panel="register"] .forms-wrapper { transform: translateX(-66.6667%); }

/* The card's height follows the panel in view. Not animated on first paint (the .is-ready class comes a frame later). */
.admin-auth-slider.is-ready { transition: height 0.6s ease-in-out; }

/* A panel out of view cannot be tabbed to or read out (admin-auth.js also sets inert). */
.admin-auth-slider .form-container[aria-hidden="true"] { visibility: hidden; transition: visibility 0s linear 0.6s; }
.admin-auth-slider .form-container[aria-hidden="false"] { visibility: visible; transition: visibility 0s; }

@media (prefers-reduced-motion: reduce) {
    .admin-auth-slider .forms-wrapper,
    .admin-auth-slider.is-ready,
    .admin-auth-slider .form-container[aria-hidden="true"] { transition: none; }
}

/* =========================================================
   Wide screens (768px and up): the form on one side, the tagline on the other.
   Same idea as auth.html. The card is two halves. Sign in sits on the LEFT with the tagline on the right; forgot
   password and create account sit on the RIGHT with the tagline on the left. Moving between them slides the
   forms and the tagline panel together (0.6s, like auth.html) and the tagline text changes.
   Under 768px none of this applies: the card is one column and the three panels slide as above.
   ========================================================= */
.admin-overlay { display: none; }

@media (min-width: 768px) {
    .admin-auth-container.admin-auth-slider {
        max-width: 920px;
        width: calc(100% - 48px);
        display: block;
        position: relative;
        overflow: hidden;
    }

    /* The track is only a positioning box now; each panel moves on its own. */
    .admin-auth-container.admin-auth-slider[data-panel] .forms-wrapper {
        position: absolute;
        inset: 0;
        width: 100%;
        min-width: 0;
        transform: none;
        transition: none;
    }

    .admin-auth-container.admin-auth-slider .form-container {
        position: absolute;
        top: 0;
        left: 0;
        flex: none;
        width: 50%;
        height: auto;
    }

    .admin-auth-container.admin-auth-slider .auth-form {
        padding: 12px 36px 24px;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Panel positions, in panel widths from the card's left edge: 0 = left half, 1 = right half,
       -1 = slid out to the left, 2 = waiting off to the right. */
    .admin-auth-container.admin-auth-slider[data-panel="login"] #adminLoginPanel    { transform: translateX(0); }
    .admin-auth-container.admin-auth-slider[data-panel="login"] #adminForgotPanel   { transform: translateX(200%); }
    .admin-auth-container.admin-auth-slider[data-panel="login"] #adminRegisterPanel { transform: translateX(200%); }

    .admin-auth-container.admin-auth-slider[data-panel="forgot"] #adminLoginPanel    { transform: translateX(-100%); }
    .admin-auth-container.admin-auth-slider[data-panel="forgot"] #adminForgotPanel   { transform: translateX(100%); }
    .admin-auth-container.admin-auth-slider[data-panel="forgot"] #adminRegisterPanel { transform: translateX(200%); }

    .admin-auth-container.admin-auth-slider[data-panel="register"] #adminLoginPanel    { transform: translateX(-100%); }
    .admin-auth-container.admin-auth-slider[data-panel="register"] #adminForgotPanel   { transform: translateX(-100%); }
    .admin-auth-container.admin-auth-slider[data-panel="register"] #adminRegisterPanel { transform: translateX(100%); }

    /* Only animate once the page has painted (admin-auth.js adds .is-ready), so a link to #register does not
       slide on load. A panel that has left stays visible for the length of the slide, then is hidden. */
    .admin-auth-container.admin-auth-slider.is-ready .form-container {
        transition: transform 0.6s ease-in-out, visibility 0s;
    }
    .admin-auth-container.admin-auth-slider.is-ready .form-container[aria-hidden="true"] {
        transition: transform 0.6s ease-in-out, visibility 0s linear 0.6s;
    }

    /* The tagline half */
    .admin-auth-container.admin-auth-slider .admin-overlay {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 50%;
        height: 100%;
        overflow: hidden;
        z-index: 10;
        transform: translateX(0);
    }
    .admin-auth-container.admin-auth-slider[data-panel="login"] .admin-overlay { transform: translateX(100%); }
    .admin-auth-container.admin-auth-slider.is-ready .admin-overlay { transition: transform 0.6s ease-in-out; }

    .admin-overlay-bg {
        position: relative;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background:
            radial-gradient(circle at 20% 15%, rgba(198, 231, 143, 0.28), transparent 55%),
            radial-gradient(circle at 85% 90%, rgba(0, 188, 212, 0.25), transparent 50%),
            linear-gradient(135deg, var(--color-forest-green) 0%, var(--color-cyan) 100%);
    }

    .admin-overlay-logo {
        position: absolute;
        top: 28px;
        left: 50%;
        width: 64px;
        height: auto;
        transform: translateX(-50%);
        opacity: 0.95;
    }

    /* Three taglines stacked in the same spot; the one for the panel in view fades in as the panel slides. */
    .admin-tagline {
        position: absolute;
        inset: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 96px 40px 40px;
        text-align: center;
        opacity: 0;
        transform: translateY(10px);
        visibility: hidden;
        transition: opacity 0.35s ease, transform 0.35s ease, visibility 0s linear 0.35s;
    }
    .admin-tagline.is-active {
        opacity: 1;
        transform: translateY(0);
        visibility: visible;
        transition: opacity 0.45s ease 0.25s, transform 0.45s ease 0.25s, visibility 0s;
    }

    .admin-tagline h2 {
        margin: 0 0 14px;
        color: var(--color-white);
        font-family: var(--font-primary);
        font-size: 26px;
        line-height: 1.25;
        letter-spacing: 1px;
        text-align: center;
    }
    .admin-tagline p {
        margin: 0 0 24px;
        max-width: 300px;
        color: rgba(255, 255, 255, 0.92);
        font-family: var(--font-primary);
        font-size: 13px;
        line-height: 1.7;
        text-align: center;
    }
    .admin-tagline .btn-ghost {
        display: inline-block;
        text-decoration: none;
    }
    .admin-tagline .btn-ghost:focus-visible { outline: 2px solid var(--color-white); outline-offset: 3px; }
}

@media (min-width: 768px) and (prefers-reduced-motion: reduce) {
    .admin-auth-container.admin-auth-slider.is-ready .form-container,
    .admin-auth-container.admin-auth-slider.is-ready .form-container[aria-hidden="true"],
    .admin-auth-container.admin-auth-slider.is-ready .admin-overlay,
    .admin-tagline, .admin-tagline.is-active { transition: none; }
}

/* =========================================================
   One look for all three panels: same card size, same header, same field size, nothing to scroll.
   ========================================================= */

/* The browser's own "show password" eye (Edge / Chrome autofill) drew a second eye next to ours. */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear { display: none; }
input[type="password"]::-webkit-credentials-auto-fill-button { visibility: hidden; display: none !important; pointer-events: none; }

/* Same header on every panel: title, small logo, then the form. */
.admin-auth-slider .form-container h2 {
    margin: 4px 0 6px;
    font-size: 20px;
    letter-spacing: 2px;
}
.admin-auth-slider .plantellect-logo {
    height: 44px;
    width: auto;
    margin: 0 0 4px;
}
.admin-auth-slider .auth-form {
    gap: 8px;
}
.admin-auth-slider .input-group { margin-bottom: 0; }
.admin-auth-slider .input-group input:not([type="checkbox"]) {
    padding-top: 18px;
    padding-bottom: 7px;
    font-size: 14px;
}
.admin-auth-slider .input-group input:focus + label,
.admin-auth-slider .input-group input:not(:placeholder-shown) + label {
    top: 5px;
}
.admin-auth-slider .login-btn { margin-top: 6px; padding: 12px; }
.admin-auth-slider .form-footer { margin-top: 6px; font-size: 12px; line-height: 1.4; }
.admin-auth-slider .admin-auth-hint { margin: 0; font-size: 12px; line-height: 1.45; }
.admin-auth-slider .admin-auth-error,
.admin-auth-slider .admin-auth-notice { padding: 8px 10px; font-size: 12px; }

/* ---------- Password rules: a floating tooltip under the field, only while you are in it ---------- */
.pw-field { position: relative; }

.pw-pop {
    position: absolute;
    z-index: 30;
    top: calc(100% + 8px);
    left: 0;
    box-sizing: border-box;
    width: max-content;
    min-width: 190px;
    max-width: 270px;
    margin: 0;
    padding: 10px 12px;
    background: #1d2819;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
    font-size: 12px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
}
.pw-pop::before {                       /* the little arrow pointing at the field */
    content: '';
    position: absolute;
    top: -6px;
    left: 18px;
    width: 10px;
    height: 10px;
    background: #1d2819;
    border-top: 1px solid rgba(255, 255, 255, 0.22);
    border-left: 1px solid rgba(255, 255, 255, 0.22);
    transform: rotate(45deg);
}
.pw-pop ul { margin: 0; padding: 0; }
.pw-pop li { margin: 3px 0; font-size: 12px; line-height: 1.35; white-space: nowrap; }
.pw-field:focus-within .pw-pop {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s;
}
/* Fields in the right-hand column open the tooltip toward the left so it stays inside the card. */
.pw-field--right .pw-pop { left: auto; right: 0; }
.pw-field--right .pw-pop::before { left: auto; right: 18px; }

@media (prefers-reduced-motion: reduce) {
    .pw-pop, .pw-field:focus-within .pw-pop { transition: none; }
}

/* ---------- Create account: two columns ---------- */
.admin-reg-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}
.admin-reg-grid .terms-section {
    grid-column: 1 / -1;
    margin-top: 2px;
}
.admin-auth-slider .terms-link { font-size: 12px; }
.admin-auth-slider .terms-hint { margin: 3px 0 0; font-size: 11px; }
.admin-auth-slider .terms-checkboxes { margin-top: 6px; gap: 4px; }
.admin-auth-slider .terms-check { font-size: 12px; line-height: 1.3; }

@media (min-width: 521px) {
    .admin-reg-grid { grid-template-columns: 1fr 1fr; gap: 8px 10px; }
    /* Two narrow columns: no field icon, the label starts at the edge, so the labels have room. */
    .admin-reg-grid .input-icon { display: none; }
    .admin-reg-grid .input-group input:not([type="checkbox"]) { padding-left: 12px; }
    .admin-reg-grid .input-group label:not(.checkbox-label) { left: 12px; font-size: 11px; letter-spacing: 0.8px; }
    .admin-reg-grid .password-wrapper input { padding-right: 36px; }
    .admin-reg-grid .eye-icon { right: 4px; }
}

/* ---------- Wide screens: one fixed card size, panels centred in it ---------- */
@media (min-width: 768px) {
    .hero-container { justify-content: center; padding-bottom: 0; }

    .admin-auth-container.admin-auth-slider {
        height: clamp(560px, calc(100dvh - 96px), 660px) !important;   /* wins over the height admin-auth.js sets */
        margin: 0 auto;
    }

    .admin-auth-container.admin-auth-slider .form-container {
        height: 100%;
        justify-content: safe center;       /* centred; if a screen is too short it scrolls instead of clipping the top */
        overflow-x: hidden;
        overflow-y: auto;
        scrollbar-width: thin;
    }

    .admin-auth-container.admin-auth-slider .auth-form {
        padding: 4px 32px 12px;
    }
}

/* =========================================================
   Centering. auth.css gives the empty .auth-container-footer `margin-top: auto`, which soaks up all the free
   height and pushes the heading, logo and fields to the top of the card. Here there is nothing in it, so it
   takes no room and the panel's own centring (justify-content: center) can work.
   ========================================================= */
.admin-auth-container .auth-container-footer { margin-top: 0; }

.admin-auth-container .form-container { align-items: center; text-align: center; }
.admin-auth-container .auth-form { width: 100%; }

/* Phones: the card sits in the middle of the free space under the Back button instead of hugging the top. */
@media (max-width: 767px) {
    .admin-auth-container.admin-auth-slider {
        margin-top: auto;
        margin-bottom: auto;
    }
    .admin-auth-container .form-container h2 { margin-top: 28px; }
    .admin-auth-container .login-container { padding-bottom: 12px; }
}
