/* =====================================================================
   auth.css - login page + error pages
   ===================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
    height: 100%;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body.auth-body {
    min-height: 100%;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--login-grad-start, #4F46E5) 0%, var(--login-grad-mid, #7C3AED) 50%, var(--login-grad-end, #9333EA) 100%);
    background-size: 200% 200%;
    overflow-x: hidden;
    overflow-y: auto;
    animation: gradientShift 8s ease infinite;
    position: relative;
    -webkit-overflow-scrolling: touch;
}
@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

/* Login background image layer */
.login-bg-layer {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 0;
    pointer-events: none;
    -webkit-background-size: cover;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.auth-body::before,
.auth-body::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    pointer-events: none;
    z-index: 0;
}
.auth-body::before {
    width: 480px; height: 480px;
    top: -180px; right: -120px;
}
.auth-body::after {
    width: 360px; height: 360px;
    bottom: -160px; left: -100px;
}

.auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 16px;
    padding: 2rem 1.75rem;
    box-shadow: 0 24px 60px rgba(0,0,0,0.08);
    overflow: hidden;
    animation: cardSlideIn .5s cubic-bezier(.4,0,.2,1);
    margin: auto;
}
@keyframes cardSlideIn {
    from { opacity: 0; transform: translateY(30px) scale(.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Mobile responsive */
@media (max-width: 480px) {
    body.auth-body {
        padding: 0.75rem;
        align-items: center;
    }
    .auth-card {
        max-width: 340px;
        padding: 1.5rem 1.25rem;
        border-radius: 14px;
    }
    .auth-card h1 { font-size: 1.25rem; }
    .auth-card .subtitle { font-size: .85rem; margin-bottom: 1.25rem; }
    .form-group label { font-size: .78rem; }
    .form-group input { padding: .55rem .75rem; font-size: .9rem; }
    .btn { padding: .55rem .85rem; font-size: .88rem; }
    .auth-body::before {
        width: 260px; height: 260px;
        top: -90px; right: -70px;
    }
    .auth-body::after {
        width: 200px; height: 200px;
        bottom: -90px; left: -50px;
    }
}

.auth-logo {
    width: 50px;
    height: 50px;
    margin: 0 auto .75rem;
    background: linear-gradient(135deg, var(--login-grad-start, #4F46E5), var(--login-grad-end, #7C3AED));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.auth-logo-img {
    background: #fff !important;
    border: 1px solid #e5e7eb !important;
    width: 80px !important;
    height: 80px !important;
    padding: 8px !important;
    border-radius: 12px !important;
}
.auth-logo-img img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
}
.auth-logo svg { width: 26px; height: 26px; }

.auth-card h1 {
    font-size: 1.35rem;
    font-weight: 700;
    text-align: center;
    color: #111827;
    margin-bottom: .2rem;
}
.auth-card .subtitle {
    text-align: center;
    color: #6b7280;
    font-size: .88rem;
    margin-bottom: 1.5rem;
}

.form-group { margin-bottom: .85rem; }
.form-group label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: .35rem;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .6rem .8rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: .92rem;
    font-family: inherit;
    background: #fff;
    color: #111827;
    transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4F46E5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-group input:-webkit-autofill,
.form-group input:-webkit-autofill:hover,
.form-group input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #fff inset !important;
    -webkit-text-fill-color: #111827 !important;
    transition: background-color 5000s ease-in-out 0s;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: .55rem 1rem;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, box-shadow .15s, transform .1s ease;
    line-height: 1.2;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--login-grad-start, #4F46E5);
    color: #fff;
    box-shadow: 0 1px 3px rgba(79,70,229,.4);
}
.btn-primary:hover { background: var(--login-grad-mid, #4338CA); }
.btn-block { display: flex; width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.alert {
    padding: .6rem .8rem;
    border-radius: 8px;
    font-size: .85rem;
    margin-bottom: .85rem;
    border: 1px solid transparent;
}
.alert-error {
    background: #FEF2F2;
    color: #991B1B;
    border-color: #FECACA;
}
.alert-success {
    background: #ECFDF5;
    color: #065F46;
    border-color: #A7F3D0;
}

.auth-footer {
    margin-top: 1.25rem;
    text-align: center;
    font-size: .82rem;
    color: #9ca3af;
}
.auth-footer strong { color: #6b7280; }

/* =====================================================================
   Registration / verification / reset pages (extends the login card)
   ===================================================================== */
.auth-card-wide { max-width: 460px; }

.auth-card .lead {
    font-size: .9rem;
    color: #374151;
    line-height: 1.55;
    margin-bottom: 1rem;
}
.auth-card .lead strong { color: #111827; }

.form-group .field-hint {
    font-size: .75rem;
    color: #6b7280;
    margin-top: .3rem;
    line-height: 1.4;
}

.form-group .field-error {
    font-size: .75rem;
    color: #b91c1c;
    margin-top: .3rem;
    min-height: 0;
}
.form-group .field-error:empty { display: none; }

.form-group input.is-invalid,
.form-group input[aria-invalid="true"] {
    border-color: #f87171;
    background: #fff7f7;
}
.form-group input.is-invalid:focus,
.form-group input[aria-invalid="true"]:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, .12);
}

.form-terms {
    font-size: .72rem;
    color: #6b7280;
    line-height: 1.5;
    margin: .25rem 0 .9rem;
}

/* Password field with a Show/Hide button inside the input */
.password-wrap { position: relative; }
.password-wrap input { padding-right: .9rem; }
.password-toggle {
    position: absolute;
    top: 50%;
    right: .5rem;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: #4f46e5;
    font: 600 .72rem/1 'Inter', sans-serif;
    padding: .35rem .4rem;
    cursor: pointer;
    border-radius: 6px;
}
.password-toggle:hover { background: #eef2ff; }
.password-toggle:focus-visible { outline: 2px solid #4f46e5; outline-offset: 1px; }

/* Strength meter */
.pw-meter {
    height: 4px;
    border-radius: 999px;
    background: #e5e7eb;
    margin-top: .5rem;
    overflow: hidden;
}
.pw-meter span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: #ef4444;
    transition: width .25s ease, background .25s ease;
}
.pw-meter span[data-level="fair"] { background: #f59e0b; }
.pw-meter span[data-level="strong"] { background: #10b981; }

.pw-rules {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: .25rem .9rem;
    margin-top: .4rem;
    font-size: .72rem;
    color: #6b7280;
}
.pw-rules li::before { content: "○ "; color: #9ca3af; }
.pw-rules li.is-ok { color: #047857; }
.pw-rules li.is-ok::before { content: "✓ "; color: #10b981; }

/* Pure-CSS strength meter — no script needed. The browser's own :valid state
   (required + minlength + pattern) drives the bar and the rule checkmarks.
   :has() is supported by current Chrome/Edge/Safari/Firefox; on an older
   browser the bar simply stays neutral, so nothing is broken. */
.form-group:has(#password:valid) .pw-meter span {
    width: 100%;
    background: #10b981;
}
.form-group:has(#password:valid) .pw-rules li { color: #047857; }
.form-group:has(#password:valid) .pw-rules li::before {
    content: "✓ ";
    color: #10b981;
}

/* Six-digit OTP field */
.otp-input {
    font: 700 1.35rem/1.2 'Courier New', monospace;
    letter-spacing: .55em;
    text-align: center;
    padding-left: .55em !important;
}

/* Button loading state */
.btn .btn-spinner { display: none; }
.btn.is-loading .btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: .5rem;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btnSpin .7s linear infinite;
}
@keyframes btnSpin { to { transform: rotate(360deg); } }

/* Resend row */
.resend-form {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    margin-top: 1rem;
    font-size: .82rem;
    color: #6b7280;
}
.link-button {
    border: 0;
    background: none;
    padding: 0;
    color: #4f46e5;
    font: 600 .82rem/1.4 'Inter', sans-serif;
    cursor: pointer;
    text-decoration: underline;
}
.link-button:disabled { color: #9ca3af; cursor: not-allowed; text-decoration: none; }
.link-button:focus-visible { outline: 2px solid #4f46e5; outline-offset: 2px; }

.auth-footer a { color: #4f46e5; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* "Don't have an account?" call to action on the login card */
.auth-links {
    text-align: right;
    font-size: .78rem;
    margin: .1rem 0 .9rem;
}
.auth-links a { color: #4f46e5; text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

.auth-cta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    margin: 1rem 0 .25rem;
    padding: .7rem .8rem;
    border: 1px dashed #c7d2fe;
    background: #f5f7ff;
    border-radius: 10px;
    font-size: .82rem;
    color: #4b5563;
}
.auth-cta a { color: #4f46e5; font-weight: 700; text-decoration: none; }
.auth-cta a:hover { text-decoration: underline; }
