/* --- Logo Styles --- */
.logo-container {
    width: 100%;
    text-align: center;
    margin-bottom: 20px;
}

.site-logo {
    max-width: 180px;
    height: auto;
}

/* --- General Styles --- */
body {
    font-family: 'Kanit', sans-serif;
    background-color: #F8F9FA;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    display: block;
    /* ป้องกันการ scroll แนวนอน */
    overflow-x: hidden;
}

.container {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 500px;
    text-align: center;
    margin: 0 auto;
    box-sizing: border-box;
}

h1, h2, h3 {
    color: #2C3E50;
}

/* --- Login & Result Page Styles --- */
.login-container, .result-container {
    max-width: 400px;
}

input[type="text"] {
    width: calc(100% - 20px);
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    box-sizing: border-box;
}

input[type="text"]:focus {
    outline: none;
    border-color: #3498DB;
}

.button {
    width: 100%;
    padding: 12px;
    background-color: #3498DB;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    transition: background-color 0.3s;
    text-decoration: none;
    display: inline-block;
    box-sizing: border-box;
}

.button:hover {
    background-color: #2980B9;
}

.button-back {
    background-color: #7f8c8d;
}
.button-back:hover {
    background-color: #6c7a7d;
}

.result-box {
    padding: 20px;
    border-radius: 5px;
    margin-top: 20px;
    color: white;
    box-sizing: border-box;
}
.pass {
    background-color: #2ECC71;
}
.fail {
    background-color: #E74C3C;
}

/* --- Exam Page Styles --- */
.exam-container {
    max-width: 800px;
    text-align: left;
    box-sizing: border-box;
}

.exam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background-color: #ecf0f1;
    border-radius: 5px;
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-sizing: border-box;
}

#countdown {
    background-color: #f1c40f;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    color: #2c3e50;
    font-size: 18px;
}

.question-form ol {
    padding-left: 0;
    list-style-type: none;
}

.question-form li {
    background-color: #ffffff;
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    box-sizing: border-box;
}

.question-form p {
    font-weight: bold;
    font-size: 18px;
    margin-top: 0;
}

.question-form input[type="radio"] {
    margin-right: 10px;
}

/* --- Instruction Styles --- */
.instructions-box {
    text-align: left;
    background-color: #fffbe6;
    border-left: 5px solid #f1c40f;
    padding: 15px 20px;
    margin-bottom: 25px;
    border-radius: 5px;
    box-sizing: border-box;
}
.instructions-box p {
    margin: 10px 0;
    font-size: 16px;
    line-height: 1.6;
}
.instructions-box .highlight-text {
    color: #c0392b;
    font-weight: bold;
}
.instructions-box .warning-text {
    font-weight: bold;
}

/* --- Error Message Box --- */
.error-box {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    text-align: center;
    box-sizing: border-box;
}

