/* ========================================= */
/* Global & Loading Overlay                  */
/* ========================================= */
body {
  font-family: "Sarabun", sans-serif;
  background-color: #f4f6f9;
}

/* เพิ่มสีพื้นหลัง body เล็กน้อยเพื่อให้กล่องขาวเด่นขึ้น */

#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  backdrop-filter: blur(2px);
}

/* ========================================= */
/* Detail Page Styles (ปรับปรุงใหม่)           */
/* ========================================= */
.detail-box {
  background: #fff;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
  margin-bottom: 30px;
}

.detail-header {
  border-bottom: 1px solid #eee;
  margin-bottom: 25px;
  padding-bottom: 15px;
}

.detail-title {
  color: #333;
  font-weight: bold;
  font-size: 1.8rem;
  margin-bottom: 10px;
}

.meta-info {
  color: #777;
  font-size: 0.9rem;
}

.meta-info i {
  color: #aaa;
  margin-right: 5px;
}

.meta-item {
  margin-right: 15px;
  display: inline-block;
}

/* เนื้อหาฝั่งซ้าย */
.content-head {
  font-weight: bold;
  font-size: 1.2rem;
  border-bottom: 2px solid #f0ad00;
  padding-bottom: 10px;
  margin-bottom: 20px;
  color: #333;
  display: inline-block;
}

.content-body {
  font-size: 1rem;
  line-height: 1.8;
  color: #444;
}

/* --- ส่วนที่เพิ่มใหม่ --- */
.content-body p {
  text-indent: 50px;
  /* ย่อหน้า 50px */
}

.content-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 20px 0;
}

/* รูปปกหลัก (เพิ่มใหม่) */
.main-cover-img {
  width: 100%;
  max-height: 500px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  margin-bottom: 25px;
}

/* รูปที่แทรกใน editor */

.yt-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.yt-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Image Viewer Modal */
#imageViewerModal .modal-dialog {
  max-width: 90%;
  margin: 1.75rem auto;
}

#imageViewerModal .modal-content {
  background: transparent;
  border: none;
  box-shadow: none;
}

#imageViewerModal .modal-body {
  padding: 0;
  text-align: center;
  position: relative;
}

#imageViewerModal img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#imageViewerModal .btn-close-custom {
  position: absolute;
  top: -40px;
  right: 0;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  z-index: 1000;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  background: none;
  border: none;
}

#imageViewerModal .btn-close-custom:hover {
  color: #ffc107;
}

/* ========================================= */
/* List Page Styles (คงเดิมไว้)               */
/* ========================================= */
/* ... (CSS ส่วนนี้เหมือนเดิม ไม่ได้แก้ไข) ... */
.layout_padding {
  padding-top: 20px;
  padding-bottom: 30px;
}

.blog-filter-container {
  margin-top: -20px;
  margin-bottom: 40px;
  text-align: center;
}

.activity-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: none;
  position: relative;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  height: 100%;
  cursor: pointer;
}

.activity-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.activity-img-box {
  height: 200px;
  overflow: hidden;
  position: relative;
}

.activity-img-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: 0.5s;
}

.activity-card:hover .activity-img-box img {
  transform: scale(1.1);
}

.activity-content {
  padding: 20px;
  position: relative;
}

