@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap');

:root {
    --primary: #2563eb; /* modern blue */
    --primary-600: #1d4ed8;
    --primary-700: #1e40af;
    --surface: #ffffff;
    --surface-muted: #f3f6fb;
    --ring: rgba(37, 99, 235, 0.35);
    --text: #0f172a;
    --muted: #6b7280;
    --success-color: #22c55e;
    --error-color: #ef4444;
}

* {
    box-sizing: border-box;
}

/* Page */
body {
    background: radial-gradient(1200px 600px at 10% 10%, #e7efff 0%, transparent 60%),
                radial-gradient(1200px 600px at 90% 90%, #eef6ff 0%, transparent 60%),
                linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    font-family: 'Open Sans', sans-serif;
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    padding: 24px;
}

/* Card */
.loginWrapper {
    background: #ffffff;
    border-radius: 16px;
    width: min(420px, 92vw);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08), 0 3px 10px rgba(15, 23, 42, 0.06);
    overflow: hidden;
    animation: floatIn .5s ease both;
    transition: transform .18s ease, box-shadow .18s ease;
}
.loginWrapper:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.10), 0 6px 16px rgba(15, 23, 42, 0.08);
}

@keyframes floatIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Headings */
h1 { margin: 8px 0 6px; font-weight: 700; }
.titleContainer { justify-content: center; align-items: center; display: flex; margin-bottom: 10px; gap: 8px; }
.titleContainer img { width: 56px; height: 56px; filter: drop-shadow(-3px -2px 2px rgba(113, 95, 24, 0.64)); }

h2  { text-align: center; margin: 0 0 18px; font-weight: 700; color: #0f172a; }

/* Form */
.form { padding: 26px 28px 30px; background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%); }

.form-control { margin-bottom: 8px; padding-bottom: 14px; position: relative; }

