/* General Body Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f4f7f6;
    margin: 0;
    color: #333;
}

/* Container หลักคุมความกว้างทั้งเว็บ */
.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 0;
}

h1, h2 {
    color: #2c3e50;
}

/* Navbar Styles */
.navbar {
    background-color: #2c3e50;
    color: #fff;
    padding: 10px 0;
    margin-bottom: 20px;
    width: 100%; 
}
.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-direction: row; 
}
.navbar .brand {
    font-size: 1.5em;
    font-weight: bold;
    color: #fff;
    text-decoration: none;
    line-height: 1; 
}
.navbar .brand .version {
    display: block; 
    font-size: 0.6em; 
    font-weight: normal; 
    color: #bdc3c7; 
    margin-top: 2px;
}
.navbar ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
}
.navbar ul li {
    margin-left: 20px;
}
.navbar ul li a {
    color: #fff;
    text-decoration: none;
    font-size: 1em;
}

/* Navbar Dropdown Styles */
.navbar ul li span { padding: 0 15px; color: #ecf0f1; }
.dropdown { position: relative; display: inline-block; }
.dropdown-content { display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 999; border-radius: 4px; }
.dropdown-content a { color: black !important; padding: 12px 16px; text-decoration: none; display: block; }
.dropdown-content a:hover { background-color: #f1f1f1; }
.dropdown:hover .dropdown-content { display: block; }

/* KPI Card Styles */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.kpi-card {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 20px;
    text-align: center;
}
.kpi-card h2 {
    margin-top: 0;
    font-size: 1.2em;
    color: #34495e;
}
.kpi-card p {
    font-size: 2em;
    font-weight: bold;
    color: #2980b9;
    margin: 10px 0 0 0;
}

/* Filter Form Styles */
.filter-form {
    background-color: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

/* Data Table and Form Container Styles */
.main-content {
    margin-top: 30px;
    width: 100%;
}

/* [แก้ไข] ขยายความกว้างเต็ม 100% เพื่อให้อิงตามความกว้างของ .container (1200px) */
.data-table-container {
    background-color: #fff;
    padding: 25px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 30px;
    box-sizing: border-box;
}

/* คลาสเสริมสำหรับกระชับหน้าฟอร์มกรอกข้อมูลสั้นๆ ให้ไม่กว้างเกินไป */
.form-container {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.data-table-container h1, .data-table-container h2 {
    margin-top: 0;
    margin-bottom: 25px;
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}
table thead {
    background-color: #ecf0f1;
}
table th, table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}
table th {
    font-weight: bold;
    color: #34495e;
}
table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}
table tbody tr:hover {
    background-color: #f1f1f1;
}

/* Form Styles */
form label {
    font-weight: bold;
    color: #34495e;
    font-size: 1.05em;
}
form input[type="text"],
form input[type="date"],
form input[type="email"],
form input[type="number"],
form input[type="password"],
form select,
form textarea {
    width: 100%;
    padding: 12px; 
    font-size: 1em;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box; 
    margin-top: 5px;
}

/* Custom Button Styles */
button[type="submit"], .btn-danger {
    padding: 12px 20px;
    font-size: 1em;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    color: white;
    transition: background-color 0.2s ease-in-out;
}
.btn-primary {
    background-color: #3498db;
    border-color: #2980b9;
}
.btn-primary:hover {
    background-color: #2980b9;
}
.btn-success {
    background-color: #2ecc71;
    border-color: #27ae60;
}
.btn-success:hover {
    background-color: #27ae60;
}
.btn-danger {
    background-color: #e74c3c;
    border-color: #c0392b;
    padding: 8px 15px;
    text-decoration: none;
    font-size: 0.95em;
    display: inline-block;
}
.btn-danger:hover {
    background-color: #c0392b;
}

/* Wrapper for responsive tables */
.table-wrapper {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Sorting Arrow Styles */
th.sortable a {
    color: inherit;
    text-decoration: none;
    display: block;
    position: relative;
}
th.sortable a:hover {
    text-decoration: underline;
}
th.sortable a::after {
    content: " ▲";
    font-size: 0.8em;
    opacity: 0.2;
}
th.sortable a::before {
    content: " ▼";
    font-size: 0.8em;
    opacity: 0.2;
}
th.sorted-asc a::after {
    opacity: 1;
}
th.sorted-desc a::before {
    opacity: 1;
}

/* ========================================== */
/* RESPONSIVE DESIGN (สำหรับรองรับมือถือ)      */
/* ========================================== */
@media (max-width: 768px) {
    .container {
        width: 95%;
        padding: 10px 0;
    }
    .navbar .container {
        flex-direction: column;
        gap: 10px;
    }
    .navbar ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    .navbar ul li {
        margin-left: 0;
    }
    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-form input,
    .filter-form select,
    .filter-form button {
        width: 100% !important;
    }
    .data-table-container {
        padding: 15px;
    }
}