.category-badge {
  position: absolute;
  top: -15px;
  left: 20px;
  background: #ffc107;
  color: #000;
  padding: 5px 15px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.activity-title {
  font-size: 1rem;
  font-weight: 700;
  color: #333;
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 45px;
}

.activity-desc {
  font-size: 0.85rem;
  line-height: 1.4;
  color: #777;
  margin-bottom: 15px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
}

.activity-meta {
  border-top: 1px solid #eee;
  padding-top: 15px;
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #999;
}

.card-actions {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s;
}

.activity-card:hover .card-actions {
  opacity: 1;
}

.btn-action {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 5px;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.btn-action:hover {
  transform: scale(1.1);
}

.btn-edit {
  background: #fff;
  color: #ffc107;
}

.btn-delete {
  background: #fff;
  color: #dc3545;
}

.btn-primary-custom {
  background: #680268;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 30px;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(104, 2, 104, 0.2);
}

.btn-primary-custom:hover {
  background: #500250;
  color: #fff;
  transform: translateY(-2px);
}

.btn-outline-custom {
  border: 1px solid #680268;
  color: #680268;
  background: #fff;
  padding: 8px 20px;
  border-radius: 30px;
  font-weight: 600;
  margin-right: 10px;
}

.btn-outline-custom:hover {
  background: #fdf2fd;
}

/* League Table */
.league-card {
  border: none;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  font-family: "Sarabun", sans-serif;
}

.league-header {
  background-color: #3e0e4e;
  color: #fff;
  padding: 12px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.league-title {
  font-weight: bold;
  font-size: 1rem;
  display: flex;
  align-items: center;
}

.league-table {
  width: 100%;
  margin-bottom: 0;
  font-size: 0.85rem;
  background: #fff;
}

.league-table thead th {
  background-color: #f8f9fa;
  color: #6c757d;
  font-weight: 600;
  border-bottom: 1px solid #dee2e6;
  border-top: none;
  text-align: center;
  padding: 10px 5px;
}

.league-table td {
  vertical-align: middle;
  padding: 8px 5px;
  border-bottom: 1px solid #f1f1f1;
  text-align: center;
  color: #555;
}

.league-table td.name-col {
  text-align: left;
  font-weight: 600;
  color: #333;
  min-width: 120px;
}

.rank-pos {
  width: 4px;
  height: 25px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 2px;
  vertical-align: middle;
}

.row-rank-1 .rank-pos {
  background-color: #f1c40f;
}

.row-rank-2 .rank-pos {
  background-color: #f39c12;
}

.row-rank-3 .rank-pos {
  background-color: #95a5a6;
}

.trophy-icon {
  color: #f1c40f;
  margin-left: 5px;
  font-size: 0.9rem;
}

.league-footer {
  background: #fff;
  padding: 15px;
  border-top: 1px solid #eee;
  font-size: 0.8rem;
}

.legend-item {
  display: inline-block;
  margin-right: 15px;
  color: #555;
  margin-bottom: 5px;
}

.legend-key {
  font-weight: bold;
  color: #333;
}

.pagination-container {
  display: flex;
  justify-content: center;
  margin-top: 40px;
}

.pagination-btn {
  background: #fff;
  border: 1px solid #ddd;
  color: #680268;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 5px;
  cursor: pointer;
  font-weight: bold;
  transition: 0.3s;
}

.pagination-btn:hover {
  background-color: #f0f0f0;
  color: #9e059e;
  text-decoration: none;
}

.pagination-btn.active {
  background-color: #680268;
  color: white;
  border-color: #680268;
  pointer-events: none;
}

.pagination-btn.disabled {
  background-color: #f9f9f9;
  color: #ccc;
  border-color: #eee;
  cursor: not-allowed;
  pointer-events: none;
}

.cat-pill-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

.cat-pill {
    cursor: pointer;
    padding: 6px 15px;
    border-radius: 50px;
    background: #fff;
    border: 1px solid #eee;
    color: #555;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease; /* เพิ่มความนุ่มนวลตอนขยับ */
}

.cat-pill:hover {
  /* ตอนเอาเมาส์ชี้ ให้พื้นหลังเป็นสีจางๆ */
  background-color: var(--pill-color);
  color: #fff;
  opacity: 0.8;
}
.cat-pill.active {
  /* background-color: #f0ad00; */
  background-color: var(--pill-color);
  color: #fff;
  border-color: var(--pill-color);
  /* box-shadow: 0 4px 6px var(--pill-color); */
  box-shadow: 0 4px 6px color-mix(in srgb, var(--pill-color), transparent 70%);
  font-weight: bold;
}

/* Upload & Form */
.custom-file-label::after {
  content: "เลือกไฟล์";
  background-color: #680268;
  color: white;
}

.custom-file-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 90px;
}

.preview-box {
  background-color: #f8f9fa;
  border: 2px dashed #dee2e6;
  border-radius: 12px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
  position: relative;
}

.preview-box:hover {
  border-color: #680268;
  background-color: #fdf2fd;
}

.preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  display: none;
}

.opacity-50 {
  opacity: 0.5;
}

.custom-control-label {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.count-badge {
  font-size: 0.8rem;
  color: #aaa;
}

/* จัดตำแหน่งกล่องรูปภาพ */
/* --- CSS สำหรับพรีวิวอัลบั้ม (เพิ่มใหม่) --- */
#albumPreview {
  max-height: 300px;
  overflow-y: auto;
  /* ให้มี Scrollbar ถ้าเลือกรูปเยอะ */
  border: 1px solid #dee2e6;
  padding: 15px;
  border-radius: 6px;
  background-color: #f8f9fa;
  margin-top: 10px;
}

/* กล่องหุ้มรูปแต่ละใบ */
.preview-thumb-box {
  position: relative;
  width: 100px;
  height: 100px;
  margin-right: 10px;
  margin-bottom: 10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #ddd;
  display: inline-block;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ตัวรูปภาพ */
.preview-thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ปุ่ม X (ลบรูป) */
.btn-remove-img {
  position: absolute;
  top: 4px;
  right: 4px;
  background-color: rgba(220, 53, 69, 0.9);
  /* สีแดง */
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 10;
}

.btn-remove-img:hover {
  background-color: #c82333;
  transform: scale(1.1);
}

.btn-remove-img i {
  font-size: 12px;
}

.ck-editor__editable_inline {
  min-height: 200px;
  max-height: 200px;
  overflow-y: auto;
  border-bottom-left-radius: 8px !important;
  border-bottom-right-radius: 8px !important;
  border: 1px solid #ced4da !important;
}

.ck-toolbar {
  border-top-left-radius: 8px !important;
  border-top-right-radius: 8px !important;
  border: 1px solid #ced4da !important;
  border-bottom: none !important;
}

/* กำหนดให้ Modal Body มี Scrollbar และจำกัดความสูง */
#writeActivityModal .modal-body {
  max-height: 70vh; /* กำหนดความสูงสูงสุดเป็น 70% ของหน้าจอ */
  overflow-y: auto; /* เปิด Scrollbar แนวตั้ง */
  scrollbar-width: thin; /* ปรับขนาด scrollbar สำหรับ Firefox */
  scrollbar-color: #680268 #f1f1f1; /* ปรับสี scrollbar สำหรับ Firefox */
}

/* ปรับแต่งความสวยงามของ Scrollbar สำหรับ Chrome, Safari, และ Edge */
#writeActivityModal .modal-body::-webkit-scrollbar {
  width: 8px;
}

