/* ═══════════════════════════════════════════════
 *  LOGIN POPUP — v3.2
 *  Modern, mobile-first design
 * ═══════════════════════════════════════════════ */

/* ── Design tokens ── */
#login-popup-overlay,
#login-popup {
    --lp-accent:         #4f63e8;
    --lp-accent-end:     #818cf8;
    --lp-accent-hover:   #3b4fd4;
    --lp-accent-ring:    rgba(79, 99, 232, 0.18);
    --lp-text:           #111827;
    --lp-text-muted:     #6b7280;
    --lp-border:         #e5e7eb;
    --lp-input-bg:       #f9fafb;
    --lp-card-bg:        #ffffff;
    --lp-radius-sm:      8px;
    --lp-radius:         14px;
    --lp-radius-lg:      20px;
    --lp-transition:     0.2s ease;
    --lp-font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}


/* ═══════════════════════════════════════════════
 *  FULL-SCREEN OVERLAY
 *  Starts hidden — JS reveals it only after
 *  confirming the user is NOT already logged in.
 *  This eliminates the cached-page "flash" for
 *  users who are already authenticated.
 * ═══════════════════════════════════════════════ */
#login-popup-overlay {
    display: none;                /* JS sets to flex after cookie check  */
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
    padding: 24px;
    /* Background colour & image are injected inline from WP admin settings */
    background-color: #1a1a2e;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Dark gradient tint over the background image */
#login-popup-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        160deg,
        rgba(8, 8, 35, 0.72) 0%,
        rgba(0, 0, 0, 0.55) 100%
    );
    pointer-events: none;
}


/* ═══════════════════════════════════════════════
 *  CARD
 * ═══════════════════════════════════════════════ */
#login-popup {
    position: relative;
    z-index: 1;          /* above overlay ::before */
    background: var(--lp-card-bg);
    width: 100%;
    max-width: 420px;
    border-radius: var(--lp-radius-lg);
    box-shadow:
        0 4px 6px  rgba(0,0,0,0.04),
        0 12px 32px rgba(0,0,0,0.18),
        0 28px 64px rgba(0,0,0,0.16);
    overflow: hidden;
    font-family: var(--lp-font);
    animation: lpFadeUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Coloured top accent bar */
#login-popup::before {
    content: '';
    display: block;
    height: 3px;
    background: linear-gradient(90deg, var(--lp-accent), var(--lp-accent-end));
}

@keyframes lpFadeUp {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ── Shake animation on login failure ── */
@keyframes lpShake {
    0%, 100% { transform: translateX(0); }
    15%       { transform: translateX(-9px); }
    30%       { transform: translateX(8px); }
    45%       { transform: translateX(-6px); }
    60%       { transform: translateX(5px); }
    75%       { transform: translateX(-3px); }
    90%       { transform: translateX(2px); }
}

.login-popup-shake {
    animation: lpShake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) !important;
}


/* ═══════════════════════════════════════════════
 *  INNER CONTENT PADDING
 * ═══════════════════════════════════════════════ */
.login-popup-inner {
    padding: 32px 32px 28px;
}


/* ═══════════════════════════════════════════════
 *  LOGO / SITE NAME
 * ═══════════════════════════════════════════════ */
.login-popup-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-popup-logo img {
    max-height: 56px;
    width: auto;
    display: inline-block;
}

.login-popup-site-name {
    display: inline-block;
    font-size: 20px;
    font-weight: 700;
    color: var(--lp-text);
    letter-spacing: -0.3px;
    font-family: var(--lp-font);
}


/* ═══════════════════════════════════════════════
 *  FORM FIELDS
 * ═══════════════════════════════════════════════ */
.login-field {
    margin-bottom: 18px;
}

.login-field label,
#reset-password-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--lp-text);
    font-family: var(--lp-font);
    letter-spacing: 0.01em;
}

#loginform-popup input[type="text"],
#loginform-popup input[type="password"],
#reset-password-form input[type="email"] {
    display: block;
    width: 100%;
    padding: 11px 14px;
    font-size: 15px;
    font-family: var(--lp-font);
    color: var(--lp-text);
    background: var(--lp-input-bg);
    border: 1.5px solid var(--lp-border);
    border-radius: var(--lp-radius-sm);
    transition:
        border-color var(--lp-transition),
        box-shadow   var(--lp-transition),
        background   var(--lp-transition);
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1.5;
}

#loginform-popup input[type="text"]:hover,
#loginform-popup input[type="password"]:hover,
#reset-password-form input[type="email"]:hover {
    border-color: #c0c8d8;
}

#loginform-popup input[type="text"]:focus,
#loginform-popup input[type="password"]:focus,
#reset-password-form input[type="email"]:focus {
    border-color: var(--lp-accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--lp-accent-ring);
    outline: none;
}


/* ── Password field wrapper ── */
.password-input-wrap {
    position: relative;
    display: block;
}

