/* รีเซ็ตค่าเริ่มต้น */
* { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: 'Mali', cursive; background-color: #F4F9FF; background-image: radial-gradient(#B3D4FF 2px, transparent 2px); background-size: 25px 25px; color: #333333; display: flex; flex-direction: column; min-height: 100vh; }
header { background-color: #FFFFFF; padding: 15px 30px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); border-bottom: 1px solid #E0E0E0; }
main { flex: 1; width: 100%; max-width: 1000px; margin: 30px auto; padding: 0 20px; display: flex; flex-direction: column; }

/* Login UI */
.login-section { display: flex; align-items: center; justify-content: center; flex: 1; }
.auth-card { background: #FFFFFF; border-radius: 20px; padding: 40px 30px; box-shadow: 0 15px 35px rgba(0,97,160,0.15); width: 100%; max-width: 450px; text-align: center; border: 1px solid #E3F2FD; }
.auth-card h2 { color: #1261A0; margin-bottom: 5px; font-size: 1.8rem; }
.auth-card .subtitle { color: #3895D3; margin-bottom: 25px; font-size: 0.95rem; }
.animated-icon { font-size: 3.5rem; margin-bottom: 10px; animation: float 3s ease-in-out infinite; }
@keyframes float { 0% { transform: translateY(0px); } 50% { transform: translateY(-10px); } 100% { transform: translateY(0px); } }

.input-group { text-align: left; margin-bottom: 15px; }
.input-group label { display: block; font-weight: 600; color: #1261A0; margin-bottom: 5px; font-size: 0.95rem; }
input[type="text"], input[type="password"], input[type="number"], select { width: 100%; padding: 12px 15px; border: 1px solid #BBDEFB; border-radius: 10px; font-family: 'Mali', cursive; font-size: 1rem; outline: none; background-color: #F8FBFF; transition: 0.3s; }
input:focus, select:focus { border-color: #3895D3; background-color: #FFFFFF; box-shadow: 0 0 8px rgba(56,149,211,0.2); }
.divider { height: 1px; background-color: #E0E0E0; margin: 25px 0; }
.register-hint { color: #7F8C8D; font-size: 0.9rem; margin-bottom: 10px; }

/* Buttons */
button { font-family: 'Mali', cursive; font-size: 1.1rem; font-weight: bold; padding: 12px 20px; border: none; border-radius: 10px; cursor: pointer; transition: 0.2s; }
button:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.btn-primary { background-color: #1261A0; color: white; width: 100%; border-radius: 10px; font-size: 1.2rem; }
.btn-outline { background-color: transparent; color: #1261A0; border: 1px solid #1261A0; width: 100%; border-radius: 10px; }
.btn-success { background-color: #00B16A; color: white; width: 100%; border-radius: 10px; font-size: 1.2rem;}
.btn-green { background-color: #00C853; color: white; }
.btn-red { background-color: #E74C3C; color: white; }
.btn-purple { background-color: #6F42C1; color: white; }
.btn-outline-red { background-color: transparent; border: 2px solid #E74C3C; color: #E74C3C; padding: 8px 15px; border-radius: 20px;}
.btn-outline-blue { background-color: #E3F2FD; border: 1px solid #3498DB; color: #2980B9; padding: 8px 15px; border-radius: 20px;}
.btn-dark { background-color: #2C3E50; color: white; border-radius: 20px;}

.card { background-color: #FFFFFF; border-radius: 25px; padding: 30px; box-shadow: 0 10px 30px rgba(0,0,0,0.05); margin-bottom: 20px; }
.user-bar { display: flex; justify-content: space-between; align-items: center; background-color: #E3F2FD; padding: 15px 25px; border-radius: 30px; margin-bottom: 20px; border: 1px solid #BBDEFB; }

/* พาร์ทข้อสอบ */
.exam-part-header { color: white; padding: 15px 20px; border-radius: 15px 15px 0 0; margin: 30px -30px 20px -30px; font-size: 1.2rem; font-weight: bold; }
.header-blue { background-color: #2980B9; }
.header-purple { background-color: #6F42C1; }
.header-green { background-color: #00B16A; }
.question-item { background: #FFFFFF; border: 1px solid #E0E0E0; border-radius: 15px; padding: 20px; margin-bottom: 15px; }
.question-text { font-weight: 700; font-size: 1.1rem; color: #34495E; margin-bottom: 15px; }
.choices-container label { display: block; background-color: #F8F9FA; padding: 12px 15px; margin-bottom: 8px; border-radius: 10px; border: 1px solid #EEEEEE; cursor: pointer; transition: 0.2s; }
.choices-container label:hover { background-color: #E3F2FD; border-color: #90CAF9; }

/* กล่องจับคู่ (Matching UI) */
.matching-wrapper { display: flex; gap: 20px; align-items: flex-start; }
.matching-options-box { flex: 1; background: #F8F9FA; border: 2px solid #E0E0E0; border-radius: 15px; padding: 15px; min-width: 250px; }
.matching-option-item { background: white; padding: 10px; margin-bottom: 10px; border-radius: 10px; border: 1px solid #D1C4E9; display: flex; align-items: center; gap: 10px;}
.matching-option-item .badge { background: #6F42C1; color: white; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: bold;}
.matching-questions-box { flex: 2; min-width: 300px; }

/* หน้า Result วงกลมคะแนน */
.score-circle-wrapper { display: flex; justify-content: center; margin-bottom: 30px; }
.score-circle { width: 160px; height: 160px; border-radius: 50%; background: conic-gradient(#E0E0E0 100%, #E0E0E0 0); display: flex; align-items: center; justify-content: center; box-shadow: 0 5px 15px rgba(0,0,0,0.1); transition: background 1s ease-out; }
.score-inner { width: 130px; height: 130px; background: #FFFFFF; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: inset 0 2px 5px rgba(0,0,0,0.05); }
.score-breakdown { display: flex; gap: 10px; justify-content: space-between; }
.score-box { flex: 1; padding: 15px 5px; border-radius: 15px; background: #FFF; text-align: center; font-size: 1.2rem; }
.box-title { font-size: 0.9rem; color: #7F8C8D; display: block; margin-bottom: 5px; }
.part1-box { border: 2px solid #90CAF9; }
.part2-box { border: 2px solid #B39DDB; }
.part3-box { border: 2px solid #A5D6A7; }
.ai-feedback-box { border-radius: 15px; padding: 20px; border: 1px solid #BBDEFB; }

/* Admin Dashboard UI */
.admin-main-card { border: 4px solid #34495E; border-radius: 30px; padding: 40px; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; flex-wrap: wrap; gap: 15px;}
.admin-title-area { display: flex; align-items: center; gap: 15px; }
.admin-icon { background: #2C3E50; color: white; width: 60px; height: 60px; border-radius: 15px; display: flex; align-items: center; justify-content: center; font-size: 2rem; box-shadow: 0 5px 15px rgba(0,0,0,0.2);}
.badge-success { background: #E8F5E9; color: #27AE60; padding: 5px 10px; border-radius: 20px; font-size: 0.85rem; font-weight: bold; border: 1px solid #A5D6A7; }
.admin-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: white; border: 1px solid #E0E0E0; border-radius: 15px; padding: 20px; text-align: center; box-shadow: 0 5px 10px rgba(0,0,0,0.02); }
.stat-icon { font-size: 2.5rem; margin-bottom: 10px; }
.stat-label { color: #7F8C8D; font-size: 0.95rem; margin-bottom: 5px; font-weight: bold;}
.stat-value { font-size: 2.5rem; font-weight: bold; }

/* Table Admin */
.table-responsive { overflow-x: auto; border: 1px solid #EEEEEE; border-radius: 15px; }
table { width: 100%; border-collapse: collapse; background: white; min-width: 600px; }
th, td { border-bottom: 1px solid #EEEEEE; padding: 15px; text-align: center; white-space: nowrap;}
th { background-color: #F8F9FA; color: #2C3E50; font-weight: bold; }

/* UI กราฟและประวัติ */
.chart-container { background: white; padding: 15px; border-radius: 15px; border: 1px solid #E0E0E0; margin-bottom: 20px; }
.history-list-item { display: flex; justify-content: space-between; align-items: center; background: #F8F9FA; border: 1px solid #E0E0E0; border-radius: 10px; padding: 15px; margin-bottom: 10px; transition: 0.2s; }
.history-list-item:hover { background: #E3F2FD; border-color: #90CAF9; }
.history-list-btn { background: #3498DB; color: white; padding: 8px 15px; border-radius: 8px; font-size: 0.9rem; border: none; cursor: pointer; font-family: 'Mali', cursive;}
.history-list-btn:hover { background: #2980B9; }

/* Responsive */
@media screen and (max-width: 768px) {
    header h1 { font-size: 1.2rem; }
    header h1 span { display: block; font-size: 0.85rem; margin-top: 5px;}
    .card { padding: 20px; }
    .auth-card { padding: 30px 20px; }
    .exam-part-header { margin: 20px -20px 15px -20px; font-size: 1.1rem; }
    .matching-wrapper { flex-direction: column; }
    .score-breakdown { flex-direction: column; }
    .user-bar { flex-direction: column; gap: 10px; text-align: center;}
    .admin-main-card { padding: 20px; }
    .admin-header { flex-direction: column; text-align: center; }
    .admin-title-area { flex-direction: column; }
    .history-list-item { flex-direction: column; text-align: left; align-items: flex-start; gap: 10px; }
}