#writeActivityModal .modal-body::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

#writeActivityModal .modal-body::-webkit-scrollbar-thumb {
  background: #680268;
  border-radius: 10px;
}

#writeActivityModal .modal-body::-webkit-scrollbar-thumb:hover {
  background: #500250;
}

/* ปรับให้รูปทรง Modal ดูสวยงามขึ้น */
#writeActivityModal .modal-content {
  max-height: 95vh; /* ความสูงรวมไม่เกินหน้าจอ */
  display: flex;
  flex-direction: column;
}

/* ซ่อนตัวเลขเดิมของเบราว์เซอร์ */
input[type="date"].php-thai-date {
  position: relative;
  color: transparent !important;
}

/* แสดงวันที่ พ.ศ. ที่เราคำนวณไว้ */
input[type="date"].php-thai-date::before {
  content: attr(data-date);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #495057;
  pointer-events: none;
  z-index: 1;
}

/* ทำให้ปุ่มปฏิทินของเบราว์เซอร์ยังกดได้ปกติ */
input[type="date"].php-thai-date::-webkit-calendar-picker-indicator {
  background-color: transparent;
  cursor: pointer;
  z-index: 2;
}

/* ปรับสไตล์ Select2 ให้เนียนเหมือน input ตัวอื่น */
.select2-container--default .select2-selection--single {
  background-color: #f8f9fa !important; /* bg-light */
  border: none !important;
  height: 36px !important;
  display: flex;
  align-items: center;
}

.select2-container {
  width: 100% !important;
  flex: 1; /* ให้ยืดเต็มพื้นที่ใน input-group */
}

.select2-selection__arrow {
  height: 34px !important;
}

.select2-dropdown {
  border: 1px solid #eee !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* --- Premier League Style Table (Shared with Works) --- */
.league-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    background: #fff;
}

.league-header {
    background: #38003c; /* สีม่วงพรีเมียร์ลีก */
    color: #fff;
    padding: 12px 15px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.league-table {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: collapse;
}

.league-table th {
    background-color: #f8f9fa;
    color: #666;
    padding: 10px 5px;
    text-align: center;
    font-weight: 600;
    font-size: 0.75rem;
    border-bottom: 2px solid #dee2e6;
}

.league-table td {
    padding: 10px 5px;
    text-align: center;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.league-table td.name-col {
    text-align: left;
    font-weight: 600;
    color: #333;
}

/* แถบสีด้านซ้ายบอกอันดับ */
.rank-pos {
    width: 4px;
    height: 18px; /* ปรับความสูงให้พอดีกับบรรทัด */
    display: block; /* เปลี่ยนเป็น block */
    position: absolute; /* ใช้ absolute เพื่อไม่ให้เบียดตัวเลข */
    left: 5px;
    border_radius: 2px;
}

.row-rank-1 { background-color: #fffbf0; }
.row-rank-1 .rank-pos { background-color: #ffd700; } /* สีทอง */

.row-rank-ucl .rank-pos { background-color: #ffc107; } /* อันดับ 2-5 */
.row-rank-mid .rank-pos { background-color: #6f42c1; } /* อันดับ 6-10 */
.row-normal .rank-pos { background-color: #dee2e6; }   /* ทั่วไป */

.trophy-icon {
    color: #ffd700;
    margin-left: 5px;
}

.league-table td:first-child {
    position: relative; /* รองรับ absolute ของ rank-pos */
    padding-left: 15px; /* เว้นที่ให้แถบสี */
    text-align: center;
}

.league-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
    border: 1px solid #eee;
}

.league-footer {
    background: #f8f9fa;
    padding: 10px 15px;
    font-size: 0.75rem;
}