/* =========================================================
   GYANCHECK AUTH MODAL
   Modern responsive Firebase authentication UI
   ========================================================= */

   :root {
    --auth-primary: #2563eb;
    --auth-primary-dark: #1d4ed8;
    --auth-primary-light: #eff6ff;

    --auth-text: #0f172a;
    --auth-text-soft: #64748b;
    --auth-text-muted: #94a3b8;

    --auth-border: #e2e8f0;
    --auth-input: #f8fafc;
    --auth-white: #ffffff;

    --auth-success: #059669;
    --auth-danger: #dc2626;

    --auth-radius: 18px;
}

/* =========================================================
   TOAST
   ========================================================= */

#custom-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.custom-toast {
    min-width: 260px;
    max-width: 380px;
    padding: 13px 18px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 15px 35px rgba(15, 23, 42, 0.18);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    will-change: transform, opacity; /* PERF FIX */
}

.custom-toast.toast-show {
    opacity: 1;
    transform: translateY(0);
}

.custom-toast.toast-success { background: #059669; }
.custom-toast.toast-error { background: #dc2626; }

/* =========================================================
   MODAL OVERLAY (PERFORMANCE FIXED)
   ========================================================= */

#authModal.modal-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.85); /* Darkened to replace blur */
    transform: translateZ(0); 

    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    box-sizing: border-box;
    will-change: opacity, visibility; /* PERF FIX */
}

#authModal.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* =========================================================
   MAIN MODAL
   ========================================================= */

#authModal .modal-box.split-modal {
    position: relative;
    width: min(920px, 100%);
    max-height: min(720px, calc(100dvh - 40px));
    display: flex;
    background: var(--auth-white);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.22); /* Lighter shadow for perf */
    transform: translateY(20px) scale(0.97);
    
    /* Added cool spring bounce animation */
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-sizing: border-box;
    will-change: transform; /* PERF FIX */
}

#authModal.modal-overlay.active .modal-box.split-modal {
    transform: translateY(0) scale(1);
}

/* =========================================================
   CLOSE BUTTON
   ========================================================= */

#authModal .modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    color: #475569;
    font-size: 16px;
    cursor: pointer;
    z-index: 50;
    box-shadow: 0 5px 18px rgba(15, 23, 42, 0.12);
    transition: background 0.2s ease, color 0.2s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#authModal .modal-close:hover {
    background: #ef4444;
    color: #fff;
    transform: rotate(90deg) scale(1.1); /* Added scale to animation */
}

/* =========================================================
   LEFT BRAND PANEL (ANIMATIONS ADDED)
   ========================================================= */

#authModal .modal-side-panel {
    position: relative;
    width: 39%;
    min-width: 320px;
    padding: 50px 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
    background: radial-gradient(circle at 15% 20%, rgba(255,255,255,0.16), transparent 28%),
                radial-gradient(circle at 90% 85%, rgba(255,255,255,0.10), transparent 30%),
                linear-gradient(145deg, #2563eb 0%, #1d4ed8 50%, #1e3a8a 100%);
    overflow: hidden;
    box-sizing: border-box;
}

/* Floating Animation for decorative circles */
@keyframes floatShapes {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(5deg); }
}

#authModal .modal-side-panel::before,
#authModal .modal-side-panel::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.12);
    pointer-events: none;
    will-change: transform;
}

#authModal .modal-side-panel::before {
    width: 260px; height: 260px;
    top: -110px; left: -110px;
    animation: floatShapes 8s ease-in-out infinite;
}

#authModal .modal-side-panel::after {
    width: 320px; height: 320px;
    right: -180px; bottom: -170px;
    animation: floatShapes 10s ease-in-out infinite reverse;
}

/* side content */
#authModal .side-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 280px;
}

#authModal .side-content h2 {
    margin: 0 0 15px;
    color: #fff;
    font-size: 30px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -0.6px;
}

#authModal .side-content p {
    margin: 0 auto 30px;
    color: rgba(255,255,255,0.88);
    font-size: 15px;
    line-height: 1.65;
}

/* side button */
#authModal .ghost-btn {
    width: 100%;
    max-width: 210px;
    min-height: 48px;
    padding: 0 25px;
    border: 1.5px solid rgba(255,255,255,0.85);
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

