* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

/* =========================
   DEFAULT: LIGHT MODE ✅
   ========================= */
body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
    color: #0b1020;
    background:
        radial-gradient(1200px 800px at 10% -10%, rgba(6, 182, 212, 0.12), transparent 60%),
        radial-gradient(1200px 800px at 110% 10%, rgba(79, 70, 229, 0.12), transparent 60%),
        #f7f8fb;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-box {
    width: 100%;
    max-width: 440px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
    padding: 28px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
}

.login-box::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.18), transparent 40%, rgba(79, 70, 229, 0.18));
    opacity: 0.1;
}

h2 {
    margin: 0 0 8px;
    font-size: 1.6rem;
    letter-spacing: 0.2px;
}

.error-box {
    margin: 12px 0 16px;
    padding: 12px 14px;
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #7f1d1d;
    border-radius: 12px;
}

.brand-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    margin: 6px 0 20px;
}

.logo {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 14px;
    overflow: hidden;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
}

.greeting {
    margin: 0;
    color: #475569;
}

.greeting-box {
    margin: 8px 0 16px;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    color: #334155;
}

form {
    display: grid;
    gap: 18px;
    margin-top: 12px;
}

.user-box {
    position: relative;
}

.user-box input {
    width: 100%;
    padding: 16px 14px 14px;
    font-size: 0.98rem;
    color: #0b1020;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease, transform .08s ease;
}

.user-box input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.18);
    transform: translateY(-1px);
}

.user-box label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0 6px;
    font-size: 0.95rem;
    color: #64748b;
    pointer-events: none;
    transition: all .18s ease;
    background: transparent;
}

.user-box input:focus + label,
.user-box input:valid + label {
    top: 0;
    transform: translateY(-50%) scale(0.9);
    color: #0891b2;
    background: #ffffff;
    border-radius: 6px;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
    color: #64748b;
    font-size: 0.95rem;
}

/* Base links (light mode) */
a {
    color: #0891b2;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input[type="submit"] {
    appearance: none;
    border: none;
    cursor: pointer;
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.2px;
    transition: transform .08s ease, filter .15s ease, box-shadow .2s ease;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.22);
}

button:hover,
input[type="submit"]:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

button:active,
input[type="submit"]:active {
    transform: translateY(0);
    filter: brightness(0.98);
}

.jj-digital button {
    background: none !important;
    background-color: #1d2438 !important;
    border-radius: 50px !important;
    box-shadow: 0 1.5px 10px #fefdd4;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    width: 100%;
    border: none;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.jj-digital img {
    height: 48px;
    width: auto;
    flex-shrink: 0;
    vertical-align: middle;
    margin-right: 6px;
}

.login-box > p:last-child {
    margin-top: 10px;
    text-align: center;
    color: #64748b;
}

/* ✅ Fix: readable link in LIGHT mode (was too pale/grey) */
.login-box > p:last-child a {
    color: #1d4ed8; /* readable blue */
    font-weight: 700;
    border-bottom: 1px dashed rgba(29, 78, 216, 0.45);
    text-underline-offset: 3px;
}

.login-box > p:last-child a:hover {
    color: #0891b2;
    border-bottom-color: rgba(8, 145, 178, 0.6);
}

:focus-visible {
    outline: 2px solid rgba(6, 182, 212, 0.65);
    outline-offset: 3px;
    border-radius: 10px;
}

@media (max-width: 520px) {
    .login-box {
        padding: 22px;
        border-radius: 14px;
    }

    h2 {
        font-size: 1.45rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* =========================
   OVERRIDE: DARK MODE 🌙
   ========================= */
@media (prefers-color-scheme: dark) {
    body {
        color: #e6e8ef;
        background:
            radial-gradient(1200px 800px at 10% -10%, rgba(6, 182, 212, 0.18), transparent 60%),
            radial-gradient(1200px 800px at 110% 10%, rgba(79, 70, 229, 0.2), transparent 60%),
            radial-gradient(1200px 800px at 50% 100%, rgba(244, 114, 182, 0.2), transparent 60%),
            #0b1020;
    }

    .login-box {
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.12);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    }

    .login-box::before {
        background: linear-gradient(135deg, rgba(6, 182, 212, 0.24), transparent 40%, rgba(79, 70, 229, 0.24));
        opacity: 0.08;
    }

    .error-box {
        background: rgba(239, 68, 68, 0.2);
        border: 1px solid rgba(239, 68, 68, 0.55);
        color: #ffecec;
    }

    .logo {
        background: #111827;
        border: 1px solid rgba(255, 255, 255, 0.12);
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    }

    .greeting {
        color: #a3a9b7;
    }

    .greeting-box {
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid rgba(255, 255, 255, 0.14);
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
        color: #e6e8ef;
    }

    .user-box input {
        color: #e6e8ef;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid rgba(255, 255, 255, 0.14);
    }

    .user-box input:focus {
        border-color: #6b7cff;
        box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
    }

    .user-box label {
        color: #a3a9b7;
    }

    .user-box input:focus + label,
    .user-box input:valid + label {
        color: #06b6d4;
        background: #0b1020;
    }

    .remember-me {
        color: #a3a9b7;
    }

    a {
        color: #06b6d4;
    }

    .login-box > p:last-child {
        color: #a3a9b7;
    }

    /* Keep the stronger "footer link" look for dark mode */
    .login-box > p:last-child a {
        color: #e6e8ef;
        border-bottom: 1px dashed rgba(230, 232, 239, 0.6);
    }

    .login-box > p:last-child a:hover {
        color: #06b6d4;
        border-bottom-color: rgba(6, 182, 212, 0.6);
    }
}
