/* Custom styles for School Inventory System */

body {
  background-color: #f8f9fa;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.login-page {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
}

.card {
  border-radius: 10px;
  border: none;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

.card-header {
  border-radius: 10px 10px 0 0 !important;
}

.navbar-brand {
  font-weight: bold;
}

.table th {
  background-color: #f8f9fa;
  border-top: none;
}

.badge {
  padding: 5px 10px;
  font-weight: normal;
}

.btn {
  border-radius: 5px;
}

.form-control,
.form-select {
  border-radius: 5px;
  padding: 8px 12px;
}

.modal-content {
  border-radius: 10px;
}

/* Print styles */
@media print {
  .navbar,
  .card-header button,
  .btn {
    display: none !important;
  }

  .card {
    border: 1px solid #ddd !important;
    box-shadow: none !important;
  }

  body {
    background-color: white !important;
  }
}
/* Items page specific styles */
#itemsTable th {
  white-space: nowrap;
}

#itemsTable td {
  vertical-align: middle;
}

.table-responsive {
  overflow-x: auto;
}

.badge {
  font-size: 0.85em;
  padding: 0.35em 0.65em;
}

.btn-group-sm > .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

/* Status badges */
.badge.bg-success {
  background-color: #198754 !important;
}

.badge.bg-warning {
  background-color: #ffc107 !important;
  color: #000 !important;
}

.badge.bg-danger {
  background-color: #dc3545 !important;
}

/* Number formatting */
.text-end {
  text-align: right !important;
}

.fw-bold {
  font-weight: 600 !important;
}

/* แก้ไขปัญหา modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1040;
  width: 100vw;
  height: 100vh;
  background-color: #000;
}

.modal-backdrop.fade {
  opacity: 0;
}

.modal-backdrop.show {
  opacity: 0.5;
}

/* เมื่อมีปัญหา ให้บังคับซ่อน */
body.modal-open-fixed {
  overflow: hidden !important;
}

/* ปุ่มปิด modal */
[data-bs-dismiss="modal"],
.btn-close {
  cursor: pointer;
}

.btn-close:focus {
  outline: none;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Emergency fix */
.fixed-modal-fix {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 99999;
}
/* สไตล์สำหรับระบบกรอง */
#filterSection {
  background-color: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
}

.sortable {
  cursor: pointer;
  position: relative;
  user-select: none;
}

.sortable:hover {
  background-color: rgba(25, 135, 84, 0.1);
}

.sort-icon {
  font-size: 0.8em;
  margin-left: 5px;
  opacity: 0.5;
}

.sortable.active .sort-icon {
  opacity: 1;
  color: #198754;
}

.sortable.active[data-sort-direction="asc"] .sort-icon::before {
  content: "↑";
}

.sortable.active[data-sort-direction="desc"] .sort-icon::before {
  content: "↓";
}

/* สไตล์สำหรับตารางเมื่อกรอง */
tr.filtered-out {
  display: none;
}

/* สไตล์สำหรับแถวที่ตรงกับเงื่อนไขการค้นหา */
tr.highlighted {
  background-color: #fff3cd !important;
  border-left: 4px solid #ffc107;
}

/* สไตล์ปุ่ม action */
.action-buttons {
  display: flex;
  gap: 5px;
  justify-content: center;
}

.action-buttons .btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

/* สไตล์สำหรับ pagination */
#pagination .page-item.active .page-link {
  background-color: #198754;
  border-color: #198754;
}

/* สไตล์สำหรับ progress bar ในตาราง */
.progress {
  background-color: #e9ecef;
  border-radius: 3px;
}

/* สไตล์สำหรับ badge */
.badge.bg-info {
  background-color: #0dcaf0 !important;
}

.badge.bg-secondary {
  background-color: #6c757d !important;
}

/* สไตล์ responsive */
@media (max-width: 768px) {
  .action-buttons {
    flex-direction: column;
    gap: 3px;
  }

  .action-buttons .btn-sm {
    width: 100%;
    justify-content: center;
  }

  #filterSection .row.g-3 > div {
    margin-bottom: 10px;
  }

  .table-responsive {
    font-size: 0.9rem;
  }
}

/* สไตล์สำหรับแถวในตาราง */
.category-row:hover {
  background-color: #f8f9fa;
  cursor: default;
}

/* สไตล์สำหรับการแสดงผลตัวกรอง */
#filterSummary .alert {
  border-radius: 8px;
  border-left: 4px solid #0dcaf0;
}

/* สไตล์สำหรับปุ่ม toggle */
#toggleFilterBtn {
  transition: all 0.3s ease;
}

#toggleFilterBtn.active {
  background-color: #0d6efd;
  color: white;
}

/* สไตล์สำหรับตัวเลือกเรียงลำดับ */
#sortSelect:focus {
  border-color: #198754;
  box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
}