#authModal .ghost-btn:hover {
    background: #fff;
    color: var(--auth-primary);
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}

/* =========================================================
   RIGHT FORM PANEL
   ========================================================= */

#authModal .modal-form-panel {
    flex: 1;
    min-width: 0;
    padding: 42px 52px;
    background: #fff;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

#authModal .modal-form-panel::-webkit-scrollbar { width: 5px; }
#authModal .modal-form-panel::-webkit-scrollbar-track { background: transparent; }
#authModal .modal-form-panel::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 20px; }

#authModal #registerSection,
#authModal #loginSection,
#authModal #forgotSection {
    width: 100%;
    max-width: 430px;
    margin: 0 auto;
}

/* =========================================================
   HEADER
   ========================================================= */

#authModal .modal-header {
    text-align: center;
    margin-bottom: 24px;
}

#authModal .modal-header h3 {
    margin: 0 0 8px;
    color: var(--auth-text);
    font-size: 27px;
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: -0.5px;
}

#authModal .modal-header p {
    margin: 0;
    color: var(--auth-text-muted);
    font-size: 14px;
    line-height: 1.5;
}

/* =========================================================
   INPUTS
   ========================================================= */
#authModal form { width: 100%; }
#authModal .form-group {
    position: relative;
    margin-bottom: 15px;
    width: 100%;
}

#authModal .input-with-icon { position: relative; }
#authModal .input-icon {
    position: absolute;
    left: 17px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 15px;
    pointer-events: none;
    z-index: 3;
    transition: color 0.3s ease;
}

#authModal .form-input {
    width: 100%;
    height: 52px;
    padding: 0 17px 0 47px;
    border: 1px solid var(--auth-border);
    border-radius: 12px;
    outline: none;
    background: var(--auth-input);
    color: var(--auth-text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    box-sizing: border-box;
    transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

#authModal .form-input::placeholder { color: #a1acbb; font-weight: 400; }
#authModal .form-input:hover { border-color: #cbd5e1; }
#authModal .form-input:focus {
    border-color: var(--auth-primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

#authModal .input-with-icon:focus-within .input-icon {
    color: var(--auth-primary);
}

#authModal .password-wrapper { position: relative; width: 100%; }
#authModal .password-wrapper .form-input { padding-right: 48px; }
#authModal .password-toggle-icon {
    position: absolute;
    right: 17px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 15px;
    cursor: pointer;
    z-index: 4;
    transition: color 0.2s ease;
}
#authModal .password-toggle-icon:hover { color: var(--auth-primary); }

/* =========================================================
   MAIN BUTTON (PULSE ANIMATION ADDED)
   ========================================================= */

#authModal .modal-submit-btn {
    width: 100%;
    min-height: 52px;
    margin-top: 8px;
    padding: 0 18px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    background-size: 200% auto; /* For hover animation */
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 7px 18px rgba(37, 99, 235, 0.22);
    transition: all 0.3s ease;
}

#authModal .modal-submit-btn:hover {
    transform: translateY(-2px);
    background-position: right center;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.35);
}

#authModal .modal-submit-btn:active {
    transform: translateY(1px);
}

/* =========================================================
   GOOGLE MULTI-COLOR "G" BUTTON
   ========================================================= */

#authModal .google-auth-btn {
    width: 100%;
    min-height: 50px;
    margin-top: 16px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid #dbe1ea;
    border-radius: 12px;
    background: #fff;
    color: #334155;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

#authModal .google-auth-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    transform: translateY(-2px);
}

/* =========================================================
   MISC (Dividers, FireBase Box, Responsive)
   ========================================================= */

#authModal .auth-divider {
    display: flex; align-items: center; gap: 12px; margin: 18px 0;
    color: #94a3b8; font-size: 11px; font-weight: 700; text-transform: uppercase;
}
#authModal .auth-divider::before, #authModal .auth-divider::after {
    content: ""; flex: 1; height: 1px; background: #e5e7eb;
}

