/* =====================================================
   Login Page — INFINITY X
   ลอกโครงมาจาก C:\infinityx\login.html (.stage / .launcher / .login-pane)
   ไฟล์นี้ใช้กับ login.php หน้าเดียว ไม่ได้ใช้ร่วมกับ register.php / forgot_password.php
   (2 หน้านั้นยังใช้ css/login.css + css/login-theme.css ธีมเดิมอยู่)
   ===================================================== */

:root {
    --ix-blue:       #1D4ED8;
    --ix-blue-deep:  #1E3A8A;
    --ix-blue-soft:  #3B82F6;
    --ix-ink:        #0F1E3D;
    --ix-ink-2:      #44557A;
    --ix-navy:       #0A1430;
    --ix-white:      #FFFFFF;
    --ix-sky:        #EAF2FC;
    --ix-line:       #DCE6F5;
    --ix-tint:       #EFF5FF;
    --ix-shadow-card: 0 10px 30px -12px rgba(15, 30, 61, .14);
    color-scheme: light;
}

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

body {
    font-family: 'Prompt', 'Segoe UI', sans-serif;
    color: var(--ix-ink);
    background: #DEEBFB;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

img { max-width: 100%; }

a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--ix-blue);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ==================== ฉากวิดีโอเต็มจอ ==================== */
.stage {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* กันไว้ล่วงหน้า: flex item มี min-width:auto ซึ่งบางกรณีทำให้ถูกดันตาม min-content ของลูก
       (ตรวจแล้วที่ 500px การ์ดพอดีอยู่แล้วโดยไม่มีบรรทัดนี้ — ใส่ไว้เป็นเกราะเฉย ๆ) */
    width: 100%;
    min-width: 0;
}

.hero-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 30%;
    z-index: 0;
}

/* ==================== Launcher ==================== */
.launch-zone {
    position: relative;
    z-index: 3;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 40px 28px;
    width: 100%;
    min-width: 0;
}

.launcher {
    width: min(520px, 100%);
    max-width: 100%;
    background: rgba(255, 255, 255, .97);
    border: 1px solid var(--ix-line);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 30px 80px -30px rgba(10, 20, 48, .45);
}

.login-pane {
    padding: 38px 42px;
}

.login-pane h1 {
    font-family: 'Cinzel', 'Prompt', serif;
    font-weight: 700;
    font-size: 1.7rem;
    letter-spacing: .03em;
    color: var(--ix-ink);
    line-height: 1.3;
}

.login-pane h1 span {
    color: var(--ix-blue);
}

.login-pane .sub {
    margin-top: 6px;
    font-size: .9rem;
    color: var(--ix-ink-2);
}

/* ==================== ช่องกรอก ==================== */
.field {
    margin-top: 20px;
}

.field label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--ix-ink);
    margin-bottom: 7px;
}

.in-wrap {
    position: relative;
}

/* ไอคอนซ้ายในช่องกรอก */
.in-wrap > .in-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    display: block;
    color: #93A5C7;
}

.field input[type="text"],
.field input[type="password"] {
    width: 100%;
    padding: 13px 46px 13px 42px;
    border: 1.5px solid var(--ix-line);
    border-radius: 9px;
    background: #F8FBFF;
    font-family: 'Prompt', sans-serif;
    font-size: .92rem;
    color: var(--ix-ink);
    transition: border-color .15s ease-out, background .15s ease-out;
}

.field input::placeholder {
    color: #93A5C7;
}

.field input:focus {
    border-color: var(--ix-blue);
    background: #fff;
    outline: none;
}

/* ปุ่มแสดง/ซ่อนรหัสผ่าน */
.toggle-pass {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    background: none;
    border: 0;
    cursor: pointer;
    border-radius: 7px;
    color: var(--ix-ink-2);
}

.toggle-pass:hover {
    background: var(--ix-tint);
    color: var(--ix-blue);
}

.toggle-pass svg {
    display: block;
}

/* Edge/IE ใส่ปุ่มรูปตาของตัวเองมาในช่อง password (::-ms-reveal)
   ซ้อนกับปุ่มตาของเราจนเห็นเป็นตา 2 ดวง — ซ่อนของเบราว์เซอร์ทิ้ง
   ::-ms-clear คือกากบาทล้างค่าที่ Edge ใส่มาให้ช่อง text เหมือนกัน */
input::-ms-reveal,
input::-ms-clear {
    display: none;
    width: 0;
    height: 0;
}

/* Chrome/Safari บางเวอร์ชันใส่ปุ่มกุญแจ/รหัสผ่านอัตโนมัติมาในช่องเดียวกัน */
input::-webkit-credentials-auto-fill-button,
input::-webkit-strong-password-auto-fill-button {
    visibility: hidden;
    pointer-events: none;
    position: absolute;
    right: 0;
}

/* ==================== จดจำฉัน / ลืมรหัสผ่าน ==================== */
.row-opts {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    font-size: .84rem;
}

.remember {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ix-ink-2);
    cursor: pointer;
}

.remember input {
    width: 16px;
    height: 16px;
    accent-color: var(--ix-blue);
    cursor: pointer;
}

.row-opts a {
    color: var(--ix-blue);
    font-weight: 600;
    text-decoration: none;
}

.row-opts a:hover {
    text-decoration: underline;
}

