:root {
    --bg-page: #1a1a1a;
    --card-bg: #2d2d2d;
    --text-primary: #f2f3f5;
    --text-muted: #a0a0a0;
    --text-link: #d0d0d0;
    --input-bg: #1e1e1e;
    --blurple: #4a4a4a;
    --blurple-hover: #3a3a3a;
    --danger: #8a8a8a;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    /* Background with black and low-saturation halos */
    background-color: #050505;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(45, 50, 65, 0.3) 0%, transparent 35%),
        radial-gradient(circle at 80% 80%, rgba(65, 45, 55, 0.3) 0%, transparent 40%),
        radial-gradient(circle at 60% 30%, rgba(45, 65, 55, 0.25) 0%, transparent 30%);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: var(--text-primary);
}

.login-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    perspective: 1000px;
}

.login-container {
    background-color: var(--card-bg);
    border-radius: 0;
    /* Sharp edges for tech/sci-fi style */
    border: 1px solid rgba(255, 255, 255, 0.05);
    /* Subtle border */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    width: 0px;
    /* Start small for entry animation */
    max-width: 800px;
    padding: 32px;
    position: relative;
    overflow: hidden;

    /* Transitions for Width and entry */
    transition: max-width 0.6s cubic-bezier(0.16, 1, 0.3, 1), width 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease;
    opacity: 0;
}

/* Base entry state */
.login-container.visible {
    width: 100%;
    opacity: 1;
}

/* Sci-fi corner decoration */
.login-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    border-right: 2px solid rgba(255, 255, 255, 0.3);
}

/* Form wrapper handling fade in */
.form-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 380px;
    /* Force minimum width to prevent form squeeze during animation */
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease 0.4s;
}

.form-wrapper.visible {
    opacity: 1;
    transform: translateY(0);
}

.login-form {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;

    /* Toggle states for unified container */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.login-form.active {
    opacity: 1;
}

.hidden-form {
    display: none;
    opacity: 0;
}

.login-form h2 {
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 8px;
}

.login-form p {
    font-size: 16px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.input-group label .required {
    color: var(--danger);
}

.input-group input {
    width: 100%;
    padding: 10px;
    border-radius: 3px;
    border: none;
    background-color: var(--input-bg);
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: background-color 0.2s ease;
}

.input-group input:focus {
    background-color: #2b2d31;
}

.forgot-password {
    margin-bottom: 20px;
    margin-top: -12px;
}

.forgot-password a {
    color: var(--text-link);
    text-decoration: none;
    font-size: 14px;
}

.forgot-password a:hover {
    text-decoration: underline;
}

.login-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--blurple);
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-bottom: 10px;
}

.login-btn:hover {
    background-color: var(--blurple-hover);
}

.register-link {
    font-size: 14px;
    color: var(--text-muted);
}

.register-link a {
    color: var(--text-link);
    text-decoration: none;
}

.register-link a:hover {
    text-decoration: underline;
}

/* Diagonal Line Inside Card */
.card-separator-line {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40%;
    /* Short thick line matching the reference */
    height: 6px;
    background-color: var(--text-primary);
    transform: translate(-50%, -50%) rotate(45deg);
    pointer-events: none;
    z-index: 10;
}

/* Make sure diagonal line is hidden when card displays an avatar */
.empty-card.has-avatar .card-separator-line {
    display: none;
}

.empty-card.has-avatar {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* User identity helper over the card */
.empty-card .username-label {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 11px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-card:hover .username-label {
    opacity: 1;
}

/* Right Panel Container */
.right-panel {
    width: 280px;
    min-width: 280px;
    position: relative;
    margin-left: 32px;
    padding-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;

    /* Entry animation states */
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.5s;
    /* Delay behind form */
}

.right-panel.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Right Panel Elements (Cards & Avatar) */
.side-cards,
.avatar-upload {
    width: 100%;
    position: absolute;
    /* Share the exact same grid space smoothly */
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    /* Disable interaction when hidden */
}

/* Active State for Right Panel Elements */
.side-cards.active,
.avatar-upload.active {
    opacity: 1;
    transform: translateY(-50%);
    pointer-events: auto;
}

/* Override Side Cards Grid */
.side-cards {
    display: grid;
    grid-template-columns: 130px 130px;
    gap: 16px;
    align-content: center;
    transform: translateY(-50%) translateX(20px);
    /* Start slightly shifted for transition */
}

/* Base Hidden Element Utility */
.hidden-element {
    display: none;
}

/* Tech dot pattern decoration mimicking the reference image */
.right-panel::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    width: 80px;
    height: 20px;
    background-image: radial-gradient(rgba(255, 255, 255, 0.5) 2px, transparent 2px);
    background-size: 12px 12px;
    background-position: 0 0;
}

.empty-card {
    position: relative;
    overflow: hidden;
    /* Keep the diagonal line inside */
    aspect-ratio: 1;
    /* Win 11 Glass + Arknights Tech style */
    background: rgba(255, 255, 255, 0.1);
    /* Flat semi-transparent like the reference */
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0;
    /* Sharp corners! */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);

    /* Active Glassmorphism blur */
    backdrop-filter: blur(12px) saturate(120%);
    -webkit-backdrop-filter: blur(12px) saturate(120%);
    transition: all 0.2s ease;

    /* Animation state bindings */
    opacity: 0;
    transform: scale(0.9);
    animation: card-appear 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    animation-delay: calc(0.6s + var(--anim-delay));
}