#authModal .firebase-verification-box {
    width: 100%; margin: 18px 0; padding: 20px;
    border: 1px solid #bfdbfe; border-radius: 16px;
    background: linear-gradient(145deg, #eff6ff, #f8fbff);
    text-align: center; box-sizing: border-box;
    animation: firebaseBoxIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes firebaseBoxIn {
    from { opacity: 0; transform: translateY(15px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

#authModal .firebase-verification-box > i {
    width: 46px; height: 46px; margin: 0 auto 10px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; background: #dbeafe; color: var(--auth-primary); font-size: 20px;
}
#authModal .firebase-verification-box h4 { margin: 0 0 7px; color: #1e3a8a; font-size: 16px; font-weight: 800; }
#authModal .firebase-verification-box p { margin: 0 auto 15px; max-width: 330px; color: #64748b; font-size: 13px; line-height: 1.55; }
#authModal .firebase-verification-box strong { color: #1d4ed8; font-weight: 700; }

#authModal .firebase-secondary-btn {
    width: 100%; min-height: 45px; margin-top: 8px; padding: 0 15px;
    border: 1px solid #bfdbfe; border-radius: 10px; background: #fff;
    color: #1d4ed8; font-family: inherit; font-size: 13px; font-weight: 700;
    cursor: pointer; transition: all 0.2s ease;
}
#authModal .firebase-secondary-btn:hover { background: #eff6ff; border-color: #93c5fd; transform: translateY(-1px); }

#authModal .forgot-link {
    display: block; margin: 5px 0 15px; color: #64748b; font-size: 13px;
    font-weight: 600; text-align: right; text-decoration: none; transition: color 0.2s ease;
}
#authModal .forgot-link:hover { color: var(--auth-primary); }

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 768px) {
    #authModal.modal-overlay { align-items: center; padding: 12px; height: 100dvh; }
    #authModal .modal-box.split-modal {
        width: 100%; max-width: 500px; max-height: calc(100dvh - 24px);
        flex-direction: column; border-radius: 20px;
    }
    #authModal .modal-side-panel {
        width: 100%; min-width: 0; min-height: 125px; flex: 0 0 auto;
        padding: 25px 45px 22px;
    }
    #authModal .side-content { max-width: 360px; }
    #authModal .side-content h2 { font-size: 22px; margin-bottom: 5px; }
    #authModal .side-content p { font-size: 14px; margin-bottom: 14px; }
    #authModal .ghost-btn { width: auto; min-height: 42px; padding: 0 32px; font-size: 14px; }
    #authModal .modal-form-panel { padding: 28px 20px 30px; flex: 1 1 auto; -webkit-overflow-scrolling: touch; }
    #authModal .modal-header h3 { font-size: 23px; }
    #authModal .modal-header p { font-size: 13px; }
    #authModal .form-group { margin-bottom: 13px; }
    #authModal .form-input { height: 50px; font-size: 14px; }
    #authModal .modal-submit-btn { min-height: 50px; }
    #authModal .google-auth-btn { min-height: 49px; }
    #authModal .modal-close { top: 10px; right: 10px; width: 34px; height: 34px; font-size: 14px; }
}

@media (max-width: 420px) {
    #authModal.modal-overlay { padding: 8px; }
    #authModal .modal-box.split-modal { max-height: calc(100dvh - 16px); border-radius: 17px; }
    #authModal .modal-side-panel { min-height: 108px; padding: 21px 40px 17px; }
    #authModal .side-content h2 { font-size: 19px; }
    #authModal .side-content p { font-size: 14px; margin-bottom: 10px; }
    #authModal .ghost-btn { min-height: 38px; padding: 0 32px; font-size: 14px; }
    #authModal .modal-form-panel { padding: 23px 15px 25px; }
    #authModal .modal-header h3 { font-size: 21px; }
    #authModal .form-input, #authModal .modal-submit-btn { height: 48px; min-height: 48px; }
}

@media (max-height: 650px) and (min-width: 769px) {
    #authModal .modal-box.split-modal { max-height: calc(100dvh - 20px); }
    #authModal .modal-side-panel, #authModal .modal-form-panel { padding-top: 25px; padding-bottom: 25px; }
    #authModal .modal-header { margin-bottom: 15px; }
    #authModal .form-group { margin-bottom: 11px; }
}

/* ACCESSIBILITY & REDUCED MOTION */
#authModal button:focus-visible, #authModal input:focus-visible, #authModal a:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.25); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    #authModal *, #authModal *::before, #authModal *::after {
        animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important;
    }
}