/* Auth pages (signup) + landing modals */

.auth-toast {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10050;
    border-radius: 0;
    border: none;
}

/* Prevent page shift / horizontal scroll when modals open */
html.modal-open,
body.modal-open,
body.landing-page.modal-open {
    overflow: hidden !important;
    overflow-x: hidden !important;
    max-width: 100%;
}

body.landing-page {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Modal shell — fixed width, no horizontal overflow */
.modal.auth-modal {
    z-index: 1055;
    overflow-x: hidden;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.modal.auth-modal.show {
    display: block;
    opacity: 1;
}

.auth-modal-dialog {
    max-width: 400px;
    width: 100%;
    margin: 0.75rem auto;
    max-height: calc(100dvh - 1.5rem);
}

.auth-modal-dialog--login {
    max-width: 380px;
}

.auth-modal .auth-modal-content {
    border: none;
    border-radius: 24px;
    overflow: hidden;
    opacity: 1;
    visibility: visible;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    max-height: calc(100dvh - 1.5rem);
    display: flex;
    flex-direction: column;
}

.auth-modal .auth-modal-content.auth-modal-3d {
    max-height: calc(100dvh - 2rem);
}

.auth-modal .auth-modal-header {
    background: linear-gradient(135deg, var(--brand-800) 0%, var(--primary-green) 55%, var(--brand-500) 100%);
    padding: 1.1rem 1.25rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    flex-shrink: 0;
}

.auth-modal-body {
    padding: 1rem 1.25rem 1.25rem !important;
    overflow-x: hidden !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: min(calc(100dvh - 10rem), 420px);
    flex: 1 1 auto;
    min-height: 0;
}

.auth-modal #signupForm,
.auth-modal #loginForm {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-width: 100%;
}

.auth-modal-row {
    margin-left: 0;
    margin-right: 0;
    max-width: 100%;
}

.auth-modal .input-group-auth {
    min-width: 0;
    max-width: 100%;
}

.auth-modal .input-group-auth .form-control {
    min-width: 0;
    max-width: 100%;
}

.auth-modal .input-group-text {
    flex-shrink: 0;
}

.auth-modal .input-group-auth .input-group-text {
    background: var(--surface-muted);
    border-color: var(--border-default);
    color: var(--brand-600);
}

.auth-modal .input-group-auth .form-control {
    border-color: var(--border-default);
}

.auth-modal .input-group-auth .form-control:focus {
    border-color: var(--primary-green);
    box-shadow: var(--focus-ring);
}

/* Form area — readable fields + subtle glass */
.auth-modal .auth-modal-body {
    background: rgba(248, 251, 249, 0.72) !important;
    backdrop-filter: blur(14px) saturate(1.1);
    -webkit-backdrop-filter: blur(14px) saturate(1.1);
}

.auth-modal .auth-modal-body .form-label {
    color: #1b4332 !important;
    font-weight: 600 !important;
    font-size: 0.9rem !important;
    letter-spacing: 0.01em;
    margin-bottom: 0.35rem !important;
    opacity: 1 !important;
}

.auth-modal .auth-modal-body .form-control {
    background: #ffffff !important;
    color: #081c15 !important;
    font-size: 1rem !important;
    line-height: 1.45 !important;
    font-weight: 500 !important;
    border: 2px solid #c5d4cb !important;
    min-height: 2.75rem;
    -webkit-text-fill-color: #081c15;
}

.auth-modal .auth-modal-body .form-control::placeholder {
    color: #4a6358 !important;
    opacity: 1 !important;
    font-weight: 400 !important;
}

.auth-modal .auth-modal-body .form-control:focus {
    background: #ffffff !important;
    color: #081c15 !important;
    border-color: #2d6a4f !important;
    box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.18) !important;
}

.auth-modal .input-group-auth .input-group-text {
    background: #eef5f0 !important;
    border: 2px solid #c5d4cb !important;
    border-right: none !important;
    color: #1b4332 !important;
    font-size: 1.05rem;
}

.auth-modal .input-group-auth .form-control {
    border-left: none !important;
}

.auth-modal .input-group-auth:focus-within .input-group-text {
    border-color: #2d6a4f !important;
    background: #e3f0e8 !important;
    color: #0d2818 !important;
}

.auth-modal .auth-modal-grid .form-control {
    background: #ffffff !important;
    color: #081c15 !important;
    font-size: 0.95rem !important;
    border: 2px solid #c5d4cb !important;
}

.auth-modal .password-toggle-btn {
    color: #1b4332 !important;
    font-weight: 600 !important;
    font-size: 0.8rem !important;
}

.auth-modal .password-toggle-btn:hover {
    color: #0d2818 !important;
}

.auth-modal .auth-link-gold {
    color: #0d2818 !important;
    font-weight: 600 !important;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-modal .auth-submit {
    background: linear-gradient(135deg, var(--primary-green), var(--deep-emerald));
    border: none;
    border-radius: var(--radius-md);
    transition: var(--transition-smooth);
}

/* Submit 3D hover — landing-fx.css on index; keep flat fallback elsewhere */
body:not(.landing-page) .auth-modal .auth-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(45, 106, 79, 0.35);
}

