/* style.css */

/* 1. นำเข้าฟอนต์ Kanit จาก Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;600;700&display=swap');

/* 2. การตั้งค่าพื้นฐาน */
body {
    font-family: 'Kanit', sans-serif; /* ใช้ Kanit เป็นฟอนต์หลัก */
    background-color: #eef2f7; /* สีพื้นหลังอ่อนโยน */
    color: #333;
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 30px auto;
    background: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08); /* เงาให้ดูมีมิติ */
}

/* 3. ส่วนหัว (Headings) */
h1, h2, h3 {
    font-weight: 600;
    color: #007bff; /* สีน้ำเงินสำหรับหัวข้อ */
    border-bottom: 3px solid #007bff33;
    padding-bottom: 10px;
    margin-top: 20px;
}

h1 { font-size: 2.2em; }
h2 { font-size: 1.8em; }

/* 4. ฟอร์มและองค์ประกอบอินพุต */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 400;
    color: #555;
}

input[type="text"], 
input[type="number"], 
input[type="password"],
input[type="month"],
select, 
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box;
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: 'Kanit', sans-serif;
    font-size: 1em;
}

input:focus, select:focus, textarea:focus {
    border-color: #007bff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
    outline: none;
}

/* 5. ปุ่ม (Buttons) */
.btn-submit, button[type="submit"], button {
    background-color: #007bff;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: background-color 0.3s, transform 0.1s;
    font-family: 'Kanit', sans-serif;
    display: inline-block; /* ทำให้ปุ่ม Admin ดูดีขึ้น */
}

.btn-submit:hover, button[type="submit"]:hover, button:hover {
    background-color: #0056b3;
}

/* ปุ่มสำหรับ Admin */
.btn-login { background-color: #28a745; }
.btn-login:hover { background-color: #1e7e34; }

/* 6. ลิงก์และข้อความเสริม */
.admin-link {
    float: right;
    font-weight: 600;
    color: #6c757d;
    text-decoration: none;
    padding: 5px 10px;
    border: 1px solid #6c757d;
    border-radius: 4px;
    transition: background-color 0.3s;
}
.admin-link:hover {
    background-color: #f8f9fa;
    color: #333;
}

a {
    color: #007bff;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* 7. ตาราง (Tables) */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background-color: #fdfdfd;
}

th, td {
    border: 1px solid #e9ecef;
    padding: 12px;
    text-align: left;
    font-size: 0.95em;
}

th {
    background-color: #e9f2ff;
    color: #007bff;
    font-weight: 600;
}

tr:nth-child(even) {
    background-color: #f7f7f7;
}

tr:hover {
    background-color: #e9e9e9;
}

/* 8. สถานะ (Status Badges) */
.status-pending, .status-approved {
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    display: inline-block;
}

.status-pending { 
    color: #9c6500; 
    background-color: #fff3cd; 
} /* สีเหลืองอำพัน */

.status-approved { 
    color: #0c6e00; 
    background-color: #d4edda; 
} /* สีเขียว */

/* 9. ข้อความแจ้งเตือน (Errors/Success) */
.error { 
    color: white; 
    background-color: #dc3545; 
    padding: 10px; 
    border-radius: 6px; 
    text-align: center;
    font-weight: 600;
}
.success {
    color: white;
    background-color: #28a745;
    padding: 10px;
    border-radius: 6px; 
    text-align: center;
    font-weight: 600;
}

/* 10. Login Page Specific (สำหรับ login.php) */
.login-container {
    max-width: 400px; 
    margin: 150px auto; 
    padding: 30px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08); 
}

/* ======================================= */
/* 9. Media Queries: สำหรับหน้าจอโทรศัพท์ */
/* ======================================= */

@media (max-width: 600px) {
    
    /* 9.1 Container หลัก */
    .container {
        margin: 10px; /* ลด margin ด้านข้าง */
        padding: 15px; /* ลด padding ภายใน */
        width: auto; /* กำหนดให้ปรับความกว้างอัตโนมัติ */
        max-width: 100%; /* ไม่ให้เกินความกว้างหน้าจอ */
    }

    /* 9.2 หัวข้อและลิงก์ */
    h1 { font-size: 1.8em; }
    h2 { font-size: 1.5em; }
    
    .admin-link {
        float: none; /* ยกเลิก float */
        display: block; /* ให้ขึ้นบรรทัดใหม่ */
        margin-bottom: 15px;
        text-align: center;
    }
    
    /* 9.3 ปุ่ม (เพื่อให้ใหญ่ขึ้นและกดง่าย) */
    .btn-submit, button[type="submit"], button {
        padding: 10px 15px;
        font-size: 1em;
        width: 100%; /* ให้เต็มความกว้าง */
        margin-top: 10px;
        box-sizing: border-box;
    }
    
    /* 9.4 ตาราง (สำคัญมากสำหรับหน้าจอเล็ก) */
    table, thead, tbody, th, td, tr { 
        display: block; /* ทำให้ทุกองค์ประกอบเป็นบล็อก */
    }
    
    /* ซ่อนส่วนหัวตารางเดิม */
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    /* จัดการแถวแต่ละแถว */
    tr {
        border: 1px solid #ccc;
        margin-bottom: 10px;
        display: block; 
        padding: 10px;
        border-radius: 6px;
    }
    
    /* จัดการเซลล์แต่ละเซลล์ */
    td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%; /* เว้นที่ให้สำหรับ Label ใหม่ */
        text-align: right;
    }
    
    /* เพิ่ม Label ที่สร้างจาก data-label attribute (Admin/Index) */
    td:before {
        content: attr(data-label);
        position: absolute;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 600;
        color: #007bff;
    }

    /* สำหรับหน้า Login */
    .login-container {
        margin: 50px auto;
    }
}