/* ==========================
   TABLE & GALLERY STYLING
   ========================== */

/* Table image */
.table img {
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Gallery Card */
.card {
  border-radius: 12px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.25);
}
.card img {
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

/* ==========================
   SEARCH & PAGINATION
   ========================== */

/* Search input */
#search {
  border-radius: 50px;
  padding: 0.4rem 1rem;
  transition: all 0.2s ease;
}
#search:focus {
  outline: none;
  box-shadow: 0 0 8px rgba(0,123,255,0.6);
  border-color: #80bdff;
}

/* Pagination */
.pagination .page-link {
  border-radius: 6px;
  margin: 0 2px;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.pagination .page-item.active .page-link {
  background-color: #0d6efd;
  border-color: #0d6efd;
}
.pagination .page-link:hover {
  background-color: #e9ecef;
}

/* ==========================
   TOAST & PREVIEW IMAGE
   ========================== */

.toast {
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}

/* Image preview (Tambah/Edit form) */
#previewTambah,
#previewEdit {
  display: none;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  margin-top: 5px;
}

/* ==========================
   COMPACT MODE TABLE
   ========================== */
.table.compact td,
.table.compact th {
  padding: 0.3rem !important;
  font-size: 0.85rem;
}
.table.compact img {
  max-width: 70px;
}

/* ==========================
   DARK MODE (NAVY THEME)
   ========================== */

body.dark {
  background-color: #0d1b2a !important;
  color: #e0e0e0 !important;
}

/* Navbar */
body.dark .navbar {
  background-color: #1b263b !important;
}
body.dark .navbar .nav-link {
  color: #e0e0e0;
}
body.dark .navbar .nav-link:hover {
  color: #fff;
}

/* Cards */
body.dark .card {
  background-color: #1e2d3d !important;
  border-color: #2e3d4d !important;
  color: #e0e0e0 !important;
}

/* Table */
body.dark .table,
body.dark .table tbody,
body.dark .table tr,
body.dark .table td,
body.dark .table th {
  background-color: #1b263b !important;
  color: #e0e0e0 !important;
}
body.dark .table thead th {
  background-color: #243447 !important;
  color: #fff !important;
}
body.dark .table-striped > tbody > tr:nth-of-type(odd) {
  background-color: #22354a !important;
}

/* Forms & Inputs */
body.dark .form-control,
body.dark .form-select {
  background-color: #1e2d3d !important;
  color: #f1f1f1 !important;
  border-color: #2e3d4d !important;
}
body.dark .form-control::placeholder {
  color: #aaa !important;
}
body.dark #search {
  background-color: #1e2d3d !important;
  color: #f1f1f1 !important;
}

/* Dropdown */
body.dark .dropdown-menu {
  background-color: #1e2d3d !important;
}
body.dark .dropdown-item {
  color: #e0e0e0 !important;
}
body.dark .dropdown-item:hover {
  background-color: #243447 !important;
  color: #fff !important;
}

/* Buttons */
body.dark .btn-outline-secondary {
  color: #ccc !important;
  border-color: #666 !important;
}
body.dark .btn-outline-secondary:hover {
  background-color: #243447 !important;
  color: #fff !important;
}
body.dark .btn-primary {
  background-color: #0d6efd !important;
  border-color: #0d6efd !important;
}
body.dark .btn-warning {
  background-color: #e0a800 !important;
  border-color: #d39e00 !important;
  color: #fff !important;
}
body.dark .btn-danger {
  background-color: #dc3545 !important;
  border-color: #dc3545 !important;
  color: #fff !important;
}
body.dark .btn-primary:hover,
body.dark .btn-warning:hover,
body.dark .btn-danger:hover {
  filter: brightness(1.1);
}

/* Toast close button fix */
body.dark .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Dark Mode fix: Search bar container */
body.dark .sticky-top.bg-body {
  background-color: #0d1b2a !important;
  border-bottom: 1px solid #2e3d4d !important;
}
body.dark .sticky-top.bg-body .form-control {
  background-color: #1e2d3d !important;
  border: 1px solid #2e3d4d !important;
  color: #f1f1f1 !important;
}

/* ==========================
   MOBILE & TABLET FRIENDLY
   ========================== */

/* Touch-friendly buttons & pagination */
.btn, .page-link {
  min-height: 44px;
  padding: 10px 16px;
}