.form-control label { color: #6b7280; display: block; margin-bottom: 6px; font-size: 0.92rem; }

.form-control input { border: 1.5px solid #e5e7eb; border-radius: 10px; display: block; width: 100%; padding: 12px 12px; font-size: 15px; background: #fff; color: #0f172a; transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; }

.form-control input:focus { outline: 0; border-color: #2563eb; box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.35); }

.form-control.success input { border-color: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.25); }

.form-control.error input { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.2); }

.form-control small { color: #ef4444; position: absolute; left: 0; bottom: -2px; font-size: 12px; visibility: hidden; }
.form-control.error small { visibility: visible; }

/* Two-column name fields */
.horizontal { display: flex; flex-direction: row; gap: 4%; }
.horizontal input { width: 48%; }

/* Toggle strip */
.form-toggle { display: flex; margin-bottom: 5px; }
.form-toggle p { color: #22c55e; padding-left: 15px; padding-bottom: 10px; }

/* Language selector */
.langSelect { position: fixed; top: 1vh; right: 1vw; display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; z-index: 10; padding: 6px 8px; background: rgba(255,255,255,0.6); backdrop-filter: blur(6px); border-radius: 999px; box-shadow: 0 2px 10px rgba(15,23,42,0.08); }
.langSelect img { width: 22px; height: 22px; opacity: .9; }
.langSelect select { width: 110px; height: 30px; border: 1px solid transparent; background-color: transparent; color: rgba(14,14,14,0.9); font-size: 14px; cursor: pointer; padding: 0 6px; border-radius: 999px; transition: border-color .15s ease; }
.langSelect select:focus { outline: none; border-color: #2563eb; }

/* Buttons (exclude the inline eye toggle) */
.form button:not(.togglePassword) {
    cursor: pointer;
    background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
    border: 1px solid #1e40af;
    border-radius: 10px;
    color: #fff;
    display: block;
    font-size: 16px;
    font-weight: 700;
    padding: 12px 14px;
    margin-top: 18px;
    width: 100%;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.25);
    transition: transform .08s ease, box-shadow .15s ease, filter .2s ease;
}
.form button:not(.togglePassword):hover {
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.35);
    filter: brightness(1.02);
}
.form button:not(.togglePassword):active { transform: translateY(1px); }
.form button:not(.togglePassword):disabled {
    opacity: 0.55;
    background: linear-gradient(180deg, #94b5ff 0%, #87a7f5 100%);
    border: 1px solid #87a7f5;
    color: #fff;
    box-shadow: none;
    cursor: not-allowed;
}
/* Secondary actions */
.form #regLogbtn, #logRegbtn { display: block; cursor: pointer; color: #2563eb; border: 1px solid rgba(37,99,235,0.5); background: rgba(37,99,235,0.06); border-radius: 10px; margin-top: 14px; padding: 10px; width: 100%; text-align: center; transition: background .15s ease, border-color .15s ease, color .15s ease; }
.form #regLogbtn:hover, #logRegbtn:hover { background: rgba(37,99,235,0.12); border-color: #2563eb; }

.form #forgotbtn { display: inline-block; margin-top: 8px; color: #1d4ed8; cursor: pointer; text-align: center; width: 100%; opacity: .9; transition: opacity .15s ease, text-decoration-color .15s ease; }
.form #forgotbtn:hover { text-decoration: underline; opacity: 1; }

/* Demo button outside the card */
#demo_btn { margin-top: 14px; background: transparent; color: #1d4ed8; border: 1px dashed #1d4ed8; border-radius: 10px; padding: 10px 14px; cursor: pointer; transition: background .15s ease, color .15s ease, border-color .15s ease; }
#demo_btn:hover { background: rgba(37,99,235,0.08); color: #1e40af; border-color: #1e40af; }

/* Test notification */
#testNotification { background: rgba(34,197,94,.12); color: #166534; border: 1px solid rgba(34,197,94,.3); padding: 8px 12px; margin: 14px 0 10px; border-radius: 999px; font-size: 0.9rem; display: inline-block; }

/* Containers visibility (kept for JS toggling compatibility) */
.loginContainer { display: block; }
.registerContainer { display: none; }

/* Toggle switch (kept) */
.switch { position: relative; display: inline-block; width: 60px; height: 34px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: green; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: #2196F3; }
input:focus + .slider { box-shadow: 0 0 1px #2196F3; }
input:checked + .slider:before { transform: translateX(26px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* Username availability badge */
.username-status {
    position: absolute;
    right: 12px;
    top: 38px;
    font-size: 0.8rem;
    font-weight: 600;
    pointer-events: none;
    transition: opacity .2s ease;
}
.username-status.available { color: var(--success-color); }
.username-status.unavailable { color: var(--error-color); }
.username-status.checking { color: var(--muted); }

/* "account exists, login" link inside email form-control */
.email-exists-link {
    position: absolute;
    right: 0;
    bottom: -2px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
    transition: color .15s ease;
}
.email-exists-link:hover { color: var(--primary-700); }

/* Misc */
.autoDetect { display: none; }

.password-field {
    position: relative;
}
.password-field input[type="password"],
.password-field input[type="text"] {
    padding-right: 2.25rem; /* space for the button */
}
.password-field .togglePassword {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: none;
    cursor: pointer;
    font-size: 1rem; /* adjust if using an SVG/icon font */
    line-height: 1;
    padding: 0.25rem;
}
.password-field .togglePassword:focus {
    outline: 2px solid #66afe9; /* visible focus */
    outline-offset: 2px;
}

/* Responsive tweaks */
@media (max-width: 380px) {
    .form { padding: 22px; }
    .horizontal { gap: 3%; }
    .horizontal input { width: 48.5%; }
}



/* Fallback: re-declare CSS variables on valid :root to override mistaken ::root */
:root {
    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --primary-700: #1e40af;
    --surface: #ffffff;
    --surface-muted: #f3f6fb;
    --ring: rgba(37, 99, 235, 0.35);
    --text: #0f172a;
    --muted: #6b7280;
    --success-color: #22c55e;
    --error-color: #ef4444;
}

/* Auto-login modal and shared button styles */
/* Shared buttons (mirrors .form button look for reuse outside forms) */
.btn {
    cursor: pointer;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    padding: 12px 14px;
    border: 1px solid transparent;
    transition: transform .08s ease, box-shadow .15s ease, filter .2s ease, background .15s ease, color .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
    border-color: #1e40af;
    color: #fff;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover { box-shadow: 0 10px 20px rgba(37, 99, 235, 0.35); filter: brightness(1.02); }
.btn-primary:disabled { opacity: 0.55; background: linear-gradient(180deg, #94b5ff 0%, #87a7f5 100%); border-color: #87a7f5; color: #fff; box-shadow: none; cursor: not-allowed; }

.btn-secondary {
    background: #eef2f7;
    border-color: #d1d5db;
    color: #374151;
}
.btn-secondary:hover { background: #e5e9f0; border-color: #cbd5e1; }

/* Modal styles */
.autoLoginOverlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.5); z-index: 1000; padding: 10px; }
.autoLoginBox { background: #fff; padding: 20px; max-width: 380px; width: 100%; margin: 20px; border-radius: 12px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.2); outline: none; animation: floatIn .25s ease both; }
.autoLoginBox h3 { margin: 0 0 8px; }
.autoLoginBox p { margin: 0; color: #334155; }
.autoLoginActions { display: flex; gap: 10px; margin-top: 16px; justify-content: center; flex-wrap: wrap; }
