/* =========================================================
   ธีมหน้าเนื้อหา (ใช้ไฟล์นี้ร่วมกันทุกหน้า)
   ใช้กับ: Schedule, 01, 02, 03, 04, 06, 07, 08, 10, 12
   แบนเนอร์หัวหน้า: component/08-page-banner.php
   Footer: component/05-footer.php
   ========================================================= */

div.container {
    max-width: 1200px;
}

/* ---------- พื้นหลังหน้า + ดัน footer ลงล่างสุดเสมอ (หน้าที่เนื้อหาน้อย) ---------- */
body.page-modern {
    background-color: #f6f1ea;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
body.page-modern > .container-fluid,
body.page-modern > .container {
    width: 100%;
}

/* ---------- แบนเนอร์หัวหน้า ---------- */
.page-banner {
    margin-top: 20px;
}
.page-banner img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(62, 39, 35, 0.10);
    background: #fbf6ee;
}

/* ---------- พื้นที่เนื้อหา ---------- */
.page-body {
    flex: 1 0 auto;
    margin-top: 20px;
    padding-bottom: 40px;
}

/* ---------- กล่องหลัก ---------- */
.doc-panel {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(62, 39, 35, 0.08), 0 2px 6px rgba(62, 39, 35, 0.05);
    overflow: hidden;
}
.doc-panel-header {
    background: #fff;
    color: #4e342e;
    padding: 16px 20px;
    border-bottom: 1px solid #f0e9e4;
}
.doc-panel-header h5 {
    margin: 0;
    font-weight: 700;
    font-size: 1.05rem;
}
.doc-panel-header h5 i {
    color: #8d6e63;
}
.doc-panel-header .form-select {
    border-radius: 10px;
    border: 1px solid #d7ccc8;
    background-color: #fbf8f6;
    min-width: 220px;
    max-width: 320px; /* กันชื่อทีมยาว ๆ ทำให้ช่องเลือกปีกว้างเกิน */
    text-overflow: ellipsis;
}
.doc-panel-header .form-select:focus {
    border-color: #8d6e63;
    box-shadow: 0 0 0 3px rgba(141, 110, 99, 0.2);
}
.doc-panel-header .header-label {
    font-size: 0.8rem;
    opacity: 0.85;
    margin-right: 4px;
}
.doc-panel-body {
    padding: 20px;
}

/* ---------- แถบค้นหา (หน้าแบบการ์ด) ---------- */
.panel-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.panel-search {
    position: relative;
}
.panel-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #a1887f;
    font-size: 0.85rem;
}
.panel-search input {
    border: 1px solid #d7ccc8;
    border-radius: 8px;
    padding: 6px 12px 6px 34px;
    min-width: 260px;
    outline: none;
}
.panel-search input:focus {
    border-color: #8d6e63;
    box-shadow: 0 0 0 3px rgba(141, 110, 99, 0.2);
}
.panel-count {
    color: #8d6e63;
    font-size: 0.85rem;
}
.panel-empty {
    text-align: center;
    color: #8d6e63;
    padding: 40px 0;
}
.panel-empty i {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
    opacity: 0.6;
}

/* ---------- การ์ด ---------- */
.media-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #efebe9;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}
.media-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(93, 64, 55, 0.15);
}
.media-thumb {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    background-color: #efebe9;
    overflow: hidden;
    border: 0;
    padding: 0;
}
/* แสดงภาพเต็มไม่ครอป และไม่ขยายภาพเกินขนาดจริง (ภาพคมชัด) */
.media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #faf7f5;
}
.media-thumb.is-cover img {
    object-fit: cover;
}
.media-thumb.is-portrait {
    aspect-ratio: 3 / 4;
}
.media-thumb.is-square {
    aspect-ratio: 1 / 1;
}
.media-thumb.is-contain img {
    object-fit: contain;
    background: #fff;
}
button.media-thumb {
    cursor: zoom-in;
}
.media-body {
    padding: 8px 10px 4px;
    flex: 1;
}
.media-body .group-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
}
.media-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: #333;
    margin: 0 0 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}
.media-footer {
    padding: 4px 10px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.media-footer .btn-read {
    font-size: 0.72rem;
    padding: 4px 10px;
    gap: 4px;
}

/* ---------- ป้าย / ปุ่ม ---------- */
.col-no {
    color: #9e9e9e;
    width: 40px;
}
.doc-title {
    font-weight: 500;
    color: #333;
}
.group-badge {
    display: inline-block;
    background-color: #f3e5dc;
    color: #6d4c41;
    font-size: 0.78rem;
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
}
.year-text {
    white-space: nowrap;
    color: #555;
}
.btn-read {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: #6d4c41;
    color: #fff !important;
    font-size: 0.8rem;
    padding: 6px 14px;
    border-radius: 20px;
    border: 0;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s, transform 0.2s;
}
.btn-read:hover {
    background-color: #4e342e;
    transform: translateY(-1px);
}
.btn-read.btn-outline {
    background-color: #fff;
    color: #6d4c41 !important;
    border: 1px solid #8d6e63;
}
.btn-read.btn-outline:hover {
    background-color: #efebe9;
}

/* ---------- ตาราง ---------- */
.doc-table thead th {
    background-color: #efebe9;
    color: #4e342e;
    font-weight: 700;
    border-bottom: 2px solid #8d6e63 !important;
    white-space: nowrap;
}
.doc-table tbody tr {
    transition: background-color 0.15s;
}
.doc-table tbody tr:hover {
    background-color: #fbf6f2 !important;
}
.doc-table td {
    vertical-align: middle;
}

/* ---------- ปรับ DataTables ให้เข้าธีม ---------- */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid #d7ccc8;
    border-radius: 8px;
    padding: 5px 10px;
    outline: none;
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: #8d6e63;
    box-shadow: 0 0 0 3px rgba(141, 110, 99, 0.2);
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: #6d4c41 !important;
    border-color: #6d4c41 !important;
    color: #fff !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #efebe9 !important;
    border-color: #d7ccc8 !important;
    color: #4e342e !important;
}
.dataTables_wrapper .dataTables_info {
    color: #8d6e63;
    font-size: 0.85rem;
}
table.dataTable.no-footer {
    border-bottom: 1px solid #efebe9;
}

/* ---------- Modal ดูภาพ ---------- */
.preview-modal .modal-content {
    border-radius: 14px;
    overflow: hidden;
    border: 0;
}
.preview-modal .modal-header {
    background: linear-gradient(135deg, #5d4037, #8d6e63);
    color: #fff;
}
.preview-modal .modal-header .btn-close {
    filter: invert(1);
}
.preview-modal .modal-body img {
    width: 100%;
    border-radius: 8px;
}

@media (max-width: 576px) {
    .page-banner {
        margin-top: 12px;
    }
    .page-banner img {
        border-radius: 10px;
    }
    .doc-panel-body {
        padding: 14px;
    }
    .panel-search input,
    .doc-panel-header .form-select {
        min-width: 0;
        max-width: none;
        width: 100%;
    }
    .panel-search {
        width: 100%;
    }
}
