/*
 * ─────────────────────────────────────────────────────────────────────────────
 *  ATOMIX LOGIN GATE — Modal Stylesheet
 *  Version: 1.0.0
 *  
 *  Sections:
 *  1. Base Reset & Variables
 *  2. Body Lock
 *  3. Overlay & Blur
 *  4. Modal Box
 *  5. Logo
 *  6. Title & Description
 *  7. Tabs
 *  8. Social Login (Nextend)
 *  9. Divider
 * 10. Alert Messages
 * 11. Panels
 * 12. Form & Fields
 * 13. Password Strength
 * 14. Submit Button
 * 15. Spinner
 * 16. Terms Text
 * 17. Animations
 * 18. Mobile (≤ 520px)
 * 19. Very small phones (≤ 380px)
 * 20. High-contrast / reduced-motion
 * ─────────────────────────────────────────────────────────────────────────────
 */


/* ─── 1. Base Reset & Variables ─────────────────────────────────────────────── */

:root {
    --alg-primary:      #4f46e5;
    --alg-primary-dark: #4338ca;
    --alg-primary-ring: rgba(79, 70, 229, 0.18);
    --alg-text:         #111827;
    --alg-muted:        #6b7280;
    --alg-border:       #d1d5db;
    --alg-bg-input:     #f9fafb;
    --alg-bg-modal:     #ffffff;
    --alg-radius-md:    10px;
    --alg-radius-lg:    16px;
    --alg-error:        #dc2626;
    --alg-error-bg:     #fef2f2;
    --alg-error-border: #fecaca;
    --alg-success:      #16a34a;
    --alg-success-bg:   #f0fdf4;
    --alg-success-border:#bbf7d0;
    --alg-transition:   0.2s ease;
}

/* Scope reset to our modal only — never touch the rest of the page */
#alg-modal-overlay *,
#alg-modal-overlay *::before,
#alg-modal-overlay *::after {
    box-sizing: border-box;
}

#alg-modal-overlay input,
#alg-modal-overlay button,
#alg-modal-overlay label,
#alg-modal-overlay p,
#alg-modal-overlay h1,
#alg-modal-overlay h2 {
    margin: 0;
    padding: 0;
    font-family: inherit;
}


/* ─── 2. Body Lock ──────────────────────────────────────────────────────────── */

body.alg-body-locked {
    overflow: hidden !important;
    /* Prevent layout shift on scrollable pages */
    padding-right: var(--alg-scrollbar-width, 0px);
}


/* ─── 3. Overlay & Blur ─────────────────────────────────────────────────────── */

#alg-modal-overlay {
    position: fixed;
    inset: 0; /* top/right/bottom/left: 0 — fills viewport */
    z-index: 999999; /* Above Elementor, WC notices, everything */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    /* Soft dark overlay */
    background: rgba(0, 0, 0, 0.60);
    /* Blur the page content (6px as per spec) */
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    /* Entrance animation */
    animation: alg-fade-in 0.22s ease both;
    /* Prevent accidental selection of page content behind modal */
    user-select: none;
}


/* ─── 4. Modal Box ──────────────────────────────────────────────────────────── */

.alg-modal-box {
    position: relative;
    background: var(--alg-bg-modal);
    border-radius: var(--alg-radius-lg);
    box-shadow:
        0 4px 6px rgba(0,0,0,0.07),
        0 10px 25px rgba(0,0,0,0.12),
        0 25px 60px rgba(0,0,0,0.18);
    width: 100%;
    max-width: 460px;
    max-height: 92vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 36px 40px 44px;
    /* Enable momentum scroll on iOS */
    -webkit-overflow-scrolling: touch;
    /* Entrance animation */
    animation: alg-slide-up 0.28s cubic-bezier(0.34, 1.2, 0.64, 1) both;
    /* Allow text selection inside modal */
    user-select: text;
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--alg-border) transparent;
}

.alg-modal-box:focus {
    outline: none;
}

.alg-modal-box::-webkit-scrollbar { width: 6px; }
.alg-modal-box::-webkit-scrollbar-track { background: transparent; }
.alg-modal-box::-webkit-scrollbar-thumb { background: var(--alg-border); border-radius: 3px; }


/* ─── 5. Logo ───────────────────────────────────────────────────────────────── */

