/* ============================================================================
   auth.css - Giao dien dung chung cho /login/index.php va /login/devices.php
   Truoc day CSS nam inline trong index.php (~290 dong) nen 2 trang khong the
   dung chung + browser khong cache duoc. Tach ra day, cache theo ASSET_VERSION.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --auth-bg: #06121f;
    --auth-bg-soft: #0b1e33;
    --auth-primary: #38bdf8;
    --auth-primary-deep: #0284c7;
    --auth-accent: #22d3ee;
    --auth-amber: #fbbf24;
    --auth-danger: #fb7185;
    --auth-success: #34d399;
    --auth-text: #f1f5f9;
    --auth-muted: rgba(226, 232, 240, .68);
    --auth-glass: rgba(255, 255, 255, .07);
    --auth-glass-strong: rgba(255, 255, 255, .12);
    --auth-border: rgba(255, 255, 255, .16);
    --auth-shadow: 0 30px 70px -30px rgba(2, 12, 27, .85);
    --auth-radius: 26px;
    --auth-ease: cubic-bezier(.4, 0, .2, 1);
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body.auth-body {
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 4vw, 48px);
    /* padding an toan cho tai the / notch tren iPhone */
    padding-bottom: calc(clamp(16px, 4vw, 48px) + env(safe-area-inset-bottom));
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--auth-text);
    background:
        radial-gradient(1200px 600px at 12% -10%, rgba(56, 189, 248, .35), transparent 60%),
        radial-gradient(900px 520px at 100% 0%, rgba(34, 211, 238, .22), transparent 62%),
        radial-gradient(900px 700px at 50% 120%, rgba(14, 116, 144, .35), transparent 60%),
        linear-gradient(155deg, var(--auth-bg) 0%, var(--auth-bg-soft) 55%, #071726 100%);
    /* KHONG dung overflow:hidden tren body: ban cu lam form bi cat va khong the
       cuon tren dien thoai ngang / khi ban phim ao bat len. */
    overflow-x: hidden;
}

/* ===== Aurora blobs ===== */
.auth-aurora {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.auth-aurora .blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: .55;
    will-change: transform;
}

.blob-1 {
    width: 420px;
    height: 420px;
    top: -140px;
    left: -100px;
    background: radial-gradient(circle at 30% 30%, #38bdf8, transparent 70%);
    animation: authFloat 18s var(--auth-ease) infinite;
}

.blob-2 {
    width: 360px;
    height: 360px;
    bottom: -120px;
    right: -80px;
    background: radial-gradient(circle at 60% 40%, #22d3ee, transparent 70%);
    animation: authFloat 22s var(--auth-ease) infinite reverse;
}

.blob-3 {
    width: 300px;
    height: 300px;
    top: 40%;
    right: 22%;
    background: radial-gradient(circle at 50% 50%, #6366f1, transparent 72%);
    opacity: .35;
    animation: authFloat 26s var(--auth-ease) infinite;
}

@keyframes authFloat {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(28px, 36px, 0) scale(1.08); }
}

/* ===== Layout ===== */
.auth-shell {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 980px;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    gap: clamp(20px, 3vw, 38px);
    align-items: center;
}

.auth-shell--wide {
    max-width: 620px;
    grid-template-columns: 1fr;
}

.auth-hero {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: .2px;
}

.auth-brand__mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--auth-primary), var(--auth-primary-deep));
    box-shadow: 0 12px 30px -12px rgba(56, 189, 248, .9);
    font-size: 1.25rem;
}

.auth-hero__title {
    font-size: clamp(1.9rem, 4vw, 2.9rem);
    line-height: 1.12;
    font-weight: 800;
    letter-spacing: -.6px;
}

.auth-hero__title span {
    background: linear-gradient(120deg, #7dd3fc, #22d3ee 45%, #a5b4fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.auth-hero__desc {
    color: var(--auth-muted);
    font-size: 1rem;
    line-height: 1.65;
    max-width: 42ch;
}

.auth-points {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

.auth-point {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .94rem;
    color: var(--auth-muted);
}

.auth-point__dot {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: var(--auth-glass-strong);
    border: 1px solid var(--auth-border);
    color: var(--auth-accent);
    font-size: .8rem;
    font-weight: 700;
}

/* ===== Card ===== */
.auth-card {
    position: relative;
    padding: clamp(24px, 4vw, 38px);
    border-radius: var(--auth-radius);
    background: linear-gradient(160deg, rgba(255, 255, 255, .13), rgba(255, 255, 255, .05));
    border: 1px solid var(--auth-border);
    box-shadow: var(--auth-shadow);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    animation: authCardIn .55s var(--auth-ease) both;
}

@keyframes authCardIn {
    from { opacity: 0; transform: translateY(18px) scale(.985); }
    to { opacity: 1; transform: none; }
}

.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .3px;
    text-transform: uppercase;
    background: rgba(56, 189, 248, .16);
    border: 1px solid rgba(56, 189, 248, .35);
    color: #bae6fd;
}

.auth-badge--warn {
    background: rgba(251, 191, 36, .15);
    border-color: rgba(251, 191, 36, .38);
    color: #fde68a;
}

.auth-title {
    margin: 14px 0 6px;
    font-size: clamp(1.35rem, 2.6vw, 1.72rem);
    font-weight: 800;
    letter-spacing: -.3px;
}

.auth-sub {
    color: var(--auth-muted);
    font-size: .95rem;
    line-height: 1.6;
    margin-bottom: 22px;
}

.auth-sub strong {
    color: #e0f2fe;
}

/* ===== Fields ===== */
.auth-field {
    position: relative;
    margin-bottom: 16px;
}

.auth-field input {
    width: 100%;
    height: 58px;
    padding: 22px 46px 8px 16px;
    font: inherit;
    font-size: 1rem;
    font-weight: 500;
    color: var(--auth-text);
    background: rgba(8, 22, 38, .55);
    border: 1px solid var(--auth-border);
    border-radius: 16px;
    outline: none;
    transition: border-color .2s var(--auth-ease), box-shadow .2s var(--auth-ease), background .2s var(--auth-ease);
}

.auth-field input:hover {
    border-color: rgba(255, 255, 255, .28);
}

.auth-field input:focus {
    border-color: var(--auth-primary);
    background: rgba(8, 22, 38, .78);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, .18);
}

.auth-field label {
    position: absolute;
    left: 17px;
    top: 18px;
    font-size: 1rem;
    color: var(--auth-muted);
    pointer-events: none;
    transition: all .18s var(--auth-ease);
}

/* :placeholder-shown thay cho :valid — :valid bat ke ca khi o trong khong
   required, khien nhan bi treo o tren luc trang vua tai. */
.auth-field input:focus + label,
.auth-field input:not(:placeholder-shown) + label {
    top: 8px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: #7dd3fc;
}

.auth-field__toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--auth-muted);
    cursor: pointer;
    transition: color .2s, background .2s;
}

.auth-field__toggle:hover,
.auth-field__toggle:focus-visible {
    color: #e0f2fe;
    background: var(--auth-glass);
}

.auth-field__toggle svg {
    width: 20px;
    height: 20px;
}

.auth-caps {
    display: none;
    margin: -8px 0 12px;
    font-size: .8rem;
    color: var(--auth-amber);
}

.auth-caps.is-on {
    display: block;
}

.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 0 22px;
    font-size: .9rem;
}

.auth-check {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--auth-muted);
    cursor: pointer;
    user-select: none;
}

.auth-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--auth-primary);
    cursor: pointer;
}

.auth-link {
    color: #7dd3fc;
    text-decoration: none;
    font-weight: 600;
    transition: color .2s;
}

.auth-link:hover {
    color: #e0f2fe;
    text-decoration: underline;
}

/* ===== Buttons ===== */
.auth-btn {
    position: relative;
    width: 100%;
    min-height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 20px;
    font: inherit;
    font-size: 1.02rem;
    font-weight: 700;
    color: #04121f;
    border: 0;
    border-radius: 16px;
    cursor: pointer;
    background: linear-gradient(120deg, #7dd3fc, #38bdf8 45%, #22d3ee);
    box-shadow: 0 18px 40px -18px rgba(56, 189, 248, .85);
    transition: transform .18s var(--auth-ease), box-shadow .2s var(--auth-ease), filter .2s;
}

.auth-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 24px 50px -20px rgba(56, 189, 248, .95);
}

.auth-btn:active:not(:disabled) {
    transform: translateY(0) scale(.99);
}

.auth-btn:disabled {
    cursor: not-allowed;
    filter: grayscale(.25) brightness(.9);
    opacity: .75;
}

.auth-btn--danger {
    color: #fff;
    background: linear-gradient(120deg, #fb7185, #f43f5e 55%, #e11d48);
    box-shadow: 0 18px 40px -18px rgba(244, 63, 94, .8);
}

.auth-btn.is-busy::after {
    content: '';
    width: 17px;
    height: 17px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-top-color: transparent;
    animation: authSpin .7s linear infinite;
}

@keyframes authSpin {
    to { transform: rotate(360deg); }
}

:where(a, button, input, label.device-item):focus-visible {
    outline: 2px solid var(--auth-accent);
    outline-offset: 3px;
}

.auth-foot {
    margin-top: 20px;
    text-align: center;
    font-size: .9rem;
    color: var(--auth-muted);
    line-height: 1.7;
}

.auth-foot a {
    color: #7dd3fc;
    text-decoration: none;
    font-weight: 700;
}

.auth-foot a:hover {
    text-decoration: underline;
}

.auth-alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: .9rem;
    line-height: 1.5;
    background: rgba(251, 113, 133, .14);
    border: 1px solid rgba(251, 113, 133, .4);
    color: #fecdd3;
}

