
/* --- General Styles --- */
body {
    font-family: 'Sarabun', sans-serif;
    margin: 0;
    background-color: #f4f7f6;
    color: #333;
}

/* --- Status Modal (เพิ่มใหม่) --- */
#status-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none; /* ซ่อนไว้เป็นค่าเริ่มต้น */
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none; /* ซ่อนไว้เป็นค่าเริ่มต้น */
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#status-modal {
    background-color: white;
    padding: 25px 30px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    text-align: center;
    position: relative;
    width: 90%;
    max-width: 400px;
}
/* ใช้ .modal-box เป็นคลาสร่วมกัน */
.modal-box, #status-modal {
    background-color: white;
    padding: 25px 30px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    text-align: center;
    position: relative;
    width: 90%;
    max-width: 400px;
}

.close-modal-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal-btn:hover {
    color: #333;
}

#status-modal h3 {
    margin-top: 0;
    margin-bottom: 10px;
}
.modal-box h3, #status-modal h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

#status-modal p {
    margin-bottom: 20px;
}
.modal-box p, #status-modal p {
    margin-bottom: 25px;
    line-height: 1.6;
}


#status-modal .modal-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}
#confirm-modal-overlay .modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}
#alert-modal-overlay .modal-buttons {
    justify-content: center;
}