.alg-modal-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.alg-modal-logo img {
    max-width: 150px;
    max-height: 56px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.alg-modal-logo .alg-site-name {
    font-size: 20px;
    font-weight: 800;
    color: var(--alg-text);
    letter-spacing: -0.02em;
}


/* ─── 6. Title & Description ────────────────────────────────────────────────── */

.alg-modal-title {
    font-size: 22px !important;
    font-weight: 700 !important;
    color: var(--alg-text) !important;
    text-align: center;
    margin-bottom: 6px !important;
    line-height: 1.25 !important;
    letter-spacing: -0.01em;
}

.alg-modal-desc {
    font-size: 14px;
    color: var(--alg-muted);
    text-align: center;
    margin-bottom: 22px !important;
    line-height: 1.5;
}


/* ─── 7. Tabs ───────────────────────────────────────────────────────────────── */

.alg-tabs {
    display: flex;
    background: #f3f4f6;
    border-radius: var(--alg-radius-md);
    padding: 4px;
    margin-bottom: 22px;
    gap: 4px;
}

.alg-tab {
    flex: 1;
    padding: 9px 16px;
    border: none !important;
    background: transparent !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    cursor: pointer;
    color: var(--alg-muted) !important;
    transition: background var(--alg-transition), color var(--alg-transition), box-shadow var(--alg-transition);
    outline: none !important;
    box-shadow: none !important;
    line-height: 1.4 !important;
}

.alg-tab:focus-visible {
    outline: 2px solid var(--alg-primary) !important;
    outline-offset: 2px !important;
}

.alg-tab--active {
    background: #ffffff !important;
    color: var(--alg-text) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.06) !important;
}


/* ─── 8. Social Login (Nextend) ─────────────────────────────────────────────── */

.alg-social-login {
    margin-bottom: 18px;
}

.alg-social-label {
    font-size: 13px;
    color: var(--alg-muted);
    text-align: center;
    margin-bottom: 10px;
}

/* Override Nextend button styles to match modal */
.alg-social-login .nsl-container {
    flex-direction: column !important;
    gap: 8px !important;
}

.alg-social-login .nsl-container-block .nsl-button {
    width: 100% !important;
    border-radius: var(--alg-radius-md) !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    padding: 10px 16px !important;
    min-height: 44px !important;
    justify-content: center !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.10) !important;
    border: 1.5px solid var(--alg-border) !important;
    transition: box-shadow var(--alg-transition) !important;
}

.alg-social-login .nsl-container-block .nsl-button:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.14) !important;
}


/* ─── 9. Divider ────────────────────────────────────────────────────────────── */

.alg-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0 0;
}

.alg-divider::before,
.alg-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--alg-border);
}

.alg-divider span {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
}


/* ─── 10. Alert Messages ────────────────────────────────────────────────────── */

.alg-messages {
    display: none;
    padding: 12px 14px;
    border-radius: var(--alg-radius-md);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 16px;
    animation: alg-fade-in 0.18s ease both;
}

.alg-messages.alg-msg-error {
    display: block;
    background: var(--alg-error-bg);
    color: var(--alg-error);
    border: 1px solid var(--alg-error-border);
}

.alg-messages.alg-msg-success {
    display: block;
    background: var(--alg-success-bg);
    color: var(--alg-success);
    border: 1px solid var(--alg-success-border);
}

/* Per-field inline errors */
.alg-field-error {
    display: block;
    font-size: 12px;
    color: var(--alg-error);
    margin-top: 3px;
    min-height: 14px;
    line-height: 1.3;
}


/* ─── 11. Panels ────────────────────────────────────────────────────────────── */

.alg-panel {
    display: none;
}

.alg-panel--active {
    display: block;
    animation: alg-fade-in 0.16s ease both;
}

/* HTML hidden attribute support */
.alg-panel[hidden] {
    display: none !important;
}


/* ─── 12. Form & Fields ─────────────────────────────────────────────────────── */

.alg-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.alg-field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.alg-field-group label {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #374151 !important;
    line-height: 1.4 !important;
    display: block;
}

.alg-required {
    color: var(--alg-error);
    margin-left: 2px;
}

/* Two-column row (First/Last name) */
.alg-field-row-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Inline row (Remember Me + Forgot PW) */
.alg-field-row-inline {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px !important;
}

/* ── Input Field ─────────────────────────── */

.alg-input {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--alg-border);
    border-radius: var(--alg-radius-md);
    /* font-size 16px prevents iOS zoom on focus */
    font-size: 16px !important;
    color: var(--alg-text);
    background: var(--alg-bg-input);
    transition: border-color var(--alg-transition), box-shadow var(--alg-transition), background var(--alg-transition);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1.4;
}

.alg-input:focus {
    border-color: var(--alg-primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px var(--alg-primary-ring);
}

.alg-input.alg-input-error {
    border-color: var(--alg-error);
}

.alg-input.alg-input-error:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}

.alg-input::placeholder {
    color: #c0c7d0;
}

/* ── Input with toggle button ─────────────── */

.alg-input-wrap {
    position: relative;
}

.alg-input-wrap .alg-input {
    padding-right: 46px;
}

.alg-toggle-pw {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none !important;
    border: none !important;
    padding: 4px !important;
    cursor: pointer;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--alg-transition);
    outline: none !important;
    box-shadow: none !important;
    line-height: 0;
    /* Ensure sufficient touch target */
    min-width: 32px;
    min-height: 32px;
}

.alg-toggle-pw:focus-visible {
    outline: 2px solid var(--alg-primary) !important;
    border-radius: 4px !important;
    outline-offset: 2px !important;
}

.alg-toggle-pw:hover {
    color: var(--alg-primary) !important;
}

/* ── Checkbox ────────────────────────────── */

.alg-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px !important;
    font-weight: 400 !important;
    color: #374151 !important;
    cursor: pointer;
    user-select: none;
}