/* 3D open/close animation — see landing-fx.css (.auth-modal-dialog) */

/* Override legacy signup modal rules in style.css */
#signupModal .modal-dialog,
#loginModal .modal-dialog,
.modal.auth-modal .modal-dialog {
    max-width: 400px !important;
    width: calc(100% - 1.5rem) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    display: flex !important;
    align-items: center !important;
}

#loginModal .modal-dialog {
    max-width: 380px !important;
}

#signupModal .modal-content,
#loginModal .modal-content,
.modal.auth-modal .modal-content {
    max-width: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
    max-height: calc(100dvh - 1.5rem) !important;
}

#signupModal .modal-body,
#loginModal .modal-body,
.auth-modal-body {
    overflow-x: hidden !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

#signupModal #signupForm,
#loginModal #loginForm {
    height: auto !important;
    max-width: 100% !important;
}

.auth-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.auth-modal-grid .form-control {
    width: 100%;
    min-width: 0;
}

/* ——— Mobile phones ——— */
@media (max-width: 575.98px) {
    .modal.auth-modal {
        padding: 0 !important;
    }

    .modal.auth-modal .modal-dialog,
    #signupModal .modal-dialog,
    #loginModal .modal-dialog {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        min-height: 100dvh !important;
        max-height: 100dvh !important;
        display: flex !important;
        align-items: stretch !important;
        transform: none !important;
    }

    .modal.auth-modal .modal-content,
    #signupModal .modal-content,
    #loginModal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    .auth-modal .auth-modal-header:not(.auth-modal-header--brand) {
        border-radius: 0;
        padding: 1rem 1rem 0.85rem;
    }

    .auth-modal .auth-modal-header.auth-modal-header--brand,
    #signupModal .auth-modal-header.auth-modal-header--brand,
    #loginModal .auth-modal-header.auth-modal-header--brand {
        padding: 1.15rem 1rem 0.95rem !important;
    }

    .auth-modal-body,
    #signupModal .modal-body,
    #loginModal .modal-body {
        max-height: none !important;
        flex: 1 1 auto;
        padding: 0.75rem 1rem 1.25rem !important;
    }

    .auth-modal-grid {
        grid-template-columns: 1fr;
    }

    .auth-modal .input-group-auth {
        flex-wrap: nowrap;
        width: 100%;
    }

    .auth-modal .input-group-auth .form-control {
        font-size: 16px; /* prevents iOS zoom on focus */
    }
}

@media (max-width: 380px) {
    .auth-modal .auth-modal-header .modal-title {
        font-size: 1.05rem;
    }

    .auth-modal .auth-logo-showcase {
        --auth-logo-size: 60px !important;
        --auth-logo-outer: 74px !important;
    }

    .auth-modal .auth-modal-header.auth-modal-header--brand,
    #signupModal .auth-modal-header.auth-modal-header--brand,
    #loginModal .auth-modal-header.auth-modal-header--brand {
        padding: 1.1rem 1rem 0.9rem !important;
    }
}

/* Standalone signup page */
body.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--surface-base);
    overflow-x: hidden;
}

.auth-page-bg {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 50% at 10% 0%, rgba(45, 106, 79, 0.18), transparent 55%),
        radial-gradient(ellipse 50% 40% at 90% 100%, rgba(212, 160, 23, 0.12), transparent 50%);
    pointer-events: none;
}

.auth-shell {
    position: relative;
    width: 100%;
    max-width: 440px;
    z-index: 1;
}

.auth-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.auth-back:hover {
    color: var(--primary-green);
}

.auth-card {
    border-radius: var(--radius-xl) !important;
}

.auth-card-header {
    padding: 2rem 1.5rem 0.5rem;
}

/* ================= Auth logo — perfect circle, 3D shadow, animation ================= */
.auth-logo-showcase {
    --auth-logo-size: 72px;
    --auth-logo-outer: 86px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--auth-logo-outer);
    height: var(--auth-logo-outer);
    min-width: var(--auth-logo-outer);
    min-height: var(--auth-logo-outer);
    margin: 0 auto 0.85rem;
    flex-shrink: 0;
}

.auth-modal .auth-logo-showcase {
    margin-top: 0.15rem;
    margin-bottom: 0.65rem;
}

.auth-card-header .auth-logo-showcase {
    margin-bottom: 1rem;
}

/* Soft 3D glow behind circle */
.auth-logo-glow {
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--auth-logo-size);
    height: var(--auth-logo-size);
    margin-left: calc(var(--auth-logo-size) / -2);
    margin-top: calc(var(--auth-logo-size) / -2);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.45) 0%, rgba(64, 145, 108, 0.2) 55%, transparent 72%);
    filter: blur(6px);
    -webkit-filter: blur(6px);
    animation: authLogoGlow 3s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

