/* =====================================================
   BIT — Email-first Authentication UI (css/auth.css)
   Shared premium styling for login / signup / password
   reset / verify pages. Loaded AFTER css/style.css, so it
   consumes the brand tokens defined there (:root).
   ===================================================== */

/* ---- Progressive-enhancement visibility gates -------------------------
   Pages ship <html class="no-js">; a tiny inline head script flips it to
   "js". Without JS the full legacy forms render; with JS the step UI does. */
.js-only { display: none; }
html.js .js-only { display: block; }
html.js .no-js-only { display: none; }
/* JS switches steps by toggling the [hidden] attribute — force it to win
   over any display rule above. */
[hidden] { display: none !important; }

/* ---- Page frame ------------------------------------------------------- */
.auth-wrap {
    max-width: 440px;
    margin: 3.5rem auto;
    padding: 0 1.25rem;
}
.auth-card {
    position: relative;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem 2.2rem 2.2rem;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
/* Brand accent bar across the top of the card */
.auth-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-blue-light));
}

.auth-logo {
    display: block;
    max-height: 42px;
    margin: 0.25rem auto 1.1rem;
}
.auth-title {
    font-family: "Syne", sans-serif;
    font-weight: 800;
    color: var(--deep-navy);
    font-size: 1.45rem;
    text-align: center;
    margin-bottom: 0.35rem;
}
.auth-sub {
    color: var(--text-light);
    text-align: center;
    font-size: 0.9rem;
    margin-bottom: 1.4rem;
    line-height: 1.5;
}

/* ---- Form fields ------------------------------------------------------ */
.auth-fg { margin-bottom: 1rem; }
.auth-fg label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
}
.auth-fg input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;               /* 16px avoids iOS zoom-on-focus */
    font-family: inherit;
    color: var(--text-dark);
    background: #fff;
    transition: var(--transition);
    box-sizing: border-box;
}
.auth-fg input::placeholder { color: #9aa4b2; }
.auth-fg input:focus {
    outline: none;
    border-color: var(--primary-blue-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.auth-fg input[readonly] {
    background: var(--bg-light);
    color: var(--text-light);
    cursor: default;
    border-style: dashed;
}
.auth-hint {
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 5px;
    line-height: 1.45;
}

/* Email address with a leading mail glyph */
.auth-input-icon { position: relative; }
.auth-input-icon input { padding-left: 40px; }
.auth-input-icon::before {
    content: "\2709";              /* ✉ */
    position: absolute;
    left: 13px; top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    color: var(--primary-blue);
    pointer-events: none;
}

/* Password field + show/hide toggle */
.auth-pw-wrap { position: relative; }
.auth-pw-wrap input { padding-right: 46px; }
.auth-pw-toggle {
    position: absolute;
    right: 8px; top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 6px 8px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary-blue);
    cursor: pointer;
    border-radius: 6px;
}
.auth-pw-toggle:hover { background: var(--bg-light); }

/* ---- Buttons & links -------------------------------------------------- */
.auth-btn-primary {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 10px;
    color: #fff;
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-blue-light));
    box-shadow: 0 8px 24px rgba(30, 64, 175, 0.35);
    transition: var(--transition);
}
.auth-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(30, 64, 175, 0.42); }
.auth-btn-primary:disabled,
.auth-btn-primary[aria-busy="true"] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.auth-links {
    text-align: center;
    margin-top: 1.3rem;
    font-size: 0.88rem;
    color: var(--text-light);
    line-height: 1.9;
}

/* ---- "or" divider + Google Sign-In button ----------------------------- */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin: 1.3rem 0;
    color: var(--text-light);
    font-size: 0.82rem;
}
.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.auth-btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    background: #fff;
    color: var(--text-dark);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}
.auth-btn-google svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.auth-btn-google:hover {
    background: var(--bg-light);
    border-color: var(--primary-blue-light);
    color: var(--text-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.auth-link,
.auth-links a {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 600;
    background: none;
    border: none;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    padding: 0;
}
.auth-link:hover,
.auth-links a:hover { color: var(--primary-blue-light); text-decoration: underline; }

/* Identity row shown on the password / details steps (email + Change) */
.auth-identity {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.auth-identity .auth-identity-email {
    color: var(--text-dark);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.auth-change {
    flex-shrink: 0;
    color: var(--primary-blue);
    font-weight: 700;
    font-size: 0.82rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
}
.auth-change:hover { background: #fff; }

/* Row for right-aligned "Forgot password?" above/near the button */
.auth-row-end { text-align: right; margin: -0.4rem 0 0.9rem; }

/* ---- Alerts ----------------------------------------------------------- */
.auth-alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1.1rem;
    line-height: 1.5;
}
.auth-alert.success { background: #DEF7EC; color: #03543F; }
.auth-alert.error   { background: #FDE2E1; color: #9B1C1C; }
.auth-alert.info    { background: #EFF6FF; color: #1D4ED8; }
.auth-alert a { color: inherit; font-weight: 700; }
.auth-alert.is-hidden { display: none; }

/* ---- OTP 6-box widget ------------------------------------------------- */
.otp-row {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    margin: 1.2rem 0;
}
.otp-box {
    width: 52px;
    height: 60px;
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--deep-navy);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-family: inherit;
    background: #fff;
    transition: var(--transition);
    -moz-appearance: textfield;
}
.otp-box::-webkit-outer-spin-button,
.otp-box::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.otp-box:focus {
    outline: none;
    border-color: var(--primary-blue-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.otp-box.filled { border-color: var(--primary-blue-light); }
.otp-row.error .otp-box {
    border-color: #DC2626;
    animation: auth-shake 0.35s ease;
}
@keyframes auth-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Resend timer / meta text under the OTP boxes */
.otp-meta {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.2rem;
}

/* ---- Spinner (injected into busy buttons) ----------------------------- */
.auth-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: auth-spin 0.6s linear infinite;
    vertical-align: -3px;
    margin-left: 8px;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* ---- Responsive ------------------------------------------------------- */
@media (max-width: 480px) {
    .auth-wrap { margin: 1.5rem auto; }
    .auth-card { padding: 1.5rem 1.25rem 1.6rem; }
    .otp-row { gap: 0.4rem; }
    .otp-box { width: 48px; height: 56px; font-size: 1.45rem; }
}
@media (max-width: 360px) {
    .otp-box { width: 42px; height: 50px; font-size: 1.25rem; }
}
