/* CSS ทั้งหมดของคุณ (ไม่มีการเปลี่ยนแปลง) */
:root {
    --bg-color: #000000;
    --app-bg: #FFFFFF;
    --text-color: #1a1a1a;
    --text-light: #888;
    --primary-red: #E53935;
    --border-color: #E0E0E0;
    --disabled-bg: #f5f5f5;
    --disabled-text: #bdbdbd;
}

body {
    margin: 0;
    font-family: 'Noto Sans Thai', sans-serif;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-feature-settings: "pnum";
    font-variant-numeric: proportional-nums;
    font-weight: 300;
}

.mobile-frame {
    width: 414px;
    height: 896px;
    /* กำหนดความสูงคงที่สำหรับกรอบมือถือ */
    border: 12px solid #1c1c1c;
    border-radius: 40px;
    background-color: var(--app-bg);
    position: relative;
    overflow: hidden;
    /* **สำคัญ:** ซ่อนส่วนเกินเพื่อให้เนื้อหาไม่ล้นกรอบ */
    display: flex;
    flex-direction: column;
    /* ทำให้เป็น flex container แนวตั้ง */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.container {
    width: 100%;
    height: 100%;
    /* ทำให้ container เต็มความสูงของ mobile-frame */
    display: flex;
    flex-direction: column;
}

.main-content {
    flex-grow: 1;
    /* **สำคัญ:** ทำให้ main-content ขยายเพื่อเติมเต็มพื้นที่ที่เหลือ */
    position: relative;
    overflow-y: auto;
    /* อนุญาตให้เนื้อหาภายใน main-content เลื่อนได้ถ้าจำเป็น */
}

.step-container {
    display: none;
    /* ซ่อนทุก step-container เริ่มต้น */
    flex-direction: column;
    box-sizing: border-box;
    background-color: white;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

#step-register {
    display: flex;
    /* แสดง step-register เป็นค่าเริ่มต้น */
}


#step-register .step-content {
    display: flex !important;
    flex-direction: column;
    height: 100%;
    /* ทำให้ step-content เต็มความสูงของ parent */
    padding: 0;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1px 15px;
    background-color: var(--primary-red);
    color: white;
    flex-shrink: 0;
    /* ป้องกันไม่ให้ header หดตัว */
}

.pop-mart-logo {
    font-weight: bold;
    background-color: white;
    color: var(--primary-red);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

.sub-header {
    padding: 5px 0px;
    background-color: var(--primary-red);
    color: white;
    font-size: 14px;
    text-align: center !important;
    flex-shrink: 0;
    /* ป้องกันไม่ให้ sub-header หดตัว */
}

.back-link {
    color: white;
}

.event-list {
    padding: 15px;
    flex-grow: 1;
    /* **สำคัญ:** ทำให้ event-list ขยายและเลื่อนได้ */
    overflow-y: auto;
}

.event-card {
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.event-card img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    margin-right: 15px;
}

.event-info {
    flex-grow: 1;
}

.event-info .open-time {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 5px;
}

.event-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.register-section .register-btn-visual {
    background-color: var(--primary-red);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 16px;
    font-size: 14px;
}

.register-section .register-btn-visual:disabled {
    background-color: var(--disabled-bg);
    color: var(--disabled-text);
    cursor: not-allowed;
}

/* --- ✨ CSS ที่แก้ไข --- */
.top-menu {
    display: flex;
    justify-content: space-around;
    border-bottom: 1px solid var(--border-color); /* เปลี่ยนจาก border-top */
    padding: 10px 0;
    background-color: white;
    flex-shrink: 0;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 12px;
    color: var(--text-light);
    text-decoration: none; /* เพิ่มเข้ามาเพื่อลบขีดเส้นใต้ของลิงก์ */
}

.nav-item.active {
    color: var(--text-color);
    font-weight: 600;
}

.nav-item i {
    font-size: 24px;
    margin-bottom: 4px;
}

/* Step 2: Branch (Styled as a Modal) */
#step-branch {
    
    /* display: flex;  จะถูกเปิดใช้เมื่อถึงขั้นตอนนี้ */
    /* justify-content: flex-end; */
    /* Push content to bottom */
    background-color: rgba(0, 0, 0, 0.5);
    /* Overlay */
}

#step-branch .step-content {
    position: absolute;   /* <-- เพิ่มเข้ามา */
    bottom: 0;            /* <-- เพิ่มเข้ามา */
    left: 0;              /* <-- เพิ่มเข้ามา */
    background: white;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    max-height: 70%;
    width: 100%;
    display: flex !important;
    flex-direction: column;
    animation: slideUp 0.3s ease-in-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    box-sizing: border-box;
}