/* Mobile (≤576px) */
@media (max-width: 576px) {
  .pagination .page-link {
    font-size: 1rem;
    padding: 12px 18px;
  }
  .form-control, .form-select {
    font-size: 1rem;
    padding: 12px;
  }
  .btn {
    width: 100%;
    margin-bottom: 10px;
  }
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Tablet (768px–1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  body { font-size: 1.05rem; }
  .btn { padding: 12px 20px; font-size: 1rem; }
  .form-control, .form-select { font-size: 1rem; padding: 12px; }
  .card { margin-bottom: 1.2rem; }
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
  .table td, .table th { padding: 0.8rem; }
  .table img { max-width: 90px; }
}

/* Desktop (≥992px) */
@media (min-width: 992px) {
  .table-hover tbody tr:hover {
    background-color: #f8f9fa;
    cursor: pointer;
  }
  body.dark .table-hover tbody tr:hover {
    background-color: #243447;
  }
  .pagination .page-link {
    font-size: 1rem;
    padding: 10px 18px;
    margin: 0 4px;
  }
  .pagination { font-weight: 500; }
}

/* Large Desktop (≥1200px, ≥1600px) */
@media (min-width: 1200px) {
  .container { max-width: 1400px; }
  .gallery-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 1600px) {
  .container { max-width: 1500px; }
  .gallery-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ==========================
   FAB (Floating Action Button)
   ========================== */
.fab-add {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1050;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: #0d6efd;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  text-decoration: none;
}
.fab-add:hover {
  background-color: #0b5ed7;
  color: #fff;
}
@media (min-width: 768px) {
  .fab-add {
    width: 50px;
    height: 50px;
    font-size: 1.3rem;
  }
}

/* ==========================
   GALLERY GRID (FINAL)
   ========================== */
.gallery-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.gallery-grid > div {
  display: flex;
}
.gallery-grid .card {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.gallery-grid .card-body {
  flex: 1;
}

/* ==========================
   FULLSCREEN SEARCH OVERLAY
   ========================== */
.search-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-color: rgba(13, 27, 42, 0.95);
  z-index: 2000;
  padding: 1rem;
  overflow-y: auto;
}
.search-overlay .search-box {
  position: sticky;
  top: 0;
  background: #0d1b2a;
  padding-bottom: 1rem;
}
body.dark .search-overlay {
  background-color: rgba(13, 27, 42, 0.95);
}
@media (min-width: 768px) {
  .search-overlay { display: none !important; }
}

/* ==========================
   SAFE AREA (iOS/Android)
   ========================== */
body {
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

/* ==========================
   DARK MODE FIX: MODAL
   ========================== */
body.dark .modal-content {
  background-color: #1e2d3d !important; /* warna dark navy */
  color: #e0e0e0 !important;
  border: 1px solid #2e3d4d !important;
}

/* ==========================
   IMAGE LIGHTBOX
   ========================== */
.img-lightbox-backdrop {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 2rem 1.2rem 1.2rem;
  backdrop-filter: blur(2px);
}
.img-lightbox-backdrop.open { display: flex; }
.img-lightbox-backdrop img { max-width: 90vw; max-height: 85vh; object-fit: contain; }
.img-lightbox-backdrop .btn-close { position: absolute; top: 12px; right: 12px; filter: invert(1); }
body.dark .img-lightbox-backdrop { background: rgba(0,0,0,0.92); }
@media (max-width:576px){
  .img-lightbox-backdrop img { max-width: 100vw; max-height: 70vh; }
}

/* ==========================
   UNIFORM THUMBNAILS (DISPLAY ONLY)
   ========================== */
img.thumbnail {
  width: 120px;            /* Table context */
  aspect-ratio: 4 / 3;     /* Konsisten rasio */
  height: auto;            /* Browser hitung dari aspect-ratio */
  object-fit: cover;       /* Crop tengah */
  background: #f2f2f2;     /* Placeholder warna */
}

/* Gallery menggunakan lebar penuh kolom, tetap rasio sama */
.gallery-grid img.thumbnail, .gallery-grid .card-img-top.thumbnail {
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: cover;
}

/* Dark mode adjust placeholder */
body.dark img.thumbnail { background: #1e2d3d; }

body.dark .modal-header {
  background-color: #243447 !important;
  border-bottom: 1px solid #2e3d4d !important;
  color: #fff !important;
}

body.dark .modal-body {
  background-color: #1e2d3d !important;
  color: #e0e0e0 !important;
}

body.dark .modal-footer {
  background-color: #1e2d3d !important;
  border-top: 1px solid #2e3d4d !important;
}