/* === Login Page Redesign === */
.login-page-background {
    background-color: #eef2f5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

.login-card {
    background: #ffffff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-sizing: border-box;
}

.login-logo {
    max-width: 120px;
    margin-bottom: 20px;
}

.login-title {
    font-size: 24px;
    color: #2c3e50;
    margin: 0 0 10px 0;
}

.login-subtitle {
    font-size: 16px;
    color: #7f8c8d;
    margin: 0 0 30px 0;
    line-height: 1.5;
}

.login-form input[type="text"] {
    background: #f8f9fa;
    border: 1px solid #dfe6e9;
    font-size: 16px;
}

.login-form .button {
    margin-top: 10px;
    background-color: #3498db;
    font-weight: bold;
}

.login-footer {
    margin-top: 30px;
    font-size: 12px;
    color: #95a5a6;
}

/* --- Media Query สำหรับสมาร์ทโฟน (หน้าจอแนวตั้ง) --- */
@media (max-width: 600px) and (orientation: portrait) {
    
    /* ลดระยะห่างรอบๆ ตัวเว็บ */
    body {
        padding: 5px;
        font-size: 14px;
    }

    /* ปรับ container หลักและ container ของหน้าข้อสอบ */
    .container, .exam-container {
        width: 100%;
        max-width: 100%;
        padding: 10px;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        min-height: calc(100vh - 10px);
    }

    /* ปรับ login card สำหรับมือถือ */
    .login-card {
        width: 100%;
        max-width: 100%;
        padding: 20px 15px;
        border-radius: 0;
        box-shadow: none;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .login-page-background {
        padding: 0;
        align-items: stretch;
    }

    /* ปรับขนาดตัวอักษร */
    .question-form p {
        font-size: 15px;
        line-height: 1.4;
    }

    .login-subtitle {
        font-size: 14px;
    }

    h1 {
        font-size: 22px;
    }

    h2 {
        font-size: 20px;
    }

    /* ปรับ exam header */
    .exam-header {
        padding: 8px;
        margin-bottom: 10px;
        flex-wrap: wrap;
        gap: 10px;
    }

    #countdown {
        font-size: 14px;
        padding: 4px 12px;
    }

    /* ปรับคำถาม */
    .question-form li {
        padding: 15px;
        margin-bottom: 10px;
    }

    /* ปรับกล่องคำชี้แจง */
    .instructions-box {
        padding: 12px 15px;
        margin-bottom: 15px;
    }

    .instructions-box p {
        font-size: 14px;
        line-height: 1.5;
        margin: 8px 0;
    }

    /* ปรับ input และ button */
    input[type="text"] {
        font-size: 16px; /* ต้องเป็น 16px เพื่อป้องกัน zoom บน iOS */
        padding: 12px 10px;
        width: calc(100% - 20px);
    }

    .button {
        font-size: 16px;
        padding: 14px 12px;
        border-radius: 6px;
    }

    /* ปรับโลโก้ */
    .site-logo, .login-logo {
        max-width: 140px;
    }

    /* จัดโลโก้ให้อยู่กึ่งกลางในหน้าจอมือถือ */
    .logo-container {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        margin-bottom: 20px;
    }

    /* สำหรับหน้า login */
    .login-card .login-logo {
        display: block;
        margin: 0 auto 20px auto;
    }

    /* ปรับ radio button ให้กดง่ายขึ้น */
    .question-form input[type="radio"] {
        transform: scale(1.2);
        margin: 0 12px 0 0;
    }

    .question-form label {
        display: block;
        padding: 8px 0;
        cursor: pointer;
        line-height: 1.4;
    }

    /* ปรับ result box */
    .result-box {
        padding: 15px;
        font-size: 15px;
        line-height: 1.4;
    }
}

/* Media query สำหรับหน้าจอที่เล็กมาก */
@media (max-width: 360px) {
    body {
        padding: 2px;
        font-size: 13px;
    }

    .container, .exam-container, .login-card {
        padding: 8px;
    }

    .question-form li {
        padding: 10px;
    }

    .instructions-box {
        padding: 10px 12px;
    }

    .instructions-box p {
        font-size: 13px;
    }

    #countdown {
        font-size: 12px;
        padding: 3px 8px;
    }
}

/* === Modern Login Page Design === */

/* สำหรับหน้า Login ที่ใช้ class .modern-login */
.modern-login {
    font-family: 'Kanit', sans-serif;
    overflow-x: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    position: relative;
    margin: 0;
    padding: 0;
}

/* Animated Background */
.modern-login .bg-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
}

.modern-login .bg-animation::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, 
        transparent, 
        rgba(255,255,255,0.1), 
        transparent,
        rgba(255,255,255,0.05),
        transparent
    );
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Floating particles */
.modern-login .particle {
    position: absolute;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    animation: float 6s ease-in-out infinite;
}

