/* ====== Reset and Base Styles ====== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    font-family: 'Roboto', sans-serif;
    background-color: #F5F7FA;
    color: #333;
    margin: 0;
    -webkit-overflow-scrolling: touch;
}

body::-webkit-scrollbar {
    display: none;
}

body {
    scrollbar-width: none;
}

/* ====== Navbar Styles ====== */
#mainNav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 999;
    background: linear-gradient(to bottom, #5AC8FA, #3A75C4);
}

.navbar-collapse {
    display: none !important;
}
.navbar-collapse.show {
    display: block !important;
}

@media (max-width: 991px) {
    .navbar-collapse {
        display: none !important;
    }
    .navbar-collapse.show {
        display: block !important;
    }
}

#mainNav .container {
    padding: 5px 10px;
}
#mainNav .container img {
    margin-bottom: 0;
}

.navbar-light .navbar-nav .nav-link:link,
.navbar-light .navbar-nav .nav-link:visited {
    color: #fff;
}
.navbar-light .navbar-nav .nav-link:hover,
.navbar-light .navbar-nav .nav-link:active {
    color: lightgray;
}

.navbar-brand {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    max-width: 100%;
    padding: 5px;
}

.navbar-brand img {
    width: 40px;
    height: 50px;
    margin-right: 8px;
    object-fit: contain;
}

.navbar-text h1, .navbar-text h2 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    line-height: 1.2;
    color: #fff;
}

.navbar-text h1 {
    font-size: calc(18px + (24 - 18) * ((100vw - 320px)/(1600 - 320)));
    font-weight: bold;
}

.navbar-text h2 {
    font-size: calc(14px + (18 - 14) * ((100vw - 320px)/(1600 - 320)));
    font-weight: normal;
    font-style: italic;
}

@media (min-width: 1200px) {
    #mainNav li.nav-item {
        margin-left: 40px;
    }
}

@media (max-width: 1199px) {
    #mainNav li.nav-item {
        margin-bottom: 4px; /* ลดระยะห่างจาก 20px */
    }
}

@media (max-width: 991px) {
    .navbar-brand img {
        width: 30px;
        height: 38px;
        margin-right: 5px;
    }
    .navbar-light .navbar-brand {
        padding: 5px !important;
    }
    .navbar-text {
        flex: 1;
        padding: 0;
        margin: 0;
    }
    .navbar-light .navbar-brand .navbar-text h1 {
        font-size: 11px !important;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 180px;
        margin: 0;
    }
    .navbar-light .navbar-brand .navbar-text h2 {
        font-size: 9px !important;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 180px;
        margin: 0;
    }
    #mainNav {
        min-height: 50px;
    }
    .navbar-nav .nav-item {
        margin-bottom: 4px !important;
    }
    .navbar-nav .nav-link {
		font-size: 13px !important; /* ขนาดฟอนต์ทั่วไป */
        padding: 3px 6px !important;
        line-height: 1.1;
    }
    .navbar-collapse {
        padding: 0 !important;
    }
    .navbar-nav {
        margin: 0 !important;
    }
}

@media (max-width: 991px) and (orientation: landscape) {
    .navbar-brand img {
        width: 28px;
        height: 35px;
        margin-right: 5px;
    }
    .navbar-light .navbar-brand .navbar-text h1 {
        font-size: 10px !important;
        max-width: 250px;
    }
    .navbar-light .navbar-brand .navbar-text h2 {
        font-size: 8px !important;
        max-width: 250px;
    }
    .navbar-nav .nav-item {
        margin-bottom: 3px !important;
    }
    .navbar-nav .nav-link {
        padding: 3px 6px !important;
    }
}

@media (max-width: 767px) {
    .navbar-text h1 {
        font-size: 15px !important;
    }
    .navbar-text h2 {
        font-size: 12px !important;
    }
    .navbar-brand img {
        width: 30px;
        height: 38px;
    }
}
/*ขนาดมือถือเรา */
@media (max-width: 400px) {
    .navbar-brand img {
        width: 25px;
        height: 38px;
        margin-right: 3px;
    }
    .navbar-light .navbar-brand .navbar-text h1 {
        font-size: 13px !important;
        max-width: 250px;
    }
    .navbar-light .navbar-brand .navbar-text h2 {
        font-size: 10px !important;
        max-width: 150px;
    }
    .navbar-nav .nav-item {
        margin-bottom: 3px !important;
    }
}

nav.navbar.navbar-dark.bg-dark {
    background-color: darkblue !important;
}
nav.navbar.navbar-light.bg-light {
    background: linear-gradient(to bottom, #5AC8FA, #3A75C4) !important;
    color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#mainNav li.nav-item a {
    font-size: large;
    font-weight: bold;
}
#mainNav li.nav-item a.btn {
    padding: 6px 20px;
    font-weight: normal;
}

/* ====== Body Section ====== */
.body-section {
    margin-top: 192px;
    height: auto;
    background: linear-gradient(192deg, #F5F7FA 0%, #E9ECEF 100%);
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    scrollbar-width: none;
}

/* ปุ่มกด บันทึกข้อมูล, รายละเอียดการสอน, เนื้อหาล่าสุด */
.student-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.student-buttons button {
    font-size: 16px;
    padding: 10px 20px;
    flex: 1 1 auto;
    max-width: 200px;
}

/* ====== Student List Section ====== */
#studentListSection {
    flex: 1;
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    overflow: auto;
    margin: 120px auto 200px auto;
}

#studentList {
    width: 100%;
    height: 100%;
}

.student-table {
    width: 100%;
    min-height: 100%;
    border-collapse: collapse;
    font-size: 16px;
}

.student-table th, .student-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
}