/* สไตล์สำหรับช่องค้นหาแบบ global */
#globalSearch:focus {
  border-color: #0dcaf0;
  box-shadow: 0 0 0 0.25rem rgba(13, 202, 240, 0.25);
}

/* สไตล์สำหรับป้ายสถานะ */
.badge[title="ไม่มีวัสดุ"] {
  font-size: 0.7em;
  padding: 2px 6px;
}

/* สไตล์สำหรับตารางเมื่อมีข้อมูลน้อย */
#categoryTableContainer {
  min-height: 300px;
}
/* สไตล์สำหรับระบบค้นหาเร็ว */
#quickSearch {
  border-color: #0dcaf0;
  transition: all 0.3s ease;
}

#quickSearch:focus {
  border-color: #0dcaf0;
  box-shadow: 0 0 0 0.25rem rgba(13, 202, 240, 0.25);
}

#quickSearch.searching {
  background-color: #fff3cd;
  border-color: #ffc107;
}

/* สไตล์สำหรับปุ่มรีเฟรช */
#refreshTableBtn .spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* สไตล์สำหรับข้อความผลลัพธ์ */
#searchResultText {
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

/* สไตล์สำหรับแถวที่กำลังค้นหา */
tr.searching {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    background-color: rgba(255, 243, 205, 0.3);
  }
  50% {
    background-color: rgba(255, 243, 205, 0.7);
  }
  100% {
    background-color: rgba(255, 243, 205, 0.3);
  }
}

/* สไตล์สำหรับ highlight หลายครั้ง */
.highlight {
  padding: 1px 3px;
  border-radius: 3px;
  font-weight: bold;
}

.highlight.bg-warning {
  background-color: #ffc107 !important;
  color: #000;
}

/* สไตล์สำหรับการค้นหาที่ไม่พบผลลัพธ์ */
.no-results {
  color: #dc3545;
  font-style: italic;
}

/* สไตล์สำหรับปุ่มช่วยเหลือ */
#searchHelpBtn:hover {
  background-color: #0dcaf0;
  color: white;
}

/* สไตล์สำหรับแถวที่ถูกกรองออก */
tr.filtered-out {
  display: none !important;
}

/* สไตล์สำหรับตารางเมื่อค้นหา */
.table-responsive.searching {
  border: 2px solid #0dcaf0;
  border-radius: 8px;
  transition: all 0.3s ease;
}

/* สไตล์สำหรับ badge สถานะ */
.badge.bg-warning {
  animation: bounce 0.5s ease infinite alternate;
}

@keyframes bounce {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-2px);
  }
}

/* Responsive สำหรับช่องค้นหาเร็ว */
@media (max-width: 768px) {
  #quickSearch {
    font-size: 0.9rem;
  }

  #searchResultText {
    font-size: 0.8rem;
    margin-top: 5px;
  }
}

/* สไตล์เพิ่มเติมสำหรับระบบค้นหาหมวดหมู่ใน Modal */
.category-select-container {
  background-color: #f8f9fa;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.category-select-container select {
  background-color: transparent;
  border: none !important;
  box-shadow: none !important;
}

.category-select-container select option {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  transition: all 0.2s ease;
}

.category-select-container select option:hover {
  background-color: #e9ecef;
}

.category-select-container select option:checked {
  background-color: #198754;
  color: white;
}

/* สไตล์สำหรับกล่องค้นหาใน Modal */
#categorySearch:focus {
  border-color: #198754;
  box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
}

/* สไตล์สำหรับปุ่มเลือกหมวดหมู่ */
#categorySelect:focus {
  border-color: #0dcaf0;
  box-shadow: 0 0 0 0.25rem rgba(13, 202, 240, 0.25);
}

/* สไตล์สำหรับการแสดงผลรหัส */
#itemCodePreview {
  border-left: 4px solid #198754;
}

/* สไตล์สำหรับ badge รหัสวัสดุ */
#itemCodePreview .badge {
  font-family: "Courier New", monospace;
  letter-spacing: 1px;
}

/* สไตล์สำหรับปุ่มรูปแบบรหัส */
#itemCodePreview .btn-group .btn {
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
}

/* สไตล์สำหรับช่องค้นหาเมื่อมีการกรอง */
.category-select-container:has(select option[style*="display: none"]) {
  border-color: #0dcaf0;
}

/* สไตล์สำหรับหมวดหมู่ที่เลือกแล้ว */
#selectedCategoryInfo .alert {
  border-radius: 6px;
  border-left: 4px solid #198754;
}

/* Responsive สำหรับ Modal */
@media (max-width: 768px) {
  #addItemModal .modal-dialog {
    margin: 10px;
  }

  #addItemModal .row {
    flex-direction: column;
  }

  #addItemModal .col-md-6 {
    width: 100%;
  }

  .category-select-container {
    max-height: 150px !important;
  }
}

