/* --- Modern Login (glassmorphism + gradient) --- */

:root {
    --bg-1: #0b141a;
    --bg-2: #0e1b22;
    --card: rgba(20, 28, 34, 0.65);
    --card-solid: #202c33; /* fallback when no backdrop-filter */
    --stroke: rgba(255, 255, 255, 0.06);
    --ring: #00a884;
    --text: #e9edef;
    --muted: #8696a0;
    --danger: #ff6b6b;
    --btn-1: #00a884;
    --btn-2: #059c7f;
    color-scheme: dark;
}

/* Background with subtle gradient + accent blobs */
body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    margin: 0;
    min-height: 100vh;
    display: grid;
    place-items: center;
    color: var(--text);
    background:
      radial-gradient(1200px 800px at 80% -20%, rgba(0, 168, 132, 0.25), transparent 60%),
      radial-gradient(800px 600px at -10% 110%, rgba(3, 169, 244, 0.18), transparent 55%),
      linear-gradient(180deg, var(--bg-2), var(--bg-1));
}

/* Noise overlay for depth (very subtle) */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cdefs%3E%3CradialGradient id='g' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(0 0) scale(1 1)'%3E%3Cstop stop-color='white' stop-opacity='0.05'/%3E%3Cstop offset='1' stop-color='white' stop-opacity='0'/%3E%3C/rs:radialGradient%3E%3C/defs%3E%3C/svg%3E");
    opacity: 0.02;
}

.login-container {
    width: 420px;
    max-width: min(92vw, 480px);
    padding: 44px 36px 32px;
    border-radius: 16px;
    background: var(--card);
    border: 1px solid var(--stroke);
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    isolation: isolate;
    animation: cardIn 420ms cubic-bezier(.2,.8,.2,1);
    backdrop-filter: blur(10px) saturate(120%);
}

/* Fallback when backdrop-filter is unsupported */
@supports not ((-webkit-backdrop-filter: none) or (backdrop-filter: none)) {
    .login-container { background: var(--card-solid); }
}

/* Subtle gradient border ring */
.login-container::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(0,168,132,0.6), rgba(3,169,244,0.35));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    opacity: 0.5;
    pointer-events: none;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)     scale(1); }
}

.login-container h2 {
    margin: 0 0 28px;
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: 0.2px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Add logo chip before title if asset exists */
.login-container h2::before {
    content: "";
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: url('walogo.png') center/90% no-repeat, linear-gradient(135deg, #00a884, #03a9f4);
    box-shadow: 0 4px 10px rgba(0, 168, 132, 0.3);
}

#login-form {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

/* Inputs with leading icons via data-URI SVG */
#login-form input {
    width: 100%;
    padding: 14px 16px 14px 46px;
    border-radius: 12px;
    border: 1px solid var(--stroke);
    font-size: 1rem;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)) , rgba(12, 18, 23, 0.7);
    color: var(--text);
    transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
}

/* username icon */
#username {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='%238696a0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 14px center;
}

/* password icon */
#password {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='%238696a0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 14px center;
}

#login-form input::placeholder { color: var(--muted); }

#login-form input:hover { border-color: rgba(0, 168, 132, 0.35); }

#login-form input:focus {
    border-color: rgba(0, 168, 132, 0.6);
    box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.18);
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)) , rgba(12, 18, 23, 0.7);
}

/* Built-in invalid state feedback (uses required attr) */
#login-form input:invalid:focus {
    border-color: rgba(255, 107, 107, 0.8);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.18);
}

#login-form button {
    width: 100%;
    padding: 14px 0;
    color: #ffffff;
    border: 0;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 6px;
    letter-spacing: 0.2px;
    font-family: inherit;
    outline: none;
    background: linear-gradient(135deg, var(--btn-1), var(--btn-2));
    box-shadow: 0 12px 24px rgba(0, 168, 132, 0.25), 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

#login-form button:hover { 
    transform: translateY(-1px);
    box-shadow: 0 14px 26px rgba(0, 168, 132, 0.3), 0 4px 10px rgba(0, 0, 0, 0.32);
}

#login-form button:active { transform: translateY(0); }

#login-form button:disabled { 
    filter: grayscale(25%);
    cursor: progress;
    opacity: 0.85;
}

.error {
    color: var(--danger);
    font-size: 0.95rem;
    min-height: 20px;
    text-align: center;
    font-weight: 600;
    width: 100%;
    margin-top: 4px;
    padding: 10px 14px;
    /* Fallbacks */
    background: rgba(255, 107, 107, 0.12);
    border: 1px solid rgba(255, 107, 107, 0.22);
    /* Modern override */
    background: color-mix(in oklab, var(--danger) 12%, transparent);
    border: 1px solid color-mix(in oklab, var(--danger) 20%, transparent);
    border-radius: 10px;
    display: none;
}

.error:not(:empty) {
    display: block;
    animation: shake 180ms linear 0s 3;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .login-container { animation: none; }
    .error:not(:empty) { animation: none; }
    #login-form button { transition: none; }
    #login-form input { transition: none; }
}

/* Mobile tweaks */
@media (max-width: 520px) {
    .login-container {
        width: 94vw;
        padding: 28px 22px 22px;
        border-radius: 14px;
    }
    .login-container h2 { font-size: 1.6rem; margin-bottom: 24px; }
    #login-form { gap: 14px; }
    #login-form input { padding: 12px 14px 12px 44px; font-size: 0.98rem; }
    #login-form button { padding: 12px 0; font-size: 1rem; }
}