.student-table th:nth-child(2), .student-table td:nth-child(2) {
    text-align: left;
}

.student-table th {
    background-color: #f2f2f2;
    position: sticky;
    top: 0;
    z-index: 1;
}

.student-table tr.present {
    background-color: #d4edda;
}

.student-table tr.absent {
    background-color: #f8d7da;
}

.student-table tr.leave {
    background-color: #fff3cd;
}

.table-container {
    width: 100%;
    overflow-x: auto;
}

/* ====== Teaching Details Form ====== */
#teaching-details-form-container {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 500px;
    z-index: 1100;
    overflow-y: auto;
    max-height: 80vh;
}

#teaching-details-form-container h3 {
    margin-top: 0;
}

#teaching-details-form label {
    display: block;
    margin: 10px 0 5px;
}

#teaching-details-form input[type="text"],
#teaching-details-form textarea,
#teaching-details-form input[type="date"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

#teaching-details-form textarea {
    height: 100px;
    resize: vertical;
}

#teaching-details-form input[type="radio"] {
    margin: 0 10px 0 20px;
}

#obstacles-section {
    display: none;
}

#teaching-details-form .form-buttons {
    margin-top: 20px;
    text-align: right;
}

#teaching-details-form .form-buttons button {
    padding: 8px 16px;
    margin-left: 10px;
}

#overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

/* ====== Buttons ====== */
button.save-button, button.teaching-details-button {
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
}
button.latest-button {
    padding: 10px 20px;
    background-color: #ffc107 !important;
    color: #000;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 10px;
    font-size: 14px;
}

button.latest-button:hover {
    background-color: #e0a800;
}

button.save-button:hover, button.teaching-details-button:hover {
    background-color: #0056b3;
}

button.teaching-details-button {
    background-color: #28a745;
}

button.teaching-details-button:hover {
    background-color: #218838;
}

.check-work {
    padding: 8px 16px;
    background-color: #ffc107;
    color: #000;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

/* ====== Camera Section ====== */
.camera-section {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 5000;
    overflow-y: auto;
    padding-top: 100px;
    box-sizing: border-box;
}

.camera-section .container {
    width: 100%;
    padding: 0 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100%;
}

.camera-section header {
    width: 100%;
    background-color: #fff;
    text-align: center;
    padding: 10px 0;
    position: sticky;
    top: 20px;
    z-index: 5100;
}

.camera-section h2#selected-subject-name {
    font-size: 16px;
    color: #333;
    margin: 5px 0;
}

.camera-section video#camera-preview {
    width: 100%;
    height: auto;
    display: block;
    margin: 30px auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
}

.camera-section img#photo-preview,
.camera-section canvas#photo-canvas {
    width: 100%;
    height: auto;
    display: block;
    margin: 30px auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
}

.camera-section video#camera-preview {
    display: block;
}

.camera-section img#photo-preview,
.camera-section canvas#photo-canvas {
    display: none;
}

.camera-section .photo-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 15px 0;
    width: 100%;
}

.camera-section .button-container {
    display: flex;
    flex-direction: row;
    gap: 10px;
    width: 100%;
    max-width: 200px;
    justify-content: center;
}

.camera-section .button-container button {
    padding: 10px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    width: 100%;
}

.camera-section .button-container button#retake-btn {
    background-color: #dc3545;
}

.camera-section .button-container button#upload-btn {
    background-color: #28a745;
}

.camera-section .button-container button:hover {
    opacity: 0.9;
}

/* ====== Footer Styles ====== */
footer.container-fluid {
    text-align: center;
    color: #fff;
    background: linear-gradient(to bottom, #5AC8FA, #3A75C4);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    height: 50px;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
}

@media (min-width: 768px) {
    footer {
        padding: 2% 8%;
    }
}
@media (max-width: 767px) {
    footer {
        padding: 8% 8% 12%;
    }
}

footer h4, footer h5,
footer ul.footer-icons li, footer ul.footer-icons li a,
footer p, footer p a {
    color: #fff;
}

footer h4 {
    font-weight: normal;
    font-size: calc(26px + (48 - 26) * ((100vw - 320px)/(1600 - 320)));
    margin: 0 auto 16px 0;
}

footer h5 {
    font-weight: normal;
    font-style: italic;
    margin: 0 auto 36px auto;
    font-size: calc(20px + (32 - 20) * ((100vw - 320px)/(1600 - 320)));
}

footer ul.footer-links, footer ul.footer-icons {
    text-align: center;
    margin: 0 auto 48px auto;
    padding-left: 0;
    list-style-type: none;
}

footer ul.footer-links li,
footer ul.footer-icons li {
    display: inline-block;
    margin-right: 32px;
}

footer ul.footer-links li:last-child,
footer ul.footer-icons li:last-child {
    margin-right: 0;
}

footer ul.footer-links li a {
    color: #fff;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    padding-bottom: 2px;
    font-size: calc(17px + (20 - 17) * ((100vw - 320px)/(1600 - 320)));
}

footer ul.footer-links li a:hover,
footer ul.footer-links li a:active {
    border-bottom-color: #fff;
}

footer ul.footer-icons li a i {
    font-size: calc(22px + (28 - 22) * ((100vw - 320px)/(1600 - 320)));
}

footer ul.footer-icons li a:hover,
footer ul.footer-icons li a:active {
    color: #fff1e5;
}

footer p a, a.privacy-legal {
    color: #fff;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    padding-bottom: 2px;
    font-size: calc(15px + (18 - 15) * ((100vw - 320px)/(1600 - 320)));
    font-family: sans-serif;
    display: inline-block;
}

a.privacy-legal:hover, a.privacy-legal:active,
footer p a:hover, footer p a:active {
    border-bottom-color: #fff;
}