/**
 * account-form.css — ส่วนที่ฟอร์มของหน้ากลุ่มบัญชีผู้ใช้ใช้ร่วมกันทุกหน้า
 *
 * ช่องกรอกเบอร์ (.tel-input) เว็บเดิมเขียนซ้ำในทุกหน้า (เข้าสู่ระบบ · สมัคร · ลืมรหัสผ่าน · ยืนยันเบอร์ · ตั้งค่าบัญชี)
 * ค่าทุกตัวเท่าของเดิม ย้ายมารวมไว้ที่นี่ชุดเดียว หน้าไหนต่างค่อยเขียนทับในไฟล์ของหน้านั้น
 * + ปุ่มระหว่างรอผล (.is-busy) ที่ทุกหน้าใช้ร่วมกัน
 *
 * โหลดก่อน CSS ของหน้าเสมอ เพื่อให้ค่าเฉพาะหน้าชนะ
 */

/* ── ช่องกรอกเบอร์โทรพร้อมรหัสประเทศ ─────────────────────────────────────── */
.tel-input {
    display: flex;
    align-items: stretch;

    .country-code {
        display: flex;
        align-items: center;
        padding: 0 10px;
        background-color: #e9ecef;
        border: 1px solid #cccccc;
        border-radius: 4px 0 0 4px;

        img {
            width: 20px;
            height: auto;
            margin-right: 5px;
        }

        span {
            font-size: 14px;
            color: #333333;
        }
    }

    input {
        flex: 1;
        padding: 10px;
        border: 1px solid #cccccc;
        border-left: none;
        border-radius: 0 4px 4px 0;

        &:focus {
            border-color: none;
            box-shadow: none;
        }
    }
}

/* ── ปุ่มระหว่างรอผล (setBusy() ใน assets/js/account-ui.js) ─────────────────
   กล่องแจ้งผลย้ายไปใช้ Modal กลาง (require/site-alert.php) แล้ว
   pointer-events กันลิงก์ที่ไม่มี disabled (ปุ่มขอ OTP ใหม่) ไม่ให้กดซ้ำ */
.is-busy {
    pointer-events: none;
    opacity: 0.75;
    cursor: progress;

    .busy-spinner {
        display: inline-block;
        width: 1em;
        height: 1em;
        margin-right: 8px;
        vertical-align: -0.15em;
        border: 2px solid currentColor;
        border-right-color: transparent;
        border-radius: 50%;
        animation: busy-spin 0.7s linear infinite;
    }
}

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

/* ═══ หน้าสมาชิกแบบการ์ด (.auth-page) ════════════════════════════════════════
   ใช้ที่: /sign-in · /forgot · /sign-up · /confirmation-phone · /account-setting (ดีไซน์ใหม่ เซสชัน 41–44 — ต่างจากเว็บเดิมโดยตั้งใจ)
   การ์ดกลางจอบนพื้นเทาอ่อน · แถบขั้นตอน (require/auth-steps.php) · ช่องกรอกสูง 48px มุม 8px · การ์ดมุม 12px
   ภาษาเดียวกับ Modal กลาง (site-modal.css) · ชิ้นที่ใช้ซ้ำ: require/tel-input.php · password-input.php · otp-field.php
   ค่าเฉพาะหน้าเขียนใน CSS ของหน้านั้นใต้คลาสหน้า (เช่น .sign-in-page .social-buttons) */

