/* รีเซ็ตและบังคับใช้ฟอนต์ Sarabun ทั่วทั้งระบบ 100% */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Sarabun', sans-serif !important; }

/* 🌈 พื้นหลังสีสว่างสดใส (Glassmorphism) */
body { background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 50%, #fbc2eb 100%); min-height: 100vh; display: flex; color: #333; overflow-x: hidden; }

/* 1. Sidebar Design */
.sidebar { 
    width: 270px; 
    height: 100vh;
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.3); 
    backdrop-filter: blur(15px); 
    -webkit-backdrop-filter: blur(15px);
    border-right: 1px solid rgba(255, 255, 255, 0.4); 
    display: flex; flex-direction: column; transition: all 0.3s ease; 
}
.school-brand { padding: 25px 20px; display: flex; align-items: center; gap: 15px; border-bottom: 1px solid rgba(255, 255, 255, 0.4); }
.brand-icon { font-size: 28px; background: rgba(255, 255, 255, 0.6); width: 45px; height: 45px; display: flex; align-items: center; justify-content: center; border-radius: 12px; }

.brand-text h3 { color: #4a4e69; font-size: 16px; font-weight: 700; line-height: 1.3; white-space: normal; word-wrap: break-word; margin-bottom: 2px; }
.brand-text p { color: #666; font-size: 12px; }

.sidebar-menu { flex: 1; overflow-y: auto; padding: 15px 15px; }
.sidebar-menu::-webkit-scrollbar { width: 5px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.5); border-radius: 5px; }

.menu-category { font-size: 12px; color: #4a4e69; font-weight: 700; text-transform: uppercase; margin: 15px 0 8px 10px; letter-spacing: 0.5px; opacity: 0.8;}
.menu-item { 
    padding: 12px 15px; margin-bottom: 8px; border-radius: 10px; cursor: pointer; transition: all 0.3s ease; 
    font-weight: 500; color: #22223b; display: flex; align-items: center; gap: 10px;
    background: rgba(255, 255, 255, 0.4);
}
.menu-item:hover, .menu-item.active { background: rgba(255, 255, 255, 0.8); transform: translateX(5px); box-shadow: 0 4px 15px rgba(0,0,0,0.1); color: #4a4e69; font-weight: 600; }

.sidebar-user { padding: 15px; border-top: 1px solid rgba(255, 255, 255, 0.4); display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, 0.2); }
.user-avatar { font-size: 20px; background: rgba(255, 255, 255, 0.6); width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.user-info { flex: 1; overflow: hidden; }
.user-info h4 { font-size: 14px; color: #4a4e69; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 12px; color: #666; }
.logout-btn { background: rgba(239, 68, 68, 0.15); border: none; cursor: pointer; padding: 8px 10px; border-radius: 10px; transition: 0.3s; display: flex; align-items: center; justify-content: center; }
.logout-btn:hover { background: #ef4444; }
.logout-btn:hover svg { stroke: #ffffff; }

/* 2. Main Content & Topbar */
.main-content { flex: 1; display: flex; flex-direction: column; overflow-y: auto; padding: 30px; transition: 0.3s; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.topbar-left { display: flex; align-items: center; gap: 15px; }
.topbar-right { display: flex; align-items: center; }
.page-titles h2 { color: #4a4e69; font-size: 24px; margin-bottom: 2px;}
.page-titles p { color: #666; font-size: 14px; }
.date-badge { background: rgba(255, 255, 255, 0.4); backdrop-filter: blur(5px); padding: 8px 15px; border-radius: 20px; font-size: 14px; color: #4a4e69; font-weight: 600; border: 1px solid rgba(255, 255, 255, 0.3);}

/* 3. Panel & Cards */
.glass-panel { background: rgba(255, 255, 255, 0.4); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 20px; padding: 30px; box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15); flex: 1; }
.glass-card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 16px; padding: 25px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); }

h1, h2, h3 { color: #4a4e69; margin-bottom: 15px; }

/* Buttons & Inputs */
.btn-container { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { padding: 10px 15px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; border: none; transition: 0.3s; display: inline-flex; align-items: center; gap: 5px;}
.btn-primary { background: linear-gradient(45deg, #667eea, #764ba2); color: white; } 
.btn-secondary { background: #e0e0e0; color: #333; }
.btn-danger { background: #ff6b6b; color: white; }
.btn-success { background: #28a745; color: white; }
.btn-info { background: #17a2b8; color: white; }
.btn-warning { background: #f59e0b; color: white; }
.btn:hover { opacity: 0.9; transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0,0,0,0.15); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 5px; }

.controls-panel { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 20px; flex-wrap: wrap; }
.search-group { flex: 1; min-width: 250px; }
.search-group input { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.5); background: rgba(255, 255, 255, 0.6); outline: none; transition: 0.3s; font-size: 15px; }
.search-group input:focus { background: rgba(255, 255, 255, 0.9); box-shadow: 0 0 8px rgba(118, 75, 162, 0.2); }

/* Table */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: rgba(255, 255, 255, 0.2); border-radius: 12px; overflow: hidden; white-space: nowrap; }
th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.2); font-size: 14px; }
th { background: rgba(118, 75, 162, 0.2); color: #4a4e69; font-weight: 600; }
tr:hover { background: rgba(255, 255, 255, 0.3); }

/* Badges */
.badge { padding: 4px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; color: white; display: inline-block; }
.bg-success { background: #28a745; }
.bg-warning { background: #ffc107; color: #333; }
.bg-danger { background: #dc3545; }
.bg-info { background: #17a2b8; }
.bg-secondary { background: #6c757d; }
.bg-primary { background: #3b82f6; }
.bg-purple { background: #8b5cf6; }

/* Modal */
.modal-overlay { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.4); backdrop-filter: blur(5px); align-items: center; justify-content: center; opacity: 0; transition: opacity 0.3s ease; }
.modal-overlay.show { display: flex; opacity: 1; }
.modal-content { background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(20px); border-radius: 20px; padding: 30px; width: 90%; max-width: 800px; max-height: 90vh; overflow-y: auto; position: relative; box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.25); }
.close-btn { position: absolute; top: 15px; right: 20px; font-size: 28px; cursor: pointer; color: #4a4e69; background: none; border: none; font-weight: bold;}
.close-btn:hover { color: #ff6b6b; transform: scale(1.1); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 15px; }
.input-group { display: flex; flex-direction: column; }
.input-group label { font-size: 14px; font-weight: 600; margin-bottom: 5px; color: #4a4e69; }
.input-group input, .input-group select, .input-group textarea { padding: 10px; border-radius: 8px; border: 1px solid rgba(0, 0, 0, 0.1); background: rgba(255, 255, 255, 0.9); outline: none; transition: 0.3s; font-size: 14px; }
.input-group input:focus, .input-group select:focus, .input-group textarea:focus { background: #fff; box-shadow: 0 0 8px rgba(118, 75, 162, 0.3); border-color: rgba(118, 75, 162, 0.5); }

/* ============================================== */
/* 📺 PUBLIC BOARD (หน้าจอสาธารณะแบบลอยตัว) */
/* ============================================== */
.public-header { text-align: center; margin-bottom: 30px; }
.pb-clock-text { font-size: 5rem; font-weight: 700; color: #3b82f6; margin-bottom: 0; line-height: 1; text-shadow: 2px 2px 10px rgba(59, 130, 246, 0.2); }
.pb-date-text { font-size: 1.5rem; color: #64748b; font-weight: 500; margin-bottom: 20px; }
.pb-title-text { font-size: 2rem; color: #f59e0b; font-weight: 700; margin-bottom: 5px; }
.pb-school-text { font-size: 1.6rem; color: #1e293b; font-weight: 600; }

.pb-stats-bar { 
    display: flex; gap: 15px; overflow-x: auto; margin-bottom: 30px; padding-bottom: 10px; 
    justify-content: center;
}
.pb-stat-box { 
    flex: 1; min-width: 140px; max-width: 200px;
    background: #ffffff; border-radius: 15px; padding: 20px 10px; 
    text-align: center; box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0; border-top: 5px solid #3b82f6;
}
.pb-stat-box.all { border-top-color: #f59e0b; }
.pb-stat-box h2 { font-size: 2rem; color: #1e293b; margin: 0; line-height: 1.2; font-weight: 700; }
.pb-stat-box p { font-size: 1rem; color: #64748b; margin-top: 5px; font-weight: 600; }

.pb-main-grid { display: grid; grid-template-columns: 3fr 1fr; gap: 25px; }

/* Student Cards (Left) */
.pb-student-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.pb-student-card { 
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 15px; 
    display: flex; align-items: center; gap: 15px; transition: 0.3s;
}
.pb-student-card:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.08); }
.pb-avatar { font-size: 28px; background: #e0e7ff; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.pb-info { flex: 1; }
.pb-info h4 { font-size: 16px; color: #0f172a; margin-bottom: 3px; white-space: normal; word-break: break-word; line-height: 1.3;}
.pb-info p { font-size: 13px; color: #64748b; margin-bottom: 5px; }

/* Recent Logs (Right) */
.pb-recent-logs { display: flex; flex-direction: column; gap: 12px; }
.pb-recent-card { 
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 12px;
    display: flex; align-items: center; gap: 12px;
}
.pb-recent-avatar { font-size: 24px; background: #fef3c7; width: 45px; height: 45px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.pb-recent-card h4 { font-size: 15px; color: #b45309; margin-bottom: 2px; white-space: normal; word-break: break-word;}
.pb-recent-card p { font-size: 12px; color: #92400e; margin-bottom: 3px; }

/* ไอคอนกดขยายเต็มจอ (ลอยมุมขวาบน) */
.floating-fs-btn {
    position: absolute;
    top: 20px;
    right: 25px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    color: #4a4e69;
    transition: 0.3s;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.floating-fs-btn:hover {
    background: #fff;
    color: #3b82f6;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* ============================================== */
/* 📊 DASHBOARD STYLES */
/* ============================================== */
.dash-welcome {
    display: flex; justify-content: space-between; align-items: center; 
    background: linear-gradient(120deg, #3f51b5, #1e3a8a); 
    color: white; border: none; margin-bottom: 20px; padding: 30px;
}
.welcome-text h2 { color: #ffca28; font-size: 22px; margin-bottom: 5px; }
.welcome-text p { color: #e2e8f0; font-size: 14px; }
.welcome-time { text-align: right; }
.welcome-time h3 { color: white; font-size: 18px; margin-bottom: 2px;}
.welcome-time p { color: #cbd5e1; font-size: 14px; }

.dash-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 20px; }
.dash-stat-card {
    background: #fff; border-radius: 16px; padding: 20px; display: flex; align-items: center; gap: 15px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); border-left: 5px solid transparent;
}
.dash-stat-card.border-blue { border-left-color: #3b82f6; }
.dash-stat-card.border-yellow { border-left-color: #f59e0b; }
.dash-stat-card.border-green { border-left-color: #10b981; }
.dash-stat-card.border-red { border-left-color: #ef4444; }

.stat-icon { width: 50px; height: 50px; border-radius: 12px; display: flex; justify-content: center; align-items: center; font-size: 24px; }
.bg-blue-light { background: #eff6ff; color: #3b82f6; }
.bg-yellow-light { background: #fef3c7; color: #f59e0b; }
.bg-green-light { background: #ecfdf5; color: #10b981; }
.bg-red-light { background: #fef2f2; color: #ef4444; }

.stat-info h2 { font-size: 26px; color: #1e293b; margin: 0; line-height: 1; }
.stat-info p { font-size: 12px; color: #64748b; margin-top: 5px; font-weight: 600; }
.stat-info small { font-size: 11px; color: #10b981; display: block; margin-top: 5px; font-weight: 500;}

.dash-charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px; }
.dash-bottom-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px; }

.activity-list { display: flex; flex-direction: column; gap: 15px; }
.activity-item { display: flex; align-items: flex-start; gap: 15px; padding-bottom: 15px; border-bottom: 1px solid #f1f5f9; }
.activity-item:last-child { border-bottom: none; padding-bottom: 0; }
.act-icon { width: 35px; height: 35px; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 16px; background: #f1f5f9; }
.act-detail { flex: 1; }
.act-detail h4 { font-size: 13px; color: #1e293b; margin-bottom: 3px; }
.act-detail p { font-size: 11px; color: #64748b; }
.act-time { font-size: 11px; color: #94a3b8; white-space: nowrap; }

.monthly-stats { display: flex; gap: 15px; }
.m-stat-box { flex: 1; background: #f8fafc; padding: 20px; border-radius: 12px; text-align: center; border: 1px solid #e2e8f0;}
.m-stat-box h1 { font-size: 32px; margin-bottom: 5px; line-height: 1;}
.m-stat-box p { font-size: 12px; color: #64748b; font-weight: 600; }

/* ============================================== */
/* 💳 NFC Attendance & Activity Check-in (ล่องหน 100%) */
/* ============================================== */
.attendance-container { display: flex; gap: 30px; flex-wrap: wrap; }
.scan-area { flex: 1.2; min-width: 300px; text-align: center; }
.log-area { flex: 1; min-width: 300px; }
.clock-display { font-size: 56px; font-weight: 700; color: #764ba2; margin: 10px 0; text-shadow: 2px 2px 5px rgba(0,0,0,0.1);}

.nfc-input-hidden { 
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    border: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    z-index: -100;
}
.nfc-input-hidden:focus { outline: none; }

.nfc-display-card { background: white; padding: 30px; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); transition: all 0.3s ease; border: 5px solid transparent; }
.nfc-display-card.success { border-color: #28a745; background: #e8f5e9; }
.nfc-display-card.warning { border-color: #ffc107; background: #fff8e1; }
.nfc-display-card.info { border-color: #17a2b8; background: #e0f7fa; }
.nfc-display-card.error { border-color: #dc3545; background: #ffebee; }
#scan-icon, #act-scan-icon { font-size: 60px; margin-bottom: 10px; }

/* ============================================== */
/* 🏆 ACTIVITY MODULE STYLES */
/* ============================================== */
.activity-tabs-container { display: flex; gap: 10px; margin-bottom: 20px; border-bottom: 2px solid rgba(255,255,255,0.4); padding-bottom: 10px; flex-wrap: wrap;}
.act-tab-btn { background: rgba(255,255,255,0.5); border: none; padding: 12px 20px; border-radius: 10px; font-weight: 600; cursor: pointer; transition: 0.3s; color: #4a4e69; font-size: 15px;}
.act-tab-btn:hover { background: rgba(255,255,255,0.8); transform: translateY(-2px);}
.act-tab-btn.active { background: #764ba2; color: white; box-shadow: 0 4px 10px rgba(118, 75, 162, 0.3); }

/* Leaderboard Cards */
.lb-card { background: #fff; border-radius: 12px; padding: 15px 25px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 2px 10px rgba(0,0,0,0.05); width: 100%; transition: transform 0.2s;}
.lb-card:hover { transform: scale(1.02); }
.lb-rank { font-size: 24px; font-weight: 700; color: #cbd5e1; width: 40px;}
.lb-rank-1 { color: #fbbf24; font-size: 30px;} /* ทอง */
.lb-rank-2 { color: #94a3b8; font-size: 28px;} /* เงิน */
.lb-rank-3 { color: #b45309; font-size: 26px;} /* ทองแดง */
.lb-info { flex: 1; margin-left: 15px;}
.lb-info h4 { font-size: 16px; color: #1e293b; margin-bottom: 2px;}
.lb-info p { font-size: 13px; color: #64748b;}
.lb-points { font-size: 22px; font-weight: 700; color: #10b981;}
.lb-points span { font-size: 12px; color: #64748b; font-weight: 400;}

/* Mobile Responsive */
@media (max-width: 768px) {
    body { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; border-right: none; border-bottom: 1px solid rgba(255, 255, 255, 0.4); }
    .main-content { padding: 15px; }
    .dash-stats-grid { grid-template-columns: 1fr; }
    .dash-charts-grid, .dash-bottom-grid { grid-template-columns: 1fr; }
    .attendance-container { flex-direction: column; }
    .pb-main-grid { grid-template-columns: 1fr; }
    .pb-student-grid { grid-template-columns: 1fr; }
}

@media print { body { background: white; } .sidebar, .topbar, .controls-panel, .action-btns, .activity-tabs-container, .floating-fs-btn { display: none !important; } .glass-panel { box-shadow: none; border: none; background: transparent; padding: 0;} }