.modern-login .particle:nth-child(1) {
    width: 8px;
    height: 8px;
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.modern-login .particle:nth-child(2) {
    width: 12px;
    height: 12px;
    top: 60%;
    left: 80%;
    animation-delay: 2s;
}

.modern-login .particle:nth-child(3) {
    width: 6px;
    height: 6px;
    top: 80%;
    left: 20%;
    animation-delay: 4s;
}

.modern-login .particle:nth-child(4) {
    width: 10px;
    height: 10px;
    top: 30%;
    left: 70%;
    animation-delay: 1s;
}

.modern-login .particle:nth-child(5) {
    width: 14px;
    height: 14px;
    top: 70%;
    left: 60%;
    animation-delay: 3s;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); opacity: 1; }
    50% { transform: translateY(-20px) rotate(180deg); opacity: 0.8; }
}

/* Main container สำหรับหน้า Modern Login */
.modern-login .main-container {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* Modern Login card - Override เฉพาะเมื่อใช้ .modern-login */
.modern-login .login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.1),
        0 8px 32px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    text-align: center;
    animation: slideUp 0.8s ease-out;
    position: relative;
    box-sizing: border-box;
}

@keyframes slideUp {
    0% {
        opacity: 0;
        transform: translateY(50px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modern Logo */
.modern-login .login-logo {
    max-width: 120px;
    margin-bottom: 25px;
    border-radius: 50%;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.modern-login .login-logo:hover {
    transform: scale(1.05) rotate(5deg);
}

/* Modern Title */
.modern-login .login-title {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 15px;
    line-height: 1.4;
    background: linear-gradient(135deg, #2c3e50, #3498db);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Modern Subtitle */
.modern-login .login-subtitle {
    font-size: 16px;
    color: #7f8c8d;
    margin-bottom: 30px;
    line-height: 1.5;
}

/* Modern Error message */
.modern-login .error-box {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
    animation: shake 0.5s ease-in-out;
    border: none;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Modern Form */
.modern-login .login-form {
    margin-bottom: 30px;
}

/* Modern Input */
.modern-login .input-group {
    position: relative;
    margin-bottom: 25px;
}

.modern-login .login-form input[type="text"] {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    font-size: 16px;
    font-family: 'Kanit', sans-serif;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
    outline: none;
    box-sizing: border-box;
}

.modern-login .login-form input[type="text"]:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.1);
    background: white;
    transform: translateY(-2px);
}

.modern-login .login-form input[type="text"]::placeholder {
    color: #95a5a6;
    transition: opacity 0.3s ease;
}

.modern-login .login-form input[type="text"]:focus::placeholder {
    opacity: 0.7;
}

/* Modern Button */
.modern-login .button {
    width: 100%;
    padding: 16px 20px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    font-family: 'Kanit', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    text-decoration: none;
    display: inline-block;
}

.modern-login .button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.modern-login .button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.3);
}

.modern-login .button:hover::before {
    left: 100%;
}

.modern-login .button:active {
    transform: translateY(0);
}

/* Modern Info sections */
.modern-login .info-section {
    background: rgba(255, 255, 255, 0.5);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    border-left: 4px solid #3498db;
}

.modern-login .info-section p {
    font-size: 14px;
    line-height: 1.6;
    color: #2c3e50;
    margin: 0;
}

/* Modern Footer */
.modern-login .login-footer {
    font-size: 12px;
    color: #7f8c8d;
    line-height: 1.6;
}

.modern-login .login-footer b {
    color: #2c3e50;
}

/* Glow effect */
.modern-login .glow {
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { box-shadow: 0 0 20px rgba(52, 152, 219, 0.2); }
    to { box-shadow: 0 0 30px rgba(52, 152, 219, 0.4); }
}

/* Modern Login Responsive */
@media (max-width: 600px) {
    .modern-login .main-container {
        padding: 10px;
    }

    .modern-login .login-card {
        padding: 30px 20px;
        border-radius: 15px;
        max-width: 100%;
        min-height: auto;
    }

    .modern-login .login-title {
        font-size: 20px;
    }

    .modern-login .login-logo {
        max-width: 100px;
    }

    .modern-login .button, 
    .modern-login .login-form input[type="text"] {
        padding: 14px 16px;
        font-size: 16px;
    }

    .modern-login .login-subtitle {
        font-size: 14px;
    }

    .modern-login .info-section {
        padding: 15px;
    }
}