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

:root {
    --primary-color: #E69D45;
    --primary-dark: #C67D22;
    --bg-color: #5C3A21;
    --card-bg: #FFF3C4;
    --text-dark: #6E4423;
    --text-gray: #9E7453;
    --border-color: #DEB586;
    --border-dark: #B57F4D;
    --gradient-btn: linear-gradient(180deg, #F9D079 0%, #ECA646 100%);
    --shadow-sm: 0 4px 0px rgba(181, 127, 77, 1);
    --shadow-md: 0 6px 0px rgba(181, 127, 77, 1);
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 28px;
    --cheese-color: #FFDE7A;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Kanit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* Hide ALL legacy elements */
.pc-header, .mobile-hero, .footer-illustration, .hero-illustration {
    display: none !important;
}

body {
    background-color: #462A15;
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    background: #462A15;
}

/* ========================================
   VIEW 1: Background Image + Overlay (Aspect-Ratio)
   ======================================== */
.cheese-bg-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 9 / 16; /* ล็อคสัดส่วนให้เท่ากับรูปเป๊ะๆ */
    margin: auto 0; /* จัดให้อยู่กึ่งกลางแนวตั้งถ้าจอยาวเกินไป */
}
.cheese-bg-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Overlay Service Grid - positioned over the background image */
.overlay-service-grid {
    position: absolute;
    top: 28%; /* จุดเริ่มต้นแนวตั้ง ขยับขึ้นมา */
    left: 49%; /* จุดเริ่มต้นแนวนอน */
    width: 44%; /* ความกว้างของกลุ่มปุ่มเทียบกับความกว้างรูป */
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px; /* ระยะห่างระหว่างปุ่ม */
    z-index: 10;
}

.overlay-service-card {
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.overlay-service-card:active {
    transform: scale(0.95);
}

.overlay-card-inner {
    background: rgba(255, 243, 196, 0.92);
    border: 2.5px solid #C9A06C;
    border-radius: 16px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.5);
    aspect-ratio: 1 / 1; /* บังคับให้เป็นสี่เหลี่ยมจัตุรัส */
}

.overlay-service-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 10px;
    margin-bottom: 4px;
}

.overlay-gear-icon {
    margin-bottom: 4px;
}

.overlay-service-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
}

.overlay-auth-badge {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 9px;
    font-weight: 700;
    color: #5DB55D;
    margin-top: 3px;
}

/* ========================================
   VIEWS MANAGEMENT
   ======================================== */