.modal-header .close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
}

.modal-header h4 {
    margin: 0;
    font-weight: 600;
}

#branch-list-container {
    padding: 0;
    overflow-y: auto;
    flex-grow: 1;
}

#branch-list-container button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 15px;
    font-size: 16px;
    border: none;
    border-bottom: 1px solid var(--border-color);
    background: none;
    cursor: pointer;
}

#branch-list-container button.selected {
    background-color: #ffeeee;
    color: var(--primary-red);
}

.btn-primary {
    width: 100%;
    padding: 15px;
    background-color: var(--primary-red);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}

.btn-primary:disabled {
    background-color: var(--disabled-bg);
    color: var(--disabled-text);
}

.page-footer {
    padding: 15px;
}

/* Step 3 & 4 */
.page-header {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.page-header .back-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #333;
}

.page-header-title {
    flex-grow: 1;
    text-align: center;
    font-weight: 600;
    font-size: 17px;
}

.page-header .icon-placeholder {
    width: 24px;
}

#step-datetime .step-content,
#step-final .step-content {
    display: flex !important;
    flex-direction: column;
    height: 100%;
}

#step-datetime .page-content,
#step-final .page-content {
    flex-grow: 1;
    overflow-y: auto;
}

#calendar-container {
    padding: 0 15px;
}

.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1rem 0;
}

.calendar-nav button {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 30px;
    height: 30px;
    cursor: pointer;
}

#weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 500;
    color: var(--text-light);
    padding-bottom: 10px;
}

#calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    gap: 5px 0;
}

#calendar-grid button {
    height: 44px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
}

.day-number {
    width: 36px;
    height: 36px;
    line-height: 36px;
    border-radius: 50%;
    display: inline-block;
}

.today .day-number {
    border: 1px solid var(--primary-red);
    color: var(--primary-red);
}

.selected .day-number {
    background-color: var(--primary-red);
    color: white;
}

.time-select-section {
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
    padding: 20px 15px 0 15px;
    text-align: center;
}

#time-slots-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

#time-slots-grid button {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: white;
    cursor: pointer;
}

#time-slots-grid button.selected {
    background-color: var(--primary-red);
    color: white;
    border-color: var(--primary-red);
}

.info-section {
    border-bottom: 1px solid var(--border-color);
    padding: 15px;
}

.info-section h4 {
    font-size: 14px;
    color: var(--text-light);
    margin: 0 0 5px 0;
    font-weight: 500;
}

.info-section p {
    font-size: 16px;
    margin: 0;
    font-weight: 600;
}

.checkbox-group {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-red);
}

.success-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 30;
}

.success-modal-dialog {
    background: white;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    width: 300px;
}

.success-modal-dialog img {
    width: 100px;
    height: auto;
    margin-bottom: 15px;
}

.success-modal-dialog h4 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 20px 0;
}
.img-thumbnail{
    width: 100%;
}
.mess h3 {
    margin: 1px 1px 1px 1px;
    color: #0429ad;
}
.mess p{
    margin: 1px 1px 1px 1px;
    color: red;
}
.btn-hid{
    margin: -15px;
    z-index: -200;
}

/* ⭐ Added: CSS สำหรับ Step Verify (แยกเฉพาะ ไม่แตะของเดิม) */
#step-verify .viewport{width:280px;height:280px;perspective:800px;margin:auto;}
#step-verify .spin{width:100%;height:100%;transform-style:preserve-3d;transition:transform .06s linear;}
#step-verify .face{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#f1f3f5;border-radius:20px;backface-visibility:hidden;}
#step-verify .front{transform:rotateY(0deg);}
#step-verify .back{transform:rotateY(180deg);}
#captcha-status{text-align:center;margin-top:15px;font-weight:600;}
#captcha-bar{height:100%;width:0%;background:#2f9e44;transition:width .12s;} 

/* ✅ กันเบราว์เซอร์แปล gesture เป็น scroll/zoom */
#step-verify .viewport{
  touch-action: none;            /* Chrome/Android/Edge */
  -ms-touch-action: none;        /* IE/old Edge */
}

.captcha-img{
  pointer-events: none;          /* ให้รับ event ที่กล่อง viewport เท่านั้น */
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

/* ลดแรงดีดและการเลื่อนหน้าจอมากิน gesture */
body, .mobile-frame, .main-content{
  overscroll-behavior: contain;
}
