/* style.css */
/* ไฟล์นี้เก็บ CSS สำหรับระบบ Booking ทั้งหมด */

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f4f7f6;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    font-size: 0.9em; /* ลดขนาด font ทั้งหมดลง 1em ตามที่ร้องขอ */
}

/* Base container styling - now only for centering */
.page-container {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    margin: 0 auto; /* Center the container */
}

/* Specific width for smaller pages (index, book, login, alter_table, sqlite_test) */
.small-page-width {
    max-width: 600px;
}

/* Specific width for medium pages (admin) */
.medium-page-width {
    max-width: 1000px;
}

/* Specific width for larger pages (report) */
.large-page-width {
    max-width: 1200px;
}

h1 {
    color: #333;
    text-align: center; /* Ensure h1 remains centered */
    margin-bottom: 25px;
    font-size: 2.2em;
}
h2 {
    color: #007bff;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
    margin-top: 30px;
    margin-bottom: 20px;
    font-size: 1.8em;
}
h3 {
    color: #555;
    margin-top: 25px;
    margin-bottom: 15px;
    font-size: 1.4em;
}
.section {
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 10px;
    background-color: #f9f9f9;
}
.form-group {
    margin-bottom: 20px;
}
label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
    text-align: left; /* Ensure labels are left-aligned */
}
input[type="date"],
input[type="text"],
input[type="number"],
input[type="tel"],
input[type="password"],
select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 1em;
    transition: border-color 0.3s;
}
input[type="date"]:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
select:focus {
    border-color: #007bff;
    outline: none;
}
button {
    padding: 12px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease;
    margin-right: 10px;
}
button:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}
button.status-btn {
    padding: 8px 12px;
    font-size: 0.85em;
    border-radius: 5px;
    margin-right: 5px;
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
}
button.status-btn.pending { background-color: #6c757d; } /* Grey */
button.status-btn.pending:hover { background-color: #5a6268; }
button.status-btn.followed_up { background-color: #17a2b8; } /* Info blue */
button.status-btn.followed_up:hover { background-color: #138496; }
button.status-btn.confirm { background-color: #28a745; } /* Green */
button.status-btn.confirm:hover { background-color: #218838; }
button.status-btn.forfeit { background-color: #dc3545; } /* Red */
button.status-btn.forfeit:hover { background-color: #c82333; }

button.delete { /* สำหรับ admin.php, sqlite_test.php, report.php */
    background-color: #dc3545;
}
button.delete:hover {
    background-color: #c82333;
}
button.edit { /* สำหรับ admin.php, sqlite_test.php */
    background-color: #28a745; /* Green */
    color: white;
}
button.edit:hover {
    background-color: #218838; /* Darker green on hover */
}
.submit-btn { /* สำหรับ sqlite_test.php */
    width: auto;
    padding: 10px 20px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: background-color 0.3s ease;
}
.submit-btn:hover {
    background-color: #218838;
}

/* Search and Export buttons */
.search-group {
    display: flex;
    align-items: flex-end; /* Align button with input */
    gap: 10px;
}
.search-group input[type="text"] {
    flex-grow: 1; /* Allow input to take available space */
}
.search-button {
    width: auto; /* Override full width for search button */
    padding: 12px 20px;
    background-color: #007bff;
    color: white;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease;
}
.search-button:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

.report-actions {
    text-align: right;
    margin-bottom: 15px;
}
.export-button {
    width: auto;
    background-color: #17a2b8; /* Info blue for export */
    padding: 10px 20px;
    font-size: 1em;
}
.export-button:hover {
    background-color: #138496;
}


.message {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 8px;
    text-align: center; /* Ensure message remains centered */
    font-weight: bold;
}
.message p {
    margin: 0;
}
.message p[style*="green"] {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.message p[style*="orange"] {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}
.message p[style*="red"] {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
/* New responsive table container */
.responsive-table-container {
    overflow-x: auto; /* Allows horizontal scrolling */
    -webkit-overflow-scrolling: touch; /* Improves scrolling on iOS */
    margin-top: 20px; /* Add some space above the table */
}

table {
    width: 100%; /* Ensure table takes full width of its container */
    min-width: 1000px; /* Minimum width to prevent content from collapsing too much */
    border-collapse: collapse;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden; /* เพื่อให้ border-radius ทำงานกับตาราง */
}
th, td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
    font-size: 1em;
    white-space: nowrap; /* Prevent text wrapping in cells by default */
}
th a { /* Styling for sortable headers */
    text-decoration: none;
    color: #333;
    display: block;
    width: 100%;
    height: 100%;
}
th a:hover {
    color: #007bff;
}
th {
    background-color: #e9ecef;
    color: #333;
    font-weight: bold;
}
tr:nth-child(even) {
    background-color: #f6f6f6;
}
tr:hover {
    background-color: #e2f0ff;
}
.schedule-actions, .actions { /* สำหรับ admin.php, sqlite_test.php */
    display: flex;
    gap: 5px;
    justify-content: flex-end;
}
.schedule-actions button, .actions button { /* สำหรับ admin.php, sqlite_test.php */
    margin: 0;
    padding: 8px 12px;
    font-size: 0.85em;
}
.back-link {
    text-align: center; /* Ensure back-link remains centered */
    margin-top: 30px;
}
.back-link a {
    color: #007bff;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s;
}
.back-link a:hover {
    color: #0056b3;
    text-decoration: underline;
}

.admin-link { /* สำหรับ index.php */
    margin-top: 30px;
}
.admin-link a {
    background-color: transparent;
    color: #007bff;
    border: 1px solid #007bff;
    padding: 10px 20px;
    font-size: 0.9em;
}
.admin-link a:hover {
    background-color: #e0f0ff;
    color: #0056b3;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .page-container {
        margin: 10px;
        padding: 20px;
    }
    h1 {
        font-size: 1.8em;
    }
    h2 {
        font-size: 1.5em;
    }
    h3 {
        font-size: 1.2em;
    }
    button {
        font-size: 1em;
        padding: 10px 15px;
        margin-right: 5px;
    }
    .schedule-actions, .actions {
        flex-direction: column;
        gap: 10px;
    }
    .schedule-actions button, .actions button {
        width: 100%;
    }
    table {
        font-size: 0.85em;
        min-width: unset; /* Remove min-width on small screens */
    }
    th, td {
        padding: 8px;
        white-space: normal; /* Allow text wrapping in cells on small screens */
    }
    .search-group {
        flex-direction: column; /* Stack search input and button vertically */
        align-items: stretch;
    }
    .search-group input[type="text"], .search-button {
        width: 100%;
        margin-right: 0; /* Remove right margin */
    }
    .report-actions {
        text-align: center; /* Center export button on small screens */
    }
}

/* Print-specific styles (สำหรับ report.php) */
@media print {
    body {
        font-size: 0.6em; /* ลดขนาด font ทั้งหมดลงอีกสำหรับพิมพ์ */
        margin: 0;
        padding: 0;
        background-color: white;
    }
    .page-container {
        box-shadow: none;
        border: none;
        padding: 10mm;
        max-width: none;
        width: auto;
    }
    h1, h2, h3 {
        color: #000 !important;
        border-bottom-color: #ccc !important;
    }
    /* Hide elements not needed for printing */
    .section .filter-form, /* ซ่อนฟอร์มเลือกวันที่ */
    .message,
    .back-link,
    .follow-up-status-col, /* ซ่อนคอลัมน์สถานะติดตาม */
    .follow-up-by-col, /* ซ่อนคอลัมน์ผู้ติดตาม */
    .status-actions-col, /* ซ่อนคอลัมน์จัดการสถานะ */
    .status-btn,
    .report-actions { /* ซ่อนปุ่มส่งออก CSV สำหรับพิมพ์ */
        display: none;
    }
    .responsive-table-container {
        overflow-x: visible; /* Disable horizontal scrolling for print */
    }
    table {
        font-size: 0.9em; /* ขนาด font ในตารางสำหรับพิมพ์ */
        border: 1px solid #000;
    }
    th, td {
        border: 1px solid #000;
        padding: 5px;
    }
    .status-text {
        display: inline; /* ตรวจสอบให้แน่ใจว่าข้อความสถานะยังแสดงอยู่ */
        font-weight: bold;
    }
}