/* ==================== ปุ่มเข้าสู่ระบบ ==================== */
.btn-enter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-top: 22px;
    padding: 14px 20px;
    border: 0;
    border-radius: 9px;
    background: linear-gradient(180deg, var(--ix-blue-soft), var(--ix-blue));
    color: #fff;
    font-family: 'Prompt', sans-serif;
    font-size: .98rem;
    font-weight: 700;
    letter-spacing: .04em;
    cursor: pointer;
    box-shadow: 0 10px 26px -8px rgba(29, 78, 216, .6);
    transition: transform .18s ease-out, box-shadow .18s ease-out, filter .18s ease-out;
}

.btn-enter:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.08);
    box-shadow: 0 14px 32px -8px rgba(29, 78, 216, .7);
}

.btn-enter:disabled {
    cursor: not-allowed;
    opacity: .85;
}

.btn-enter svg {
    display: block;
}

/* สถานะกำลังส่ง — js/login.js เติมคลาส loading ให้ #loginBtn */
.btn-enter.loading {
    position: relative;
    color: transparent;
}

.btn-enter.loading svg {
    visibility: hidden;
}

.btn-enter.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ix-spin .8s linear infinite;
}

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

/* ==================== ท้ายการ์ด ==================== */
.signup-row {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--ix-line);
    font-size: .88rem;
    color: var(--ix-ink-2);
    text-align: center;
}

.signup-row a {
    color: var(--ix-blue);
    font-weight: 700;
    text-decoration: none;
}

.signup-row a:hover {
    text-decoration: underline;
}

/* ลิงก์เงื่อนไข/ติดต่อ — ของเดิมในระบบเรา ต้นฉบับ infinityx ไม่มี */
.pane-footer {
    margin-top: 14px;
    text-align: center;
    font-size: .78rem;
    line-height: 1.9;
    color: var(--ix-ink-2);
}

.pane-footer a {
    color: var(--ix-blue);
    text-decoration: none;
}

.pane-footer a:hover {
    text-decoration: underline;
}

.pane-footer .sep {
    color: #A9B7D0;
    margin: 0 6px;
}

/* ==================== ปุ่มกลับหน้าหลัก ==================== */
.back-home {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 22px;
    background: rgba(255, 255, 255, .85);
    border: 1px solid var(--ix-line);
    border-radius: 999px;
    color: var(--ix-ink);
    text-decoration: none;
    font-size: .84rem;
    font-weight: 600;
    transition: background .15s ease-out, transform .15s ease-out;
}

.back-home:hover {
    background: #fff;
    transform: translateY(-1px);
}

.back-home svg {
    display: block;
}

/* ==================== Popup แจ้งผล ====================
   คลาสและ id เดิมจาก js/login.js — ห้ามเปลี่ยนชื่อ
   (errorPopup / errorPopupMessage / successPopup / successPopupMessage + คลาส show) */
.error-popup,
.success-popup {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(10, 20, 48, .55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease-out;
}

.error-popup.show,
.success-popup.show {
    opacity: 1;
    pointer-events: auto;
}

.error-popup-content,
.success-popup-content {
    width: min(380px, 100%);
    padding: 30px 28px 26px;
    background: var(--ix-white);
    border: 1px solid var(--ix-line);
    border-radius: 16px;
    box-shadow: 0 30px 80px -30px rgba(10, 20, 48, .6);
    text-align: center;
    transform: translateY(14px) scale(.97);
    transition: transform .2s ease-out;
}

.error-popup.show .error-popup-content,
.success-popup.show .success-popup-content {
    transform: translateY(0) scale(1);
}

.error-popup-icon,
.success-popup-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    border-radius: 50%;
}

.error-popup-icon {
    background: var(--t-red, #FDECEC);
    color: var(--i-red, #B91C1C);
}

.success-popup-icon {
    background: var(--t-green, #E9F8EE);
    color: var(--i-green, #15803D);
}

.error-popup-icon svg,
.success-popup-icon svg {
    width: 30px;
    height: 30px;
    display: block;
}

.error-popup-message,
.success-popup-message {
    font-size: .95rem;
    font-weight: 500;
    line-height: 1.8;
    color: var(--ix-ink);
}

.error-popup-btn {
    margin-top: 20px;
    padding: 10px 30px;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(180deg, var(--ix-blue-soft), var(--ix-blue));
    color: #fff;
    font-family: 'Prompt', sans-serif;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 18px -6px rgba(29, 78, 216, .5);
    transition: filter .18s ease-out;
}

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

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--ix-sky);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--ix-blue-soft), var(--ix-blue));
    border-radius: 99px;
    border: 2px solid var(--ix-sky);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--ix-blue), var(--ix-blue-deep));
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--ix-blue-soft) var(--ix-sky);
}

/* ==================== Responsive ==================== */
@media (max-width: 900px) {
    .login-pane { padding: 30px 26px; }
}

@media (max-width: 520px) {
    .launch-zone { padding: 20px 16px; }
    .login-pane h1 { font-size: 1.45rem; }
}

/* =====================================================
   แถบแจ้ง "ปิดเข้าสู่ระบบชั่วคราว"
   ฟอร์มยังอยู่เพราะแอดมินต้องเข้าไปเปิดสวิตช์คืนได้
   เปิด/ปิดจากหลังบ้านแอดมิน (login_enabled) — ดู php/access_control.php
   ===================================================== */
.gate-bar {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 14px 0 4px;
    padding: 11px 13px;
    border: 1px solid var(--ix-line);
    border-left: 3px solid var(--ix-blue);
    border-radius: 10px;
    background: var(--ix-tint);
    text-align: left;
}

.gate-bar svg { flex: none; margin-top: 2px; color: var(--ix-blue); }

.gate-bar p {
    margin: 0;
    font-size: .82rem;
    line-height: 1.65;
    color: var(--ix-ink-2);
}