.auth-logo-orbit {
    position: absolute;
    left: 50%;
    top: 50%;
    width: calc(var(--auth-logo-size) + 12px);
    height: calc(var(--auth-logo-size) + 12px);
    margin-left: calc((var(--auth-logo-size) + 12px) / -2);
    margin-top: calc((var(--auth-logo-size) + 12px) / -2);
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: rgba(255, 255, 255, 0.7);
    border-right-color: rgba(233, 184, 74, 0.55);
    animation: authLogoOrbit 5s linear infinite;
    pointer-events: none;
    z-index: 1;
}

/* Outer bezel — fixed square, always circular */
.auth-logo-ring {
    position: relative;
    z-index: 2;
    width: var(--auth-logo-size);
    height: var(--auth-logo-size);
    min-width: var(--auth-logo-size);
    min-height: var(--auth-logo-size);
    border-radius: 50%;
    aspect-ratio: 1 / 1;
    padding: 5px;
    box-sizing: border-box;
    background: linear-gradient(145deg, #ffffff 0%, #d8f3dc 45%, #95d5b2 100%);
    box-shadow:
        0 20px 45px rgba(13, 40, 24, 0.4),
        0 10px 22px rgba(0, 0, 0, 0.15),
        0 2px 6px rgba(255, 255, 255, 0.5) inset,
        0 -4px 10px rgba(27, 67, 50, 0.2) inset;
    animation: authLogoFloat 4.2s ease-in-out infinite;
}

/* Inner clip — true circle for image */
.auth-logo-frame {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.95);
    background: #fff;
    box-shadow:
        0 6px 18px rgba(45, 106, 79, 0.3),
        inset 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.auth-logo-img {
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    object-position: center center;
    display: block;
    border-radius: 50%;
    padding: 6%;
    box-sizing: border-box;
}

/* Modal header — centered logo + title (override style.css modal rules) */
.auth-modal .auth-modal-header.auth-modal-header--brand,
#signupModal .auth-modal-header.auth-modal-header--brand,
#loginModal .auth-modal-header.auth-modal-header--brand {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 1.35rem 1.25rem 1.05rem !important;
    border-bottom: none !important;
    background: linear-gradient(135deg, var(--brand-800) 0%, var(--primary-green) 55%, var(--brand-500) 100%) !important;
    position: relative !important;
}

.auth-modal .auth-modal-header--brand::after,
#signupModal .auth-modal-header--brand::after,
#loginModal .auth-modal-header--brand::after {
    display: none !important;
}

.auth-modal .auth-modal-header--brand .btn-close,
.auth-modal .auth-modal-header--brand .auth-modal-close {
    position: absolute !important;
    top: 0.7rem !important;
    right: 0.7rem !important;
    left: auto !important;
    margin: 0 !important;
    z-index: 10;
}

.auth-modal .auth-modal-header-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 0.5rem;
}

.auth-modal .auth-modal-header--brand .auth-modal-header-text {
    width: 100%;
    margin-top: 0;
}

.auth-modal .auth-modal-header--brand .auth-modal-subtitle {
    color: rgba(255, 255, 255, 0.9) !important;
    -webkit-text-fill-color: rgba(255, 255, 255, 0.9) !important;
}

.auth-modal .auth-modal-header--brand .modal-title {
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    background: none !important;
    background-image: none !important;
    background-clip: border-box !important;
    -webkit-background-clip: border-box !important;
    text-align: center !important;
    width: 100% !important;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.25);
}

.auth-modal .auth-modal-header--brand .auth-modal-header-text p {
    color: rgba(255, 255, 255, 0.9) !important;
    -webkit-text-fill-color: rgba(255, 255, 255, 0.9) !important;
}

.auth-modal .auth-modal-header--brand .auth-logo-showcase {
    position: relative;
    z-index: 3;
    margin-bottom: 0.15rem;
}

.auth-modal .auth-logo-frame {
    background: #ffffff !important;
}

.auth-modal .auth-logo-img {
    background-color: #ffffff;
    object-fit: contain;
}

@keyframes authLogoFloat {
    0%, 100% {
        transform: translateY(0);
        box-shadow:
            0 20px 45px rgba(13, 40, 24, 0.4),
            0 10px 22px rgba(0, 0, 0, 0.15),
            inset 0 2px 6px rgba(255, 255, 255, 0.5);
    }
    50% {
        transform: translateY(-8px);
        box-shadow:
            0 28px 52px rgba(45, 106, 79, 0.35),
            0 14px 28px rgba(0, 0, 0, 0.18),
            inset 0 2px 8px rgba(255, 255, 255, 0.85);
    }
}

@keyframes authLogoOrbit {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes authLogoGlow {
    0% { opacity: 0.65; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
    .auth-logo-ring,
    .auth-logo-orbit,
    .auth-logo-glow {
        animation: none !important;
    }
}

/* Legacy icon fallback (unused when auth-logo.php is included) */
.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-green), var(--deep-emerald));
    color: #fff;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 8px 24px rgba(45, 106, 79, 0.3);
}

body.auth-page .auth-submit {
    background: linear-gradient(135deg, var(--primary-green), var(--deep-emerald));
    border: none;
}

body.auth-page .input-group-auth .input-group-text {
    background: var(--surface-muted);
    border-color: var(--border-default);
    color: var(--brand-600);
}