.alg-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--alg-primary);
    flex-shrink: 0;
}

/* ── Links ────────────────────────────────── */

.alg-link {
    font-size: 13px;
    color: var(--alg-primary);
    text-decoration: none !important;
    font-weight: 500;
    transition: color var(--alg-transition);
}

.alg-link:hover,
.alg-link:focus {
    color: var(--alg-primary-dark);
    text-decoration: underline !important;
}

.alg-link:focus-visible {
    outline: 2px solid var(--alg-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

.alg-forgot-pw {
    white-space: nowrap;
}


/* ─── 13. Password Strength ─────────────────────────────────────────────────── */

.alg-pw-strength-bar {
    width: 100%;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.alg-pw-strength-fill {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.alg-pw-strength-text {
    font-size: 12px;
    margin-top: 3px;
    display: block;
    min-height: 16px;
    line-height: 1.3;
    transition: color var(--alg-transition);
}

/* States set by JS */
.alg-pw-strength-fill.pw-weak   { width: 33%; background: var(--alg-error); }
.alg-pw-strength-fill.pw-fair   { width: 66%; background: #f59e0b; }
.alg-pw-strength-fill.pw-strong { width: 100%; background: var(--alg-success); }

.alg-pw-strength-text.pw-weak   { color: var(--alg-error); }
.alg-pw-strength-text.pw-fair   { color: #d97706; }
.alg-pw-strength-text.pw-strong { color: var(--alg-success); }


/* ─── 14. Submit Button ─────────────────────────────────────────────────────── */

.alg-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    width: 100% !important;
    padding: 13px 20px !important;
    background: var(--alg-primary) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: var(--alg-radius-md) !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: background var(--alg-transition), transform 0.1s ease, box-shadow var(--alg-transition) !important;
    margin-top: 4px;
    outline: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    /* Minimum 44×44px touch target */
    min-height: 48px !important;
    line-height: 1.3 !important;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 3px rgba(79,70,229,0.25), 0 4px 12px rgba(79,70,229,0.18) !important;
    text-decoration: none !important;
}

.alg-btn:hover:not(:disabled) {
    background: var(--alg-primary-dark) !important;
    box-shadow: 0 2px 6px rgba(79,70,229,0.30), 0 6px 18px rgba(79,70,229,0.22) !important;
}

.alg-btn:active:not(:disabled) {
    transform: scale(0.985) !important;
}

.alg-btn:focus-visible {
    outline: 3px solid var(--alg-primary) !important;
    outline-offset: 3px !important;
}

.alg-btn:disabled {
    opacity: 0.72 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

.alg-btn-text {
    transition: opacity var(--alg-transition);
}

.alg-btn.alg-loading .alg-btn-text {
    opacity: 0.80;
}


/* ─── 15. Spinner ───────────────────────────────────────────────────────────── */

.alg-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    flex-shrink: 0;
}

.alg-btn.alg-loading .alg-spinner {
    display: block;
    animation: alg-spin 0.65s linear infinite;
}


/* ─── 16. Terms Text ────────────────────────────────────────────────────────── */

.alg-terms {
    font-size: 12px !important;
    color: #9ca3af !important;
    line-height: 1.55 !important;
    text-align: center;
    margin: 0 !important;
}

.alg-terms a {
    color: var(--alg-primary) !important;
    text-decoration: none !important;
    font-weight: 500;
}

.alg-terms a:hover {
    text-decoration: underline !important;
}


/* ─── 17. Animations ────────────────────────────────────────────────────────── */

@keyframes alg-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes alg-slide-up {
    from {
        opacity: 0;
        transform: translateY(28px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

@keyframes alg-shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}

.alg-shake {
    animation: alg-shake 0.4s ease;
}

/* Dismiss (fade out) */
.alg-overlay-dismiss {
    animation: alg-fade-in 0.25s ease reverse both;
}


/* ─── 18. Mobile (≤ 520px) ──────────────────────────────────────────────────── */

@media (max-width: 520px) {
    .alg-modal-box {
        padding: 28px 22px 32px;
        border-radius: 14px;
        max-height: 95vh;
    }

    .alg-modal-title {
        font-size: 19px !important;
    }

    .alg-field-row-two {
        grid-template-columns: 1fr;
    }

    .alg-btn {
        font-size: 15px !important;
    }
}


/* ─── 19. Very Small Phones (≤ 380px) ───────────────────────────────────────── */

@media (max-width: 380px) {
    .alg-modal-box {
        padding: 22px 16px 28px;
        border-radius: 12px;
    }

    .alg-modal-title {
        font-size: 17px !important;
    }

    .alg-field-row-inline {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
}


/* ─── 20. High Contrast / Reduced Motion ────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    #alg-modal-overlay,
    .alg-modal-box,
    .alg-panel--active,
    .alg-messages,
    .alg-pw-strength-fill {
        animation: none !important;
        transition: none !important;
    }
}

@media (forced-colors: active) {
    .alg-btn {
        border: 2px solid ButtonText !important;
    }

    .alg-input:focus {
        outline: 3px solid Highlight;
    }
}