@keyframes card-appear {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.empty-card:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.03);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.empty-card.has-avatar:hover {
    /* Use brightness filter to highlight avatar instead of overlay color */
    filter: brightness(1.15);
}

/* Avatar Upload Styling */
.avatar-upload {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transform: translateY(-50%) translateX(-20px);
    /* Transition origin */
}

.avatar-preview-box {
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 0;
    /* Tech sharp edges */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(12px) saturate(120%);
    -webkit-backdrop-filter: blur(12px) saturate(120%);
    transition: all 0.2s ease;
}

.avatar-preview-box:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.02);
}

.avatar-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
}

.avatar-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Right QR Section */
.qr-login {
    width: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-left: 32px;
    padding-left: 32px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.qr-placeholder {
    width: 176px;
    height: 176px;
    background-color: white;
    border-radius: 8px;
    margin-bottom: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
}

/* CSS fake QR code pattern */
.qr-mock {
    width: 160px;
    height: 160px;
    background-color: #000;
    /* Creating a checker-like pattern to mimic a QR code */
    background-image:
        radial-gradient(#fff 20%, transparent 20%),
        radial-gradient(#fff 20%, transparent 20%);
    background-color: #fff;
    background-position: 0 0, 10px 10px;
    background-size: 20px 20px;
    border: 10px solid #fff;
    border-radius: 4px;
    position: relative;
}

.qr-mock::before,
.qr-mock::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    background: #000;
    border: 5px solid #fff;
}

.qr-mock::before {
    top: 0;
    left: 0;
}

.qr-mock::after {
    top: 0;
    right: 0;
}

/* A third corner block */
.qr-mock-bottom {
    position: absolute;
    width: 40px;
    height: 40px;
    background: #000;
    border: 5px solid #fff;
    bottom: 0;
    left: 0;
}

.qr-login h3 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.qr-login p {
    font-size: 16px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
}

/* Responsiveness */
@media (max-width: 840px) {
    .login-wrapper {
        padding: 15px;
        /* Less padding on small screens */
    }

    .login-container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        flex-direction: column;
        /* Force top/bottom stacking */
        padding: 20px 15px;
        overflow-y: auto;
        max-height: 95vh;
        border-radius: 8px;
        /* Slightly round on mobile for better look */
    }

    .form-wrapper {
        min-width: 0 !important;
        /* Allow shrinking below 380px */
        width: 100%;
        transform: translateY(0) !important;
    }

    .right-panel {
        width: 100%;
        min-width: 0 !important;
        margin-left: 0;
        margin-top: 30px;
        padding-top: 30px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        justify-content: center;
        align-items: center;
        transform: translateX(0) !important;
    }

    .side-cards {
        transform: translateY(0) !important;
        position: relative !important;
        /* Keep grid compact and strictly center the columns inside the 100% wrapper */
        grid-template-columns: 130px 130px !important;
        gap: 16px !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        justify-content: center !important;
        align-content: center !important;
        padding-bottom: 10px;
    }

    .empty-card {
        width: 130px;
        height: 130px;
        aspect-ratio: unset;
        /* override since fixed dims */
    }

    .avatar-upload {
        position: relative !important;
        transform: translateY(0) !important;
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }

    .avatar-preview-box {
        width: 100%;
        aspect-ratio: 1;
        /* Keep it square */
        height: auto;
    }

    .right-panel::before {
        display: none;
    }

    .qr-login,
    .separator-line {
        display: none;
        /* Hide QR on mobile entirely */
    }
}

/* Extra small screens (down to ~320px) */
@media (max-width: 400px) {
    .login-container {
        padding: 15px 12px;
    }

    .login-form h2 {
        font-size: 20px;
    }

    .side-cards {
        grid-template-columns: 110px 110px !important;
        gap: 12px !important;
    }

    .empty-card {
        width: 110px !important;
        height: 110px !important;
        border-radius: 6px;
        /* Avoid sharp edges breaking layout on tiny screens */
    }
}