.auth-page {
    --auth-accent: #ff6500;
    --auth-accent-hover: #e55b00;
    --auth-accent-soft: #fff1e6;
    --auth-accent-ring: rgba(255, 101, 0, 0.18);
    --auth-text: #111827;
    --auth-label: #374151;
    --auth-muted: #6b7280;
    --auth-faint: #9ca3af;
    --auth-border: #d1d5db;
    --auth-line: #e5e7eb;
    --auth-soft: #f3f4f6;
    --auth-error: #dc2626;
    --auth-radius: 8px;          /* ช่องกรอก · ปุ่ม · สวิตช์ — เดิม 12px เจ้าของสั่งให้มนน้อยลง */
    --auth-card-radius: 12px;    /* การ์ด — เดิม 20px (มือถือ 16px) */

    /* header ลอยทับบนสุด (สูง 60px) — เว้นบนเผื่อไว้ก่อนถึงการ์ด */
    padding: 116px 0 80px;
    background-color: #f6f7f9;

    .container {

        .auth-card {
            max-width: 460px;
            margin: 0 auto;
            padding: 36px 32px 28px;
            background-color: #ffffff;
            border: 1px solid #eef0f3;
            border-radius: var(--auth-card-radius);
            box-shadow: 0 10px 40px rgba(17, 24, 39, 0.06);

            /* ── หัวการ์ด ── */
            .auth-header {
                text-align: center;

                .auth-icon {
                    display: inline-flex;
                    align-items: center;
                    justify-content: center;
                    width: 56px;
                    height: 56px;
                    margin-bottom: 16px;
                    border-radius: 50%;
                    background-color: var(--auth-accent-soft);
                    color: var(--auth-accent);

                    svg {
                        width: 26px;
                        height: 26px;
                    }
                }

                h1 {
                    margin: 0;
                    font-size: 24px;
                    font-weight: 700;
                    line-height: 1.35;
                    color: var(--auth-text);
                }
            }

            /* ── แถบขั้นตอน: วงกลมเลข (ผ่านแล้ว = เครื่องหมายถูก) + ชื่อขั้น · เส้นเชื่อมวาดจากขั้นก่อนหน้า ── */
            .auth-steps {
                display: flex;
                margin: 24px 0 28px;
                padding: 0;
                list-style: none;

                li {
                    position: relative;
                    flex: 1 1 0;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    gap: 6px;
                    text-align: center;

                    & + li::before {
                        content: "";
                        position: absolute;
                        top: 14px;
                        right: calc(50% + 20px);
                        left: calc(-50% + 20px);
                        height: 2px;
                        border-radius: 2px;
                        background-color: var(--auth-line);
                    }

                    .step-number {
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        width: 30px;
                        height: 30px;
                        border-radius: 50%;
                        background-color: var(--auth-soft);
                        color: var(--auth-faint);
                        font-size: 14px;
                        font-weight: 600;
                        transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;

                        .step-check {
                            display: none;
                            width: 15px;
                            height: 15px;
                        }
                    }

                    .step-label {
                        font-size: 12.5px;
                        line-height: 1.3;
                        color: var(--auth-faint);
                    }

                    &.is-active {

                        .step-number {
                            background-color: var(--auth-accent);
                            color: #ffffff;
                            box-shadow: 0 0 0 5px var(--auth-accent-ring);
                        }

                        .step-label {
                            font-weight: 600;
                            color: var(--auth-text);
                        }
                    }

                    &.is-done {

                        .step-number {
                            background-color: var(--auth-accent-soft);
                            color: var(--auth-accent);

                            .step-digit {
                                display: none;
                            }

                            .step-check {
                                display: block;
                            }
                        }

                        .step-label {
                            color: var(--auth-muted);
                        }
                    }

                    /* เส้นหลังขั้นที่ผ่านแล้วเป็นสีส้ม */
                    &.is-done + li::before {
                        background-color: var(--auth-accent);
                    }
                }
            }

            /* หัวการ์ดต่อด้วยฟอร์มเลย (หน้าเข้าสู่ระบบ — ไม่มีแถบขั้นตอนคั่น) เว้นระยะเท่าแถบขั้นตอน */
            .auth-header + .auth-form {
                margin-top: 28px;
            }

            /* ── ฟอร์ม ── */
            .auth-form {
                display: flex;
                flex-direction: column;
                gap: 20px;

                /* แผงของขั้นที่สลับในหน้าเดียว (forgot) — ระยะห่างเท่าตัวฟอร์ม */
                .auth-panel {
                    display: flex;
                    flex-direction: column;
                    gap: 20px;

                    &[hidden] {
                        display: none;
                    }
                }

                .form-field {

                    label {
                        display: block;
                        margin-bottom: 8px;
                        font-size: 14px;
                        font-weight: 600;
                        color: var(--auth-label);
                    }

                    .field-head {
                        display: flex;
                        align-items: baseline;
                        justify-content: space-between;
                        gap: 12px;
                    }

                    /* ชื่อ + นามสกุล คู่กันบนจอกว้าง */
                    .field-row {
                        display: grid;
                        grid-template-columns: 1fr 1fr;
                        gap: 12px;
                    }

                    /* ช่องเบอร์: ฐานจาก .tel-input ด้านบน ปรับให้สูงและมนเท่าช่องอื่น */
                    .tel-input {
                        display: flex;
                        align-items: stretch;
                        border-radius: var(--auth-radius);
                        transition: box-shadow 0.15s;

                        .country-code {
                            display: flex;
                            align-items: center;
                            justify-content: center;
                            padding: 0 12px;
                            background-color: #f9fafb;
                            border: 1px solid var(--auth-border);
                            border-radius: var(--auth-radius) 0 0 var(--auth-radius);
                        }

                        input {
                            flex: 1 1 auto;
                            min-width: 0;
                            height: 48px;
                            padding: 0 14px;
                            border: 1px solid var(--auth-border);
                            border-left: 0;
                            border-radius: 0 var(--auth-radius) var(--auth-radius) 0;
                            background-color: #ffffff;
                            font-size: 16px;   /* 16px ขึ้นไป iPhone ไม่ซูมหน้าตอนแตะช่อง */
                            color: var(--auth-text);
                            outline: none;

                            &::placeholder {
                                color: var(--auth-faint);
                            }

                            &[readonly] {
                                background-color: #f9fafb;
                                color: var(--auth-muted);
                            }
                        }

                        &:focus-within {
                            box-shadow: 0 0 0 4px var(--auth-accent-ring);

                            .country-code,
                            input {
                                border-color: var(--auth-accent);
                            }
                        }
                    }

                    .text-input,
                    .otp-input,
                    .password-input input {
                        width: 100%;
                        height: 48px;
                        padding: 0 14px;
                        border: 1px solid var(--auth-border);
                        border-radius: var(--auth-radius);
                        background-color: #ffffff;
                        font-size: 16px;
                        color: var(--auth-text);
                        outline: none;
                        transition: border-color 0.15s, box-shadow 0.15s;

                        &::placeholder {
                            color: var(--auth-faint);
                        }

                        &:focus {
                            border-color: var(--auth-accent);
                            box-shadow: 0 0 0 4px var(--auth-accent-ring);
                        }

                        &[readonly] {
                            background-color: #f9fafb;
                            color: var(--auth-muted);
                        }
                    }

                    /* OTP ตัวใหญ่ห่างกัน อ่านง่ายตอนพิมพ์ตามรหัสใน SMS */
                    .otp-input {
                        height: 56px;
                        font-size: 24px;
                        font-weight: 600;
                        letter-spacing: 0.5em;
                        text-indent: 0.5em;
                        text-align: center;

                        &::placeholder {
                            color: var(--auth-border);
                        }
                    }

                    .password-input {
                        position: relative;

                        input {
                            padding-right: 48px;
                        }

                        .password-toggle {
                            position: absolute;
                            top: 50%;
                            right: 6px;
                            display: flex;
                            align-items: center;
                            justify-content: center;
                            width: 36px;
                            height: 36px;
                            padding: 0;
                            border: 0;
                            border-radius: 6px;
                            background-color: transparent;
                            color: var(--auth-muted);
                            transform: translateY(-50%);
                            cursor: pointer;

                            &:hover {
                                background-color: var(--auth-soft);
                                color: var(--auth-text);
                            }

                            svg {
                                width: 20px;
                                height: 20px;
                            }

                            .icon-hide {
                                display: none;
                            }

                            &.is-visible {

                                .icon-show {
                                    display: none;
                                }

                                .icon-hide {
                                    display: block;
                                }
                            }
                        }
                    }

                    /* ช่องติ๊กยอมรับ — กล่องติ๊กของเบราว์เซอร์ทาสีส้ม */
                    .check-field {
                        display: flex;
                        align-items: flex-start;
                        gap: 10px;
                        margin: 0;
                        font-size: 14.5px;
                        font-weight: 400;
                        line-height: 1.5;
                        color: var(--auth-label);
                        cursor: pointer;

                        input {
                            flex-shrink: 0;
                            width: 18px;
                            height: 18px;
                            margin: 2px 0 0;
                            accent-color: var(--auth-accent);
                            cursor: pointer;
                        }

                        a {
                            color: var(--auth-accent);
                            font-weight: 600;
                            text-decoration: none;

                            &:hover {
                                text-decoration: underline;
                            }
                        }
                    }

                    /* ลิงก์ชิดขวาของหัวช่อง (เช่น "ลืมรหัสผ่าน?" เหนือช่องรหัสผ่าน) */
                    .field-link {
                        color: var(--auth-accent);
                        font-size: 13px;
                        font-weight: 600;
                        text-decoration: none;

                        &:hover {
                            text-decoration: underline;
                        }
                    }

                    .field-error {
                        margin: 8px 0 0;
                        font-size: 13px;
                        line-height: 1.45;
                        color: var(--auth-error);

                        &:empty {
                            display: none;
                        }
                    }

                    .otp-meta {
                        display: flex;
                        flex-wrap: wrap;
                        align-items: center;
                        justify-content: space-between;
                        gap: 6px 12px;
                        margin-top: 10px;
                        font-size: 13px;
                        color: var(--auth-muted);

                        .otp-timer.is-expired {
                            color: var(--auth-error);
                        }
                    }
                }

                /* ปุ่มลิงก์ (แก้ไขเบอร์ · ขอรหัสใหม่) */
                .link-button {
                    padding: 0;
                    border: 0;
                    background: none;
                    color: var(--auth-accent);
                    font-size: 13px;
                    font-weight: 600;
                    cursor: pointer;

                    &:hover {
                        text-decoration: underline;
                    }
                }

                .auth-button {
                    width: 100%;
                    min-height: 50px;
                    padding: 12px 20px;
                    border: 0;
                    border-radius: var(--auth-radius);
                    background-color: var(--auth-accent);
                    color: #ffffff;
                    font-size: 16px;
                    font-weight: 600;
                    cursor: pointer;
                    transition: background-color 0.15s, box-shadow 0.15s;

                    &:hover {
                        background-color: var(--auth-accent-hover);
                    }

                    &:focus-visible {
                        outline: none;
                        box-shadow: 0 0 0 4px var(--auth-accent-ring);
                    }

                    &[hidden] {
                        display: none;
                    }
                }
            }

            /* ── ท้ายการ์ด ── */
            .auth-footer {
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: 20px;
                margin-top: 16px;
                font-size: 14px;
                text-align: center;

                /* กลับไปหน้าเข้าสู่ระบบ (หน้าลืมรหัสผ่าน) — ปุ่มรองขอบเทาเต็มความกว้าง ใต้ปุ่มหลัก
                   เดิมเป็นลิงก์ตัวเล็ก มองข้ามง่าย (เจ้าของสั่งให้มีระยะและเด่นขึ้น) */
                .back-link {
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    gap: 6px;
                    width: 100%;
                    min-height: 48px;
                    padding: 10px 16px;
                    border: 1px solid var(--auth-border);
                    border-radius: var(--auth-radius);
                    background-color: #ffffff;
                    color: var(--auth-label);
                    font-size: 15px;
                    font-weight: 600;
                    text-decoration: none;
                    transition: border-color 0.15s, color 0.15s, background-color 0.15s;

                    svg {
                        width: 18px;
                        height: 18px;
                    }

                    &:hover {
                        border-color: var(--auth-accent);
                        background-color: var(--auth-accent-soft);
                        color: var(--auth-accent);
                    }

                    &:focus-visible {
                        outline: none;
                        box-shadow: 0 0 0 4px var(--auth-accent-ring);
                    }
                }

                /* การ์ดที่ไม่มีปุ่มกลับ (เข้าสู่ระบบ · สมัคร · ยืนยันเบอร์) เว้นจากฟอร์มเท่าเดิม */
                > p:first-child {
                    margin-top: 12px;
                }

                p {
                    margin: 0;
                    color: var(--auth-muted);

                    a {
                        color: var(--auth-accent);
                        font-weight: 600;
                        text-decoration: none;

                        &:hover {
                            text-decoration: underline;
                        }
                    }
                }
            }
        }
    }

    @media (max-width: 576px) {
        & {
            padding: 84px 0 48px;

            .container {

                .auth-card {
                    padding: 28px 20px 24px;

                    .auth-header {

                        h1 {
                            font-size: 22px;
                        }
                    }

                    .auth-steps {
                        margin: 20px 0 24px;
                    }
                }
            }
        }
    }

    /* จอแคบมาก: ชื่อ/นามสกุลเรียงลงมา */
    @media (max-width: 360px) {
        & {

            .container .auth-card .auth-form .form-field .field-row {
                grid-template-columns: 1fr;
            }
        }
    }
}