.modal-status-btn {
    font-family: 'Sarabun', sans-serif;
    font-size: 16px;
    font-weight: bold;
    padding: 15px;
    border: 2px solid transparent;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-status-btn:hover {
    opacity: 0.9;
    transform: scale(1.03);
}

/* ปุ่มสำหรับหน้าต่างยืนยัน */
.modal-action-btn {
    font-family: 'Sarabun', sans-serif;
    font-size: 16px;
    font-weight: bold;
    padding: 10px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-action-btn.ok {
    background-color: #dc3545; /* สีแดงสำหรับยืนยันการ Logout */
    color: white;
}
.modal-action-btn.ok:hover {
    background-color: #c82333;
}

.modal-action-btn.cancel {
    background-color: #f0f0f0;
    color: #333;
}
.modal-action-btn.cancel:hover {
    background-color: #e0e0e0;
}
/* ใช้สีเดียวกับสีกรอบรูป */
.modal-status-btn.status-present { background-color: #28a745; }
.modal-status-btn.status-absent  { background-color: #dc3545; }
.modal-status-btn.status-late    { background-color: #ffc107; }
.modal-status-btn.status-leave   { background-color: #17a2b8; }

header, nav, main, footer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
}

header {
    background-color: #005a8d;
    color: white;
    border-radius: 0 0 15px 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    padding-bottom: 25px;
}

h1 { margin: 0; }
h3, h4 { color: #005a8d; }

/* --- Staff Selection Area (เพิ่มใหม่) --- */
#staff-selection-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px; /* ลดช่องว่างเล็กน้อย */
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 15px;
    margin-top: 20px;
    max-width: 450px; /* เพิ่มความกว้างเล็กน้อย */
    margin-left: auto;
    margin-right: auto;
}

#staff-photo {
    width: 60px;
    height: 85px;
    border-radius: 10%;
    object-fit: cover;
    border: 3px solid #fff;
    background-color: #ccc;
}

.staff-details {
    text-align: left;
    flex-grow: 1; /* ทำให้ขยายเต็มพื้นที่ที่เหลือ */
}

.staff-details label {
    display: block;
    font-size: 14px;
    margin-bottom: 5px;
}

/* เปลี่ยนจาก select เป็น p */
#staff-name-display {
    font-size: 18px;
    font-weight: bold;
    margin: 0;
    color: #fff;
}

/* เพิ่มสไตล์ปุ่ม Logout */
#logout-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Sarabun', sans-serif;
    font-weight: bold;
    transition: background-color 0.2s;
}
#logout-btn:hover {
    background-color: #c82333;
}

/* --- Navigation Buttons --- */
/* --- Navigation Buttons (แก้ไขส่วนนี้) --- */
nav {
    position: -webkit-sticky; /* สำหรับ Safari */
    position: sticky;
    top: 0;
    background-color: #f4f7f6; /* เพิ่มสีพื้นหลังเพื่อไม่ให้เนื้อหาข้างใต้ทะลุ */
    z-index: 900; /* ทำให้แสดงอยู่ชั้นบนสุดเสมอ */
    padding-top: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
nav h2 {
    margin-top: 0;
    margin-bottom: 10px;
}
.grade-btn {
    font-family: 'Sarabun', sans-serif;
    font-size: 16px;
    padding: 10px 25px;
    margin: 5px;
    border: 2px solid #0077b6;
    background-color: #ffffff;
    color: #0077b6;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}
.grade-btn:hover, .grade-btn.active {
    background-color: #0077b6;
    color: white;
    transform: translateY(-2px);
}

/* --- Attendance Sections --- */
#attendance-section {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 20px;
}

.section-container {
    background-color: #ffffff;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.section-container h4 {
    text-align: left;
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

/* --- Student Grid --- */
.student-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    min-height: 100px;
}

/* --- Student Card (แก้ไขส่วนนี้) --- */
.student-card {
    font-size: 10px; /*ปรับขนาดของข้อความ "ห้อง:... "*/
    background-color: white;
    border: 5px solid #cccccc;
    border-radius: 15px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex; /* ใช้ Flexbox เพื่อจัดเรียงเนื้อหา */
    flex-direction: column;
}
.student-card:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.student-card img {
    width: 100%;
    /* --- ส่วนที่สำคัญที่สุด --- */
    aspect-ratio: 1 / 1; /* ทำให้เป็นสี่เหลี่ยมจัตุรัสเสมอ */
    object-fit: cover;
    border-radius: 10px;
    background-color: #eee;
}
/* ส่วนใหม่สำหรับจัดกลุ่มข้อมูลใต้ภาพ */
.card-details {
    padding-top: 10px;
    flex-grow: 1; /* ทำให้ส่วนนี้ขยายเต็มพื้นที่ที่เหลือ */
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* ดันไอคอนโทรศัพท์ไปไว้ล่างสุด */
}
.student-card p {
    margin: 0;
    font-weight: bold;
    font-size: 11px;/*ปรับขนาดของข้อความ "ชื่อนักเรียน "*/
    word-wrap: break-word; /* ตัดคำถ้าชื่อยาว */
}

/* ส่วนใหม่สำหรับเลขห้องและไอคอน กรณีอยากได้ไอคอนที่สำหรับกดโทรออก
.room-number {
    font-size: 13px;
    color: #666;
    margin-top: 4px;
}

.phone-icons {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.phone-icon {
    display: inline-block;
    color: #0077b6;
    transition: color 0.2s;
}

.phone-icon:hover {
    color: #005a8d;
}

.phone-icon svg {
    width: 22px;
    height: 22px;
}*/

/* ส่วนใหม่สำหรับส่วนติดต่อ */
.contact-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: flex-start; /* เปลี่ยนเป็น flex-start เพื่อจัดชิดซ้าย */
    gap: 5px; /* เพิ่มช่องว่างระหว่าง "ติดต่อ :" กับปุ่ม */
}

.contact-label {
    font-size: 10px;
    color: #333;
    font-weight: bold;
}

.contact-buttons {
    display: flex;
    gap: 3px;
}

.contact-btn {
    font-family: 'Sarabun', sans-serif;
    font-size: 7px;
    padding: 4px 8px;
    background-color: #0077b6;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.2s;
}

.contact-btn:hover {
    background-color: #00800b;
}


/* --- Status Colors --- */
.status-มา   { border-color: #28a745; } /* เขียว */
.status-ขาด  { border-color: #dc3545; } /* แดง */
.status-สาย  { border-color: #ffc107; } /* เหลือง */
.status-ลา   { border-color: #17a2b8; } /* ฟ้า */

/* --- Confirm Button --- */
.confirm-container { margin-top: 30px; }
#confirm-btn {
    font-family: 'Sarabun', sans-serif;
    font-size: 18px;
    font-weight: bold;
    padding: 15px 20px;
    border: none;
    background-color: #28a745;
    color: white;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
}
#confirm-btn:hover {
    background-color: #218838;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.4);
}
#confirm-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

footer {
    margin-top: 40px;
    color: #888;
    font-size: 14px;
    padding-bottom: 60px; /* เพิ่มพื้นที่ด้านล่างเผื่อปุ่ม */
}


/* --- Clear Storage Button (เพิ่มใหม่) --- */
#clear-storage-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
}
#clear-storage-btn {
    font-family: 'Sarabun', sans-serif;
    font-size: 14px;
    color: #888;
    text-decoration: none;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid #ddd;
    transition: all 0.2s;
}
#clear-storage-btn:hover {
    color: #dc3545; /* Red color on hover */
    border-color: #dc3545;
    background-color: #fff;
}


.back-link {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 20px;
    background-color: #6c757d;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.2s;
}
.back-link:hover {
    background-color: #5a6268;
}



.copy-report-container {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}
#copy-report-btn {
    font-family: 'Sarabun', sans-serif;
    font-size: 10px;
    font-weight: bold;
    padding: 5px 2px;
    border: 1px solid #ddd;
    background-color: rgba(255, 255, 255, 0.8);
    color:  #0077b6;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}
#copy-report-btn:hover {
    background-color: #cfe7fa;
}
#copy-report-btn.copied {
    background-color: #17b847;
    color: white;
    border-color: #17a2b8;
}