.view-step {
    display: none;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    animation: fadeIn 0.3s ease-in-out;
}
.view-step.active { display: flex; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   BOTTOM NAVIGATION
   ======================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 65px;
    background: var(--cheese-color);
    border-top: 3px solid var(--border-dark);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -3px 15px rgba(0,0,0,0.3);
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-dark);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}
.nav-icon {
    width: 22px;
    height: 22px;
    stroke-width: 2.5;
}
.nav-item.active { color: #D35400; }

/* ========================================
   SUB HEADERS (View 2, 3, 4)
   ======================================== */
.app-header {
    padding: 20px;
    display: flex;
    align-items: center;
}
.back-btn {
    background: var(--card-bg);
    border: 3px solid var(--border-dark);
    color: var(--text-dark);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 0 var(--border-dark);
}
.back-btn:active { transform: translateY(4px); box-shadow: none; }
.header-title {
    flex-grow: 1;
    text-align: center;
    font-size: 20px;
    font-weight: 800;
    color: #FFF;
    text-shadow: 2px 2px 0 #4A2E1B;
    margin-right: 44px;
}

/* ========================================
   FORMS & INPUTS
   ======================================== */
.form-container {
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}
.input-group { width: 100%; margin-bottom: 20px; }
.input-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #FFF;
    margin-bottom: 8px;
}
.input-field {
    width: 100%;
    background: var(--card-bg);
    border: 3px solid var(--border-dark);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    outline: none;
    box-shadow: inset 0 3px 5px rgba(0,0,0,0.1);
}
.input-field:focus { border-color: #D35400; }

.btn-primary {
    width: 100%;
    background: var(--gradient-btn);
    color: var(--text-dark);
    border: 3px solid var(--border-dark);
    border-radius: 30px;
    padding: 16px;
    font-size: 18px;
    font-weight: 800;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    margin-top: 15px;
    transition: all 0.1s;
}
.btn-primary:active { transform: translateY(4px); box-shadow: 0 2px 0px rgba(181,127,77,1); }

.btn-secondary {
    width: 100%;
    background: transparent;
    color: #FFD166;
    border: none;
    padding: 16px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-top: 10px;
}

.info-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(255,255,255,0.1);
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    border: 1px solid rgba(255,255,255,0.15);
}
.info-icon { color: #FFD166; flex-shrink: 0; }
.info-text { font-size: 13px; color: rgba(255,255,255,0.8); line-height: 1.5; }

.loader-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================
   MODALS
   ======================================== */
.modal-overlay {
    position: fixed;
    z-index: 9999;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(42, 21, 8, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.verify-modal-box {
    background: var(--card-bg) !important;
    width: 100%;
    max-width: 350px;
    border: 4px solid var(--border-dark) !important;
    border-radius: 24px !important;
    padding: 30px 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.otp-boxes-container { display: flex; justify-content: center; gap: 8px; margin: 20px 0; }
.otp-box {
    width: 42px;
    height: 52px;
    border: 3px solid var(--border-dark);
    border-radius: 12px;
    background: #FFF;
    font-size: 24px;
    font-weight: 800;
    text-align: center;
    color: var(--primary-dark);
}
.otp-box:focus { border-color: #D35400; outline: none; }

.btn-verify-green {
    width: 100%;
    background: #80C865;
    color: #1F4A14;
    border: 3px solid #5A9A42;
    border-radius: 30px;
    padding: 14px;
    font-size: 16px;
    font-weight: 800;
    box-shadow: 0 4px 0 #5A9A42;
    cursor: pointer;
    transition: 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
}
.btn-verify-green:active { transform: translateY(4px); box-shadow: none; }

/* ========================================
   OTP RESULT DISPLAY
   ======================================== */
.otp-display-area { 
    padding: 24px; 
    margin: 0 20px 20px 20px;
    width: calc(100% - 40px); 
    text-align: center; 
    background: var(--card-bg);
    border: 3px solid var(--border-dark);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    box-sizing: border-box;
}
.otp-subtitle { color: var(--text-dark); font-size: 14px; font-weight: 600; }
.otp-email-display { font-size: 16px; font-weight: 800; color: var(--primary-dark); margin-bottom: 20px; }
.otp-list { display: flex; flex-direction: column; gap: 12px; }

.otp-list-item {
    background: #FFF;
    border: 3px solid var(--border-dark);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 0 var(--border-dark);
}
.otp-item-left { display: flex; flex-direction: column; gap: 4px; }
.otp-item-time { font-size: 12px; color: var(--text-gray); }
.otp-item-code { font-size: 28px; font-weight: 800; color: #D35400; letter-spacing: 2px; }
.otp-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.status-badge { padding: 4px 10px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.status-ready { background: #E8F5E9; color: #2E7D32; border: 2px solid #2E7D32; }
.status-expired { background: #FFEBEE; color: #C62828; border: 2px solid #C62828; }

/* ========================================
   TYPE SELECT (View 2)
   ======================================== */
.page-subtitle {
    font-size: 14px;
    color: #FFF;
    font-weight: 600;
    text-shadow: 1px 1px 0 #4A2E1B;
}
.type-select-list { padding: 0 24px; display: flex; flex-direction: column; gap: 16px; width: 100%; }
.type-btn {
    background: var(--card-bg);
    border: 3px solid var(--border-dark);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.1s;
    text-align: left;
}
.type-btn:active { transform: translateY(4px); box-shadow: 0 2px 0px rgba(181,127,77,1); }
.type-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: #FFF;
    border: 2px solid var(--border-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.type-text { flex-grow: 1; }
.type-title { font-size: 16px; font-weight: 700; color: var(--text-dark); }
.type-desc { font-size: 13px; color: var(--text-gray); margin-top: 4px; }

/* ========================================
   UTILITIES
   ======================================== */
.hidden { display: none !important; }
.mask-y {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 25%, black 75%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 25%, black 75%, transparent 100%);
}

/* ========================================
   DESKTOP CONSTRAINTS
   ======================================== */
@media (min-width: 768px) {
    .app-container {
        border-left: 8px solid #4A2E1B;
        border-right: 8px solid #4A2E1B;
        box-shadow: 0 0 50px rgba(0,0,0,0.8);
    }
}

.auth-card { background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-radius: 20px; padding: 15px 20px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); border: 2px solid rgba(255,255,255,0.5); width: 100%; max-width: 400px; margin: 0 auto; } 
.fade-in { animation: fadeIn 0.4s ease-out forwards; } 
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ========================================
   LATEST OTP CARD (VIEW 4)
   ======================================== */
.latest-otp-card {
    background: #FFF;
    border-radius: var(--radius-md);
    padding: 24px 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 2px solid var(--border-color);
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}
.latest-otp-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 6px;
    background: var(--gradient-btn);
}
.latest-otp-title {
    font-size: 15px;
    color: var(--text-gray);
    font-weight: 600;
    margin-bottom: 8px;
}
.latest-otp-code {
    font-size: 38px;
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: 6px;
    margin: 10px 0 15px 0;
    text-shadow: 1px 1px 0px rgba(0,0,0,0.1);
}
.latest-otp-ref {
    font-size: 13px;
    color: var(--text-gray);
    margin-top: -10px;
    margin-bottom: 15px;
    background: #FFF3C4;
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 600;
}
.latest-otp-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px dashed #EEE;
}
.latest-otp-expire-text {
    font-size: 13px;
    color: var(--text-gray);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}
.latest-otp-status-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}
.status-badge-ready {
    background: #E8F5E9; color: #2E7D32; border: 1px solid #2E7D32;
}
.status-badge-expired {
    background: #FFEBEE; color: #C62828; border: 1px solid #C62828;
}

