/* =========================================
   1. VARIABLES & RESET
   ========================================= */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

:root {
  --primary: #0d47a1;
  --primary-light: #e0f2fe;
  --text-dark: #1f2937;
  --text-gray: #6b7280;
  --bg-body: #f3f4f6;
  --white: #ffffff;
  --sidebar-width: 260px;
  --sidebar-bg: #0d47a1;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Inter", sans-serif;
}

body {
  background-color: var(--bg-body);
  display: flex;
  min-height: 100vh;
  font-size: 0.95rem;
  color: var(--text-dark);
}

/* =========================================
   2. SIDEBAR & LAYOUT
   ========================================= */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: 0.3s ease; /* Animasi Slide Halus */
}

.sidebar-brand {
  padding: 30px 20px;
  font-size: 1.4rem;
  font-weight: 800;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-menu {
  padding: 20px 10px;
  flex-grow: 1;
  overflow-y: auto;
}

.sidebar-menu::-webkit-scrollbar {
  display: none;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  margin-bottom: 5px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-radius: 8px;
  transition: 0.3s;
  font-weight: 500;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-weight: 600;
  transform: translateX(5px);
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-logout {
  display: block;
  width: 100%;
  padding: 12px;
  background: rgba(255, 0, 0, 0.1);
  color: #ffcccc;
  text-align: center;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid rgba(255, 0, 0, 0.2);
  transition: 0.3s;
  font-weight: 600;
}

.btn-logout:hover {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}

.main-content {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  padding: 40px;
  transition: 0.3s ease;
}

/* Default: Tombol Hamburger Admin Sembunyi di Desktop */
.admin-menu-toggle {
  display: none;
}

/* =========================================
   3. HEADER & DASHBOARD STATS
   ========================================= */
.header-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 12px;
}

.header-subtitle {
  color: var(--text-gray);
  margin-bottom: 30px;
  font-size: 1rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 25px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--white);
  padding: 25px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: transform 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-5px);
}

.stat-info h3 {
  font-size: 2.2rem;
  font-weight: 800;
  color: #111;
  line-height: 1;
  margin-bottom: 5px;
}

.stat-info p {
  color: var(--text-gray);
  font-size: 0.9rem;
  font-weight: 500;
}

.stat-icon {
  width: 55px;
  height: 55px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background: var(--primary-light);
  color: var(--primary);
}

/* =========================================
   4. FORM COMPONENTS
   ========================================= */
.form-container {
  background: var(--white);
  padding: 30px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 800px;
}

.form-group {
  margin-bottom: 25px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-dark);
  font-size: 0.9rem;
}

.form-control {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.95rem;
  background-color: #f9fafb;
  transition: all 0.3s ease;
}

.form-control:focus {
  background-color: #fff;
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(13, 71, 161, 0.1);
}

input[type="file"].form-control {
  padding: 10px;
  background: white;
}

.btn-save {
  background: var(--primary);
  color: white;
  padding: 12px 30px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.3s;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.btn-save:hover {
  background: #1e40af;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(13, 71, 161, 0.3);
}

/* =========================================
   5. TABLE COMPONENTS
   ========================================= */
.card-container {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: #f8fafc;
  text-align: left;
  padding: 18px 25px;
  color: var(--text-gray);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #e5e7eb;
}

td {
  padding: 20px 25px;
  border-bottom: 1px solid #f3f4f6;
  color: var(--text-dark);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: #fafafa;
}

.badge {
  padding: 6px 12px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  display: inline-block;
}

.btn-action {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: 0.2s;
}

.btn-edit {
  background: #fff7ed;
  color: #ea580c;
  border: 1px solid #ffedd5;
}

.btn-edit:hover {
  background: #ffedd5;
}

.btn-delete {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fee2e2;
}

.btn-delete:hover {
  background: #fee2e2;
}

/* =========================================
   6. RESPONSIVE DESIGN (MOBILE) - UPDATED
   ========================================= */
@media (max-width: 768px) {
  /* 1. Sembunyikan Sidebar (Geser ke kiri) */
  .sidebar {
    width: 260px;
    left: -260px; /* Posisi awal tersembunyi */
    z-index: 9999; /* Pastikan di atas konten */
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
  }

  /* Class untuk memunculkan sidebar via JS */
  .sidebar.active {
    left: 0;
  }

  /* 2. Konten Full Width */
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 20px;
  }

  /* 3. Munculkan Tombol Hamburger */
  .admin-menu-toggle {
    display: inline-block;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-dark);
    cursor: pointer;
    margin-bottom: 20px;
  }

  /* 4. Tabel Scroll Samping */
  .card-container {
    overflow-x: auto;
  }

  table {
    min-width: 600px;
  }
}