/* Animation สำหรับการเปลี่ยนหมวดหมู่ */
@keyframes highlightChange {
  0% {
    background-color: #fff3cd;
  }
  100% {
    background-color: transparent;
  }
}

.category-select-container select option:checked {
  animation: highlightChange 0.5s ease;
}

/* สไตล์สำหรับ scrollbar ในตัวเลือกหมวดหมู่ */
.category-select-container::-webkit-scrollbar {
  width: 6px;
}

.category-select-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.category-select-container::-webkit-scrollbar-thumb {
  background: #198754;
  border-radius: 3px;
}

.category-select-container::-webkit-scrollbar-thumb:hover {
  background: #157347;
}
/* สไตล์สำหรับ Modal แก้ไข */
#editCategorySearch:focus {
  border-color: #ffc107;
  box-shadow: 0 0 0 0.25rem rgba(255, 193, 7, 0.25);
}

/* สไตล์สำหรับปุ่มล้างใน Modal แก้ไข */
#editCategorySearch + .btn-outline-secondary {
  display: none;
  transition: all 0.3s ease;
}

#editCategorySearch + .btn-outline-secondary:hover {
  background-color: #dc3545;
  color: white;
  border-color: #dc3545;
}

/* สไตล์สำหรับไฮไลต์คำค้นหา */
.bg-warning.text-dark {
  font-weight: bold;
  padding: 0 2px;
  border-radius: 2px;
}

/* สไตล์สำหรับการแสดงผลรหัสวัสดุ */
#current_item_code {
  background-color: #f8f9fa;
  font-weight: bold;
  color: #198754;
}

/* สไตล์สำหรับการเปลี่ยนหมวดหมู่ */
.text-decoration-line-through {
  text-decoration: line-through !important;
}

/* สไตล์สำหรับ animation */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#editSelectedCategoryInfo {
  animation: fadeInUp 0.3s ease;
}

/* สไตล์สำหรับข้อความแสดงผลจำนวน */
.text-info.fw-bold {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
  100% {
    opacity: 1;
  }
}
/* สไตล์สำหรับการแสดงผลลัพธ์การค้นหา */
.search-results-container {
  animation: fadeIn 0.3s ease;
}

.search-results-preview {
  border-left: 4px solid #198754 !important;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* สไตล์สำหรับ badge ผลลัพธ์ */
.bg-success-subtle.text-success {
  transition: all 0.2s ease;
}

.bg-success-subtle.text-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  background-color: #d1e7dd !important;
}

/* สไตล์สำหรับการไฮไลต์คำค้นหา */
.bg-warning.text-dark {
  font-weight: bold;
  padding: 0 4px;
  border-radius: 3px;
  animation: highlightPulse 1s infinite;
}

@keyframes highlightPulse {
  0%,
  100% {
    background-color: #ffc107;
  }
  50% {
    background-color: #ffca2c;
  }
}

/* สไตล์สำหรับข้อความแสดงผล */
#editCategoryCountInfo {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 4px;
  background-color: #f8f9fa;
  transition: all 0.3s ease;
}

#editCategoryCountInfo .badge.bg-info {
  animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* สไตล์สำหรับการแสดงผล option */
#edit_category_id option {
  padding: 8px 12px;
  margin: 2px 0;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#edit_category_id option:hover {
  background-color: #e9ecef !important;
}

#edit_category_id option:checked {
  background-color: #198754 !important;
  color: white !important;
  font-weight: bold;
}

/* สไตล์สำหรับ float-end badge ใน option */
#edit_category_id option .badge.float-end {
  font-size: 0.75em;
  opacity: 0.8;
}

/* สไตล์สำหรับ animation */
.animate__animated {
  --animate-duration: 0.3s;
}

/* สไตล์สำหรับข้อความยืนยันการเลือก */
#editSelectionConfirmation {
  border-left: 4px solid #198754;
  animation: confirmSlide 0.5s ease;
}

@keyframes confirmSlide {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* สไตล์สำหรับคำแนะนำการค้นหา */
#editSearchTips {
  border-left: 4px solid #0dcaf0;
  font-size: 0.9rem;
}

#editSearchTips .badge {
  font-size: 0.8em;
  margin-bottom: 2px;
}

/* สไตล์สำหรับช่องค้นหาเมื่อมีข้อผิดพลาด */
.is-invalid {
  border-color: #dc3545 !important;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right calc(0.375em + 0.1875rem) center;
  background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-2px);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(2px);
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .search-results-preview .d-flex {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-results-preview .badge {
    margin-bottom: 4px;
    width: 100%;
    text-align: left;
  }

  #editCategoryCountInfo {
    flex-direction: column;
    align-items: flex-start;
  }

  #editCategoryCountInfo .badge {
    margin-top: 4px;
  }
}