/* ===== Toast ===== */
.auth-toasts {
    position: fixed;
    z-index: 60;
    bottom: calc(24px + env(safe-area-inset-bottom));
    right: 24px;
    left: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(340px, calc(100vw - 32px));
}

.auth-toast {
    position: relative;
    display: flex;
    gap: 12px;
    padding: 14px 40px 14px 16px;
    border-radius: 16px;
    background: rgba(9, 24, 40, .92);
    border: 1px solid var(--auth-border);
    border-left: 4px solid var(--auth-primary);
    box-shadow: 0 20px 45px -20px rgba(2, 12, 27, .9);
    backdrop-filter: blur(14px);
    animation: authToastIn .4s var(--auth-ease) both;
}

.auth-toast.is-error { border-left-color: var(--auth-danger); }
.auth-toast.is-success { border-left-color: var(--auth-success); }

.auth-toast h3 {
    font-size: .95rem;
    font-weight: 700;
    margin-bottom: 3px;
}

.auth-toast p {
    font-size: .86rem;
    color: var(--auth-muted);
    line-height: 1.5;
}

.auth-toast__close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--auth-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.auth-toast__close:hover {
    color: #fff;
    background: var(--auth-glass);
}

@keyframes authToastIn {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: none; }
}

/* ===== Device chooser ===== */
.device-current {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 18px;
    border-radius: 16px;
    background: rgba(56, 189, 248, .1);
    border: 1px solid rgba(56, 189, 248, .28);
}

.device-current__icon {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, .1);
    color: #7dd3fc;
}

.device-current__icon svg,
.device-item__icon svg {
    width: 22px;
    height: 22px;
}

.device-current__label {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 700;
    color: var(--auth-muted);
}

.device-current__value {
    font-size: .98rem;
    font-weight: 700;
}

.device-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 22px;
}

.device-radio {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.device-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(8, 22, 38, .5);
    border: 1px solid var(--auth-border);
    cursor: pointer;
    transition: border-color .2s var(--auth-ease), background .2s var(--auth-ease), transform .18s var(--auth-ease);
}

.device-item:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, .32);
}

.device-radio:checked + .device-item {
    border-color: var(--auth-danger);
    background: rgba(251, 113, 133, .12);
    box-shadow: 0 0 0 4px rgba(251, 113, 133, .14);
}

.device-radio:focus-visible + .device-item {
    outline: 2px solid var(--auth-accent);
    outline-offset: 3px;
}

.device-item__icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: rgba(255, 255, 255, .08);
    color: #bae6fd;
}

.device-item__body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.device-item__name {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: .98rem;
    font-weight: 700;
}

.device-tag {
    font-style: normal;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(52, 211, 153, .18);
    border: 1px solid rgba(52, 211, 153, .4);
    color: #a7f3d0;
}

.device-item__meta {
    font-size: .82rem;
    color: var(--auth-muted);
}

.device-item__check {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .3);
    position: relative;
    transition: border-color .2s, background .2s;
}

.device-radio:checked + .device-item .device-item__check {
    border-color: var(--auth-danger);
    background: var(--auth-danger);
}

.device-radio:checked + .device-item .device-item__check::after {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: #fff;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .auth-shell {
        grid-template-columns: 1fr;
        max-width: 480px;
    }

    .auth-hero {
        text-align: center;
        align-items: center;
    }

    .auth-hero__desc {
        max-width: 46ch;
    }

    .auth-points {
        display: none;
    }
}

@media (max-width: 520px) {
    body.auth-body {
        align-items: flex-start;
        padding-top: 28px;
    }

    .auth-card {
        border-radius: 22px;
    }

    /* Toast full-width tren dien thoai, tranh tran ra ngoai man hinh */
    .auth-toasts {
        right: 16px;
        left: 16px;
        width: auto;
    }

    .auth-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .device-item {
        padding: 12px 13px;
        gap: 11px;
    }
}

/* iOS Safari zoom vao input khi font < 16px -> giu 16px o mobile */
@media (max-width: 520px) {
    .auth-field input {
        font-size: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }

    .auth-btn:hover:not(:disabled),
    .device-item:hover {
        transform: none;
    }
}