/* =========================================
   FIX TAMPILAN FORM RESPONSIVE (HP)
   ========================================= */

@media (max-width: 768px) {
  /* 1. PAKSA GRID JADI 1 KOLOM 
       Ini akan menimpa style inline PHP yang tadinya 2 kolom */
  .form-container div[style*="display: grid"] {
    grid-template-columns: 1fr !important; /* Paksa jadi 1 kolom full */
    gap: 20px !important;
  }

  /* 2. BESARKAN INPUT FORM 
       Agar jari mudah menekan dan teks terbaca jelas */
  .form-control {
    height: auto; /* Biar textarea fleksibel */
    min-height: 45px; /* Tinggi minimal input text */
    font-size: 1rem; /* Ukuran font standar (tidak kecil) */
    padding: 12px 15px; /* Jarak dalam lebih lega */
  }

  /* 3. RAPIKAN CONTAINER 
       Supaya tidak terlalu mepet ke pinggir layar HP */
  .form-container {
    padding: 20px 15px; /* Atas-Bawah 20, Kiri-Kanan 15 */
    width: 100%;
  }

  /* 4. RAPIKAN HEADER SECTION 
       Garis bawah judul section */
  .section-header {
    font-size: 1.1rem;
    margin-top: 20px;
  }

  /* 5. FOTO PREVIEW */
  .img-preview {
    width: 100% !important; /* Gambar preview jadi full width */
    height: auto !important;
  }
}

/* =========================================
   UPDATE: OVERLAY & CLOSE BUTTON MOBILE
   ========================================= */

/* 1. Overlay Gelap di Belakang Sidebar */
.sidebar-overlay {
  display: none; /* Sembunyi default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5); /* Hitam transparan */
  z-index: 9998; /* Di bawah sidebar (9999), di atas konten */
  backdrop-filter: blur(2px); /* Efek blur keren (opsional) */
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Saat Aktif (Diklik Hamburger) */
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* 2. Tombol Close di Dalam Sidebar */
.sidebar-close-btn {
  display: none; /* Sembunyi di Desktop */
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 5px;
}

/* MEDIA QUERY MOBILE */
@media (max-width: 768px) {
  /* Munculkan tombol close hanya di HP */
  .sidebar-close-btn {
    display: block;
  }

  /* Pastikan sidebar paling atas */
  .sidebar {
    z-index: 9999;
  }
}

/* =========================================
   MANAJEMEN GALERI (CARD MODERN & RATA BAWAH)
   ========================================= */

.gallery-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 25px;
}

.gallery-admin-card {
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid #f3f4f6;
  display: flex; /* Flexbox */
  flex-direction: column; /* Susun ke bawah */
  height: 100%; /* Paksa tinggi penuh grid */
  transition: transform 0.2s;
}

.gallery-admin-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.gallery-admin-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.gallery-card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex-grow: 1; /* KUNCI: Mengisi ruang kosong agar tombol terdorong ke bawah */
}

.gallery-desc {
  font-size: 0.95rem;
  color: #374151;
  font-weight: 600;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* Tombol Hapus Modern */
.btn-delete-full {
  margin-top: auto; /* Pastikan selalu di bawah */
  display: block;
  width: 100%;
  padding: 10px;
  background: #fef2f2;
  color: #dc2626;
  text-align: center;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  border: 1px solid #fee2e2;
  transition: 0.2s;
}

.btn-delete-full:hover {
  background: #fee2e2;
  color: #991b1b;
}

/* =========================================
   TOMBOL HAPUS FOTO MODERN
   ========================================= */
.btn-delete-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%; /* Lebar penuh mengikuti kotak */
  padding: 10px 15px;
  margin-top: 10px;

  /* Warna Dasar (Soft Red) */
  background-color: #fff1f2;
  color: #e11d48;
  border: 1px solid #fda4af;

  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  cursor: pointer;
}

/* Efek Hover (Merah Solid) */
.btn-delete-photo:hover {
  background-color: #e11d48;
  color: #ffffff;
  border-color: #e11d48;
  transform: translateY(-2px); /* Efek naik sedikit */
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.25);
}

/* Perbaikan Tampilan Gambar Preview agar tidak error/broken */
.img-preview {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background-color: #f9fafb;
  display: block;
}
