/*
 * Màn đăng nhập (body/public.login.ftl): thẻ ở giữa màn hình, bộ màu theo nhận diện ipas.com.vn.
 * Mọi màu đi qua biến: bản tối ghi đè trong login-v2-dark.css,
 * cấu hình theo từng ứng dụng chỉ cần đặt --accent* trên .lg.
 */
@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap");

:root {
    --ipas-teal: #01c9c3;
    --ipas-blue: #26b1fe;
    --ipas-royal: #4f7cff;
    /* 3 sắc độ của màu chủ đạo: vòng tròn, chấm sáng, quả cầu (login-globe.js đọc các biến này). */
    --tone-1: var(--ipas-teal);
    --tone-2: var(--ipas-blue);
    --tone-3: var(--ipas-royal);

    --page-bg:
        radial-gradient(55% 50% at 8% 8%, #d9e9fb, transparent 70%),
        radial-gradient(45% 40% at 92% 4%, #dff4fb, transparent 70%),
        radial-gradient(55% 50% at 100% 100%, #e3e9fb, transparent 70%),
        #edf2f9;
    --card-bg: rgba(255, 255, 255, 0.72);
    --card-border: rgba(11, 26, 51, 0.08);
    --card-shadow: 0 30px 80px -30px rgba(30, 64, 120, 0.25), 0 2px 6px rgba(30, 64, 120, 0.04);
    --showcase-bg: linear-gradient(160deg, rgba(243, 247, 253, 0.9), rgba(234, 241, 250, 0.9));
    --hero-shadow: 0 24px 48px -20px rgba(5, 11, 24, 0.4);

    --text: #0b1a33;
    --text-2: #46546b;
    --text-3: #7d8aa3;
    --field-bg: #eef2f8;
    --field-bg-focus: #ffffff;
    --field-border: #e1e7f0;
    --field-border-hover: #c3cddc;
    --hover: rgba(11, 26, 51, 0.05);
    --subtle: #eef2f8;

    --accent: var(--ipas-blue);
    --accent-fill: linear-gradient(90deg, #069e98 0%, #1c8fe3 55%, #3a6df0 100%);
    --accent-on: #ffffff;
    --accent-shadow: 0 10px 24px -10px rgba(37, 99, 235, 0.55);
    --accent-text: #0b6db8;
    --accent-soft: rgba(38, 177, 254, 0.1);
    --accent-ring: rgba(38, 177, 254, 0.28);

    --ring: rgba(38, 177, 254, 0.22);
    --ring-strong: rgba(38, 177, 254, 0.45);

    --danger: #e0383e;
    --danger-text: #b42318;
    --danger-bg: #fff1f0;
    --danger-ring: rgba(224, 56, 62, 0.2);

    --ease-out: cubic-bezier(0.22, 0.8, 0.26, 0.99);
}

html {
    height: auto;
}

/* Căn thẻ giữa màn hình bằng flex (margin của thẻ không dồn ra body sinh thanh cuộn). */
body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    background: var(--page-bg);
    background-attachment: fixed;
    color: var(--text);
    font-family: Montserrat, "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.lg,
.lg *,
.lg *::before,
.lg *::after {
    box-sizing: border-box;
}

/* ---------- Thẻ ---------- */

.lg {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    width: min(1000px, calc(100% - 48px));
    min-height: 600px;
    margin: 32px auto;
    overflow: hidden;
    border: 1px solid var(--card-border);
    border-radius: 28px;
    background: var(--card-bg);
    box-shadow: var(--card-shadow);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    backdrop-filter: blur(24px) saturate(1.4);
    animation: lg-rise 560ms var(--ease-out) both;
}

.lg-showcase {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    border-right: 1px solid var(--card-border);
    background: var(--showcase-bg);
}

/* Ảnh riêng của ứng dụng (416×692): không phóng to quá kích thước thật để giữ nét. */
.lg-hero {
    display: block;
    height: min(520px, calc(100vh - 160px));
    aspect-ratio: 416 / 692;
    width: auto;
    max-width: 100%;
    object-fit: cover;
    object-position: top center;
    border-radius: 20px;
    box-shadow: var(--hero-shadow);
}

.lg-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 56px 56px 28px;
}

.lg-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
}

/* ---------- Minh hoạ quả cầu (ứng dụng không có ảnh riêng) ---------- */

.lg-art {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.lg-globe {
    position: relative;
    width: min(380px, 100%);
    aspect-ratio: 1;
    margin: -24px 0 -8px;
}

.lg-globe-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Vòng đồng tâm quay chậm, mỗi vòng mang một chấm sáng. */
.lg-ring {
    position: absolute;
    border: 1px solid var(--ring);
    border-radius: 50%;
    animation: lg-orbit 60s linear infinite;
}

.lg-ring::after {
    content: "";
    position: absolute;
    top: -3.5px;
    left: 50%;
    width: 6px;
    height: 6px;
    margin-left: -3px;
    border-radius: 50%;
    background: var(--tone-2);
    box-shadow: 0 0 10px 1px var(--tone-2);
}

.lg-ring--outer {
    inset: 2%;
    opacity: 0.7;
}

.lg-ring--mid {
    inset: 11%;
    animation-duration: 42s;
    animation-direction: reverse;
}

.lg-ring--mid::after {
    background: var(--tone-1);
    box-shadow: 0 0 10px 1px var(--tone-1);
}

.lg-ring--inner {
    inset: 19%;
    opacity: 0.8;
    animation-duration: 30s;
}

.lg-ring--inner::after {
    background: var(--tone-3);
    box-shadow: 0 0 10px 1px var(--tone-3);
}

/* Sóng lan từ mép quả cầu ra ngoài. */
.lg-pulse {
    position: absolute;
    inset: 25%;
    border: 1.5px solid var(--ring-strong);
    border-radius: 50%;
    opacity: 0;
    animation: lg-pulse 7s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}

.lg-pulse--late {
    animation-delay: 3.5s;
}

.lg-art-title {
    margin: 0;
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.3;
    color: var(--text);
}

.lg-art-text {
    max-width: 340px;
    margin: 10px 0 0;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--text-2);
}

/* ---------- Tiêu đề ---------- */

.lg-head {
    margin-bottom: 32px;
}

.lg-logo {
    display: block;
    height: 34px;
    width: auto;
    max-width: 220px;
    margin-bottom: 28px;
    border-radius: 6px;
    object-fit: contain;
    object-position: left center;
}

.lg-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding: 4px 10px 4px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
}

.lg-chip svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.lg-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
    color: var(--text);
    text-wrap: pretty;
}