.password-input-wrap input {
    padding-right: 46px !important;
}

.toggle-password {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--lp-text-muted);
    transition: color var(--lp-transition);
    border-radius: 4px;
    line-height: 1;
    /* Prevent tap highlight on mobile */
    -webkit-tap-highlight-color: transparent;
}

.toggle-password:hover  { color: var(--lp-text); }
.toggle-password:focus  { outline: none; }
.toggle-password:focus-visible {
    outline: 2px solid var(--lp-accent);
    outline-offset: 2px;
}


/* ── Remember me ── */
.login-remember {
    margin-bottom: 20px;
}

.login-remember label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-family: var(--lp-font);
    color: var(--lp-text-muted);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.login-remember input[type="checkbox"] {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    accent-color: var(--lp-accent);
    cursor: pointer;
    flex-shrink: 0;
}


/* ═══════════════════════════════════════════════
 *  BUTTON
 * ═══════════════════════════════════════════════ */
.lp-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: var(--lp-radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--lp-font);
    letter-spacing: 0.01em;
    cursor: pointer;
    transition:
        opacity      var(--lp-transition),
        transform    var(--lp-transition),
        box-shadow   var(--lp-transition);
    -webkit-tap-highlight-color: transparent;
    -webkit-appearance: none;
    appearance: none;
}

.lp-btn--primary {
    background: linear-gradient(135deg, var(--lp-accent) 0%, var(--lp-accent-end) 100%);
    color: #fff;
}

.lp-btn--primary:hover:not(:disabled) {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(79, 99, 232, 0.38);
}

.lp-btn--primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.lp-btn:disabled,
.lp-btn--loading {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ── Spinner (shown while loading) ── */
.lp-btn-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: lpSpin 0.65s linear infinite;
    flex-shrink: 0;
}

.lp-btn--loading .lp-btn-spinner {
    display: block;
}

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

.login-submit {
    margin-bottom: 4px;
}


/* ═══════════════════════════════════════════════
 *  STATUS MESSAGES
 * ═══════════════════════════════════════════════ */
#login-message,
#reset-message {
    margin-top: 14px;
    min-height: 0;
}

.login-msg {
    margin: 0;
    padding: 10px 14px;
    border-radius: var(--lp-radius-sm);
    font-size: 13px;
    font-family: var(--lp-font);
    line-height: 1.5;
}

.login-msg--success {
    background: #ecfdf5;
    color: #065f46;
    border: 1.5px solid #a7f3d0;
}

.login-msg--error {
    background: #fef2f2;
    color: #991b1b;
    border: 1.5px solid #fecaca;
}


/* ═══════════════════════════════════════════════
 *  LINKS (forgot password / back to login)
 * ═══════════════════════════════════════════════ */
.login-popup-links {
    text-align: center;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--lp-border);
}

.lost-password-link,
.back-to-login-link {
    color: var(--lp-accent);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--lp-font);
    transition: color var(--lp-transition);
}

.lost-password-link:hover,
.back-to-login-link:hover {
    color: var(--lp-accent-hover);
    text-decoration: underline;
}


/* ═══════════════════════════════════════════════
 *  RESET FORM
 * ═══════════════════════════════════════════════ */
.reset-description {
    font-size: 14px;
    font-family: var(--lp-font);
    color: var(--lp-text-muted);
    margin-bottom: 22px;
    line-height: 1.6;
    text-align: center;
}


/* ═══════════════════════════════════════════════
 *  MOBILE — bottom-sheet layout
 *  On small screens the card slides up from the
 *  bottom like a native mobile sheet.
 * ═══════════════════════════════════════════════ */
@media (max-width: 480px) {
    #login-popup-overlay {
        padding: 0;
        align-items: flex-end;
    }

    #login-popup {
        max-width: 100%;
        border-radius: var(--lp-radius-lg) var(--lp-radius-lg) 0 0;
        box-shadow:
            0 -4px 24px rgba(0,0,0,0.18),
            0 -1px 0   rgba(0,0,0,0.06);
        /* Override the desktop animation with a slide-up */
        animation: lpSlideUp 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    }

    @keyframes lpSlideUp {
        from { opacity: 0; transform: translateY(100%); }
        to   { opacity: 1; transform: translateY(0); }
    }

    .login-popup-inner {
        padding: 24px 20px;
        /* Extra bottom padding for iOS home-bar safe area */
        padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    }

    .login-popup-logo {
        margin-bottom: 22px;
    }
}

/* Landscape phones — keep card compact and scrollable */
@media (max-height: 560px) and (max-width: 768px) {
    #login-popup-overlay {
        align-items: center;
        padding: 12px;
        overflow-y: auto;
    }

    #login-popup {
        animation: lpFadeUp 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
        border-radius: var(--lp-radius-lg);
    }

    .login-popup-inner {
        padding: 20px 20px 20px;
    }
}