.lg-subtitle {
    margin: 8px 0 0;
    font-size: 0.875rem;
    color: var(--text-2);
}

.lg-ecosystem {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    margin-top: 16px;
    font-size: 0.8125rem;
    color: var(--text-3);
}

.lg-ecosystem img {
    display: block;
    height: 16px;
    width: auto;
}

/* ---------- Biểu mẫu ---------- */

.lg-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 0;
}

.lg-field {
    display: flex;
    flex-direction: column;
}

.lg-label {
    margin-bottom: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-2);
}

/* "Quên mật khẩu?" nằm ngay dưới ô mật khẩu, căn phải. */
.lg-forgot {
    align-self: flex-end;
    margin-top: 8px;
}

.lg-input {
    width: 100%;
    height: 46px;
    margin: 0;
    padding: 0 16px;
    border: 1px solid var(--field-border);
    border-radius: 10px;
    background: var(--field-bg);
    color: var(--text);
    font: inherit;
    font-size: 1rem; /* >= 16px để iOS không tự phóng to khi chạm */
    transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
    -webkit-appearance: none;
    appearance: none;
}

.lg-input::placeholder {
    color: var(--text-3);
    opacity: 1;
}

.lg-input:hover {
    border-color: var(--field-border-hover);
}

.lg-input:focus {
    outline: none;
    background: var(--field-bg-focus);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-ring);
}

.lg-input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 48px var(--field-bg) inset;
    -webkit-text-fill-color: var(--text);
    caret-color: var(--text);
}

.lg-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 48px var(--field-bg-focus) inset, 0 0 0 4px var(--accent-ring);
}

.lg-field.is-invalid .lg-input {
    border-color: var(--danger);
}

.lg-field.is-invalid .lg-input:focus {
    box-shadow: 0 0 0 4px var(--danger-ring);
}

.lg-field-error {
    margin: 6px 0 0;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--danger-text);
}

.lg-field-error:empty {
    display: none;
}

.lg-input-wrap {
    position: relative;
}

.lg-input-wrap .lg-input {
    padding-right: 52px;
}

.lg-reveal {
    position: absolute;
    top: 50%;
    right: 6px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    transform: translateY(-50%);
    transition: background-color 150ms ease, color 150ms ease;
}

/* Nút này giữ class fa-eye/fa-eye-slash cho login.js, bỏ glyph của font-awesome. */
.lg-reveal::before {
    content: none !important;
}

.lg-reveal:hover {
    background: var(--hover);
    color: var(--text-2);
}

.lg-reveal:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.lg-reveal svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.lg-reveal .lg-eye-off,
.lg-reveal.fa-eye-slash .lg-eye {
    display: none;
}

.lg-reveal.fa-eye-slash .lg-eye-off {
    display: block;
}

.lg-link {
    color: var(--accent-text);
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 4px;
}

.lg-link:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.lg-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.lg-alert {
    margin: 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--danger-bg);
    color: var(--danger-text);
    font-size: 0.875rem;
    line-height: 1.45;
    animation: lg-fade 200ms ease both;
}

.lg-alert:empty {
    display: none;
}

.lg-alert button {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    cursor: pointer;
}

/* ---------- Nút ---------- */

.lg-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 48px;
    margin: 4px 0 0;
    padding: 0 24px;
    border: 0;
    border-radius: 12px;
    background: var(--accent-fill);
    color: var(--accent-on);
    box-shadow: var(--accent-shadow);
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter 150ms ease, transform 100ms ease-out, opacity 150ms ease;
    -webkit-tap-highlight-color: transparent;
}

.lg-btn:hover {
    filter: brightness(1.08);
}

.lg-btn:active {
    transform: scale(0.985);
}

.lg-btn:focus-visible {
    outline: none;
    box-shadow: var(--accent-shadow), 0 0 0 4px var(--accent-ring);
}

.lg-btn-icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* login.js đổi css-1esepcw -> css-1esepcw-disable trong lúc gửi. */
.lg-btn.css-1esepcw-disable {
    pointer-events: none;
    opacity: 0.8;
}

.lg-btn.css-1esepcw-disable .lg-btn-icon {
    display: none;
}

.lg-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: var(--accent-on);
    border-radius: 50%;
    animation: lg-spin 700ms linear infinite;
}

.lg-spinner.css-1w6qo8v-disable {
    display: inline-block;
}

/* ---- Cách đăng nhập khác (Google/Facebook/Apple, passkey ở nhánh fido) — kiểu nút viền, icon bên trái. */
.lg-methods {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lg-methods[hidden],
.lg-btn[hidden] {
    display: none;
}

.lg-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-3);
}

.lg-divider::before,
.lg-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--field-border);
}

.lg .lg-btn--secondary {
    margin: 0;
    border: 1px solid var(--field-border);
    background: var(--field-bg);
    color: var(--text);
    box-shadow: none;
}

.lg .lg-btn--secondary:hover {
    filter: none;
    border-color: var(--field-border-hover);
    background: var(--field-bg-focus);
}

.lg .lg-btn--secondary:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Icon ghim mép trái, chữ luôn ở giữa nút (giống nhau giữa các nút dù icon khác nhau). */
.lg .lg-btn--method {
    padding: 0 48px;
    font-weight: 600;
    white-space: nowrap;
}

.lg-method-icon {
    position: absolute;
    top: 50%;
    left: 18px;
    width: 20px;
    height: 20px;
    transform: translateY(-50%);
}

/* Passkey: icon nét mảnh theo màu chữ, chip "FIDO2" ghim mép phải. */
.lg-passkey-icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.lg .lg-btn--passkey {
    padding: 0 72px;
}

.lg-passkey-chip {
    position: absolute;
    top: 50%;
    right: 14px;
    padding: 2px 7px;
    border: 1px solid var(--field-border-hover);
    border-radius: 999px;
    color: var(--text-2);
    font-size: 0.65625rem;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.08em;
    transform: translateY(-50%);
}

/* Màn rất hẹp (≤ 359px) không đủ chỗ cho chip; aria-label vẫn nói rõ chuẩn FIDO2. */
@media (max-width: 359px) {
    .lg .lg-btn--passkey {
        padding: 0 48px;
    }

    .lg-passkey-chip {
        display: none;
    }
}

.lg-alt {
    margin: 4px 0 0;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-2);
}

.lg-introduce {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 32px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--subtle);
}

.lg-introduce img {
    flex: none;
    width: 44px;
    height: auto;
}

.lg-introduce p {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text-2);
}

/* ---------- Chuyển động ---------- */

@keyframes lg-rise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes lg-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes lg-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes lg-orbit {
    to {
        transform: rotate(360deg);
    }
}

@keyframes lg-pulse {
    0% {
        opacity: 0;
        transform: scale(1);
    }
    12% {
        opacity: 0.9;
    }
    100% {
        opacity: 0;
        transform: scale(1.9);
    }
}

/* ---------- Màn hình nhỏ ---------- */

/* Máy tính bảng: chỉ còn cột biểu mẫu. */
@media (max-width: 1023px) {
    .lg {
        display: block;
        width: min(480px, calc(100% - 48px));
        min-height: 0;
    }

    .lg-showcase {
        display: none;
    }

    .lg-panel {
        padding: 40px 40px 20px;
    }

    .lg-card {
        max-width: none;
    }
}

/* Điện thoại: biểu mẫu tràn màn hình. */
@media (max-width: 559px) {
    .lg {
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        margin: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .lg-panel {
        min-height: 100vh;
        min-height: 100dvh;
        padding: 56px 24px 20px;
    }

    .lg-card {
        justify-content: flex-start;
    }

    .lg-title {
        font-size: 1.4375rem;
    }
}

/* ---------- Trợ năng ---------- */

@media (prefers-reduced-motion: reduce) {
    .lg,
    .lg-alert {
        animation: lg-fade 200ms ease both;
    }

    .lg-ring {
        animation: none;
    }

    .lg-pulse {
        display: none;
    }

    .lg-btn:active {
        transform: none;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .lg {
        background: var(--field-bg-focus);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

@media (prefers-contrast: more) {
    :root {
        --field-border: #6b7890;
        --text-3: #46546b;
    }
}
