/* ============================================================
   Kos WJK - Admin Panel CSS
   ============================================================ */
:root {
  --sidebar-w: 260px;
  --sidebar-bg: #1a1a2e;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: #2c6fad;
  --topbar-h: 64px;
  --primary: #2c6fad;
  --primary-dark: #1a4a7a;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --border: #e9ecef;
  --radius: 10px;
  --shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f0f2f5;
  margin: 0;
  color: #333;
}

/* ── WRAPPER ── */
.admin-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width 0.3s ease;
  /* z-index 1000 — di bawah modal-backdrop (1050) dan modal (1055) */
  z-index: 1000;
  display: flex;
  flex-direction: column;
  /* JANGAN tambahkan transform/will-change — akan buat stacking context baru */
}

.admin-sidebar.collapsed {
  width: 70px;
}

.admin-sidebar.collapsed .sidebar-brand span,
.admin-sidebar.collapsed .sidebar-admin-info,
.admin-sidebar.collapsed .nav-label,
.admin-sidebar.collapsed li a span {
  display: none;
}

.admin-sidebar.collapsed li a {
  justify-content: center;
  padding: 14px;
}

.admin-sidebar.collapsed li a i {
  margin: 0;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-link {
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-admin-info {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.admin-avatar {
  width: 50px;
  height: 50px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.3rem;
  margin: 0 auto 8px;
}

.admin-name {
  color: #fff;
  font-weight: 600;
  font-size: 0.92rem;
}

.sidebar-nav {
  list-style: none;
  padding: 12px 0;
  margin: 0;
  flex: 1;
}

.sidebar-nav .nav-label {
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 16px 20px 6px;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  text-decoration: none;
}

.sidebar-nav li a:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-nav li.active>a {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.sidebar-nav li a i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.text-danger-sidebar {
  color: #ff6b6b !important;
}

/* ── MAIN ── */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
  min-height: 100vh;
  /* TIDAK ada overflow:hidden di sini agar modal tidak ter-clip */
}

.admin-main.expanded {
  margin-left: 70px;
}

/* ── TOPBAR ── */
.admin-topbar {
  background: #fff;
  height: var(--topbar-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: 100;
  /* Hapus transform/will-change agar tidak buat stacking context baru */
}

.sidebar-toggle {
  border: 1px solid var(--border);
  background: #fff;
  color: #555;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.sidebar-toggle:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.page-heading {
  color: #1a1a2e;
  font-weight: 700;
  font-size: 1.05rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── CONTENT ── */
.admin-content {
  padding: 24px;
  flex: 1;
  /* TIDAK overflow:hidden — agar modal bisa keluar dari sini */
}

/* ── CARDS ──
   Gunakan overflow:visible agar modal footer tidak terpotong.
   Jika perlu border-radius, gunakan clip-path atau border saja.
*/
.admin-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  /* overflow:visible = modal bisa escape, tapi sudut card tetap tampak */
  overflow: visible;
}

.admin-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  border-radius: var(--radius) var(--radius) 0 0;
}

.admin-card-header h6 {
  margin: 0;
  font-weight: 700;
  color: #1a1a2e;
  font-size: 0.95rem;
}

.admin-card-body {
  padding: 20px;
}

/* ── STAT WIDGETS ── */
.stat-widget {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-left: 4px solid;
}

.stat-widget.color-blue {
  border-left-color: #2c6fad;
}

.stat-widget.color-green {
  border-left-color: #27ae60;
}

.stat-widget.color-purple {
  border-left-color: #8e44ad;
}

.stat-widget.color-red {
  border-left-color: #e74c3c;
}

.stat-widget .stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #fff;
  flex-shrink: 0;
}

.color-blue .stat-icon {
  background: linear-gradient(135deg, #2c6fad, #1a4a7a);
}

.color-green .stat-icon {
  background: linear-gradient(135deg, #27ae60, #1e8449);
}

.color-purple .stat-icon {
  background: linear-gradient(135deg, #8e44ad, #6c3483);
}

.color-red .stat-icon {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.stat-widget .stat-num {
  font-size: 1.8rem;
  font-weight: 800;
  color: #1a1a2e;
  line-height: 1;
}

.stat-widget .stat-lbl {
  font-size: 0.82rem;
  color: #6c757d;
  font-weight: 500;
  margin-top: 4px;
}

/* ── TABLE ── */
.table th {
  font-size: 0.82rem;
  font-weight: 700;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border) !important;
  padding: 12px 16px;
  background: #fafafa;
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  vertical-align: middle;
  font-size: 0.9rem;
  border-bottom: 1px solid #f0f0f0;
}

.table tbody tr:hover {
  background: #f8f9ff;
}

/* Sortable header */
.table thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.table thead th.sortable:hover {
  background: rgba(0, 0, 0, .04);
}

.sort-icon {
  font-size: 0.7rem;
  opacity: 0.35;
}

th.sort-asc .sort-icon,
th.sort-desc .sort-icon {
  opacity: 1;
}

/* Pagination */
.pagination .page-link {
  border-radius: 6px !important;
  margin: 0 2px;
}

/* ── TABLE RESPONSIVE ──
   Scroll horizontal saja, TIDAK clip vertikal.
*/
.table-responsive {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}

/* ── BUTTONS ── */
.btn {
  border-radius: 8px;
  font-weight: 600;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.78rem;
  border-radius: 6px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

/* ── FORMS ── */
.form-control,
.form-select {
  border-radius: 8px;
  border: 2px solid var(--border);
  padding: 10px 14px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 111, 173, 0.12);
}

.form-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 6px;
}

.input-group-text {
  border: 2px solid var(--border);
  background: #f8f9fa;
  border-radius: 8px 0 0 8px;
  font-size: 0.9rem;
}

.input-group .form-control {
  border-left: 0;
  border-radius: 0 8px 8px 0;
}

/* ── GALLERY ADMIN ── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafafa;
  position: relative;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--primary);
  background: rgba(44, 111, 173, 0.04);
}

.file-input-hidden {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.gallery-admin-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1;
}

.gallery-thumb-admin {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-admin-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
  color: #fff;
  padding: 10px;
  text-align: center;
}

.gallery-admin-item:hover .gallery-admin-overlay {
  opacity: 1;
}

.gallery-item-title {
  font-weight: 600;
  font-size: 0.85rem;
}

.gallery-item-branch {
  font-size: 0.75rem;
  opacity: 0.8;
}

/* ── TESTIMONIALS ADMIN ── */
.testi-admin-avatar img,
.avatar-ph {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-ph {
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.testi-content-sm {
  font-size: 0.88rem;
  color: #666;
  font-style: italic;
  line-height: 1.6;
  margin: 0;
}

.stars-sm {
  font-size: 0.75rem;
}

/* ── ALERTS ── */
.alert {
  border-radius: 10px;
  border: none;
  padding: 12px 16px;
  font-size: 0.9rem;
}

.alert-success {
  background: #d4edda;
  color: #155724;
}

.alert-danger {
  background: #f8d7da;
  color: #721c24;
}

/* ── BADGES ── */
.badge {
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 6px;
  font-weight: 600;
}

/* ════════════════════════════════════════════════
   MODAL FIX — permanen, terpusat di admin.css
   ════════════════════════════════════════════════ */

/*
 * Root fix: pastikan html & body tidak punya overflow tersembunyi
 * yang bisa memotong backdrop atau dialog modal.
 * min-height: 100% cukup — jangan pakai overflow:hidden di sini.
 */
html,
body {
  height: 100%;
  /* TIDAK overflow:hidden — biarkan Bootstrap handle scroll lock saat modal open */
}

/*
 * Saat modal terbuka Bootstrap menambah class .modal-open ke <body>.
 * Kita pastikan body tidak punya padding/margin yang mengeser konten.
 */
body.modal-open {
  overflow: hidden;
  /* padding-right di-handle Bootstrap secara dinamis — jangan di-override */
}

/* ── Backdrop harus full-viewport, BUKAN relatif terhadap parent ── */
.modal-backdrop {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 1050 !important;
  background-color: #000 !important;
}

.modal-backdrop.show {
  opacity: 0.5 !important;
}

/* ── Modal overlay harus fixed ke viewport ── */
.modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  z-index: 1055 !important;
  /* Pastikan modal tidak dipengaruhi margin-left dari .admin-main */
  margin: 0 !important;
  padding: 0 !important;
}

/* ── Modal dialog — centered dengan margin ── */
.modal-dialog {
  margin: 1.75rem auto !important;
  /* max-width di-handle Bootstrap per ukuran (modal-lg, dll) */
}

/* ── Modal content — flex column agar footer selalu kelihatan ── */
.modal-content {
  display: flex !important;
  flex-direction: column !important;
  max-height: calc(100vh - 3.5rem) !important;
  overflow: hidden !important;
  border-radius: 12px !important;
  /* Tidak ada transform di sini — akan buat stacking context baru */
}

/*
 * FIX: Jika <form> membungkus modal-body + modal-footer sekaligus,
 * form harus ikut menjadi flex column agar footer tidak terpotong.
 * flex: 1 1 auto + min-height: 0 supaya form bisa shrink di dalam modal-content.
 */
.modal-content>form {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

/* ── Header & footer TIDAK boleh scroll — harus selalu terlihat ── */
.modal-header,
.modal-footer {
  flex: 0 0 auto !important;
  min-height: 0;
  /* fix flexbox shrink di beberapa browser */
}

/* ── Hanya modal-body yang boleh scroll ── */
.modal-body {
  flex: 1 1 auto !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  min-height: 0;
  /* KRITIS: tanpa ini flex item tidak bisa shrink */
}

/* ── Footer styling ── */
.modal-footer {
  background: #f8f9fa !important;
  border-top: 1px solid var(--border) !important;
  padding: 12px 20px !important;
  gap: 8px !important;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
    transition: transform 0.3s ease;
  }

  .admin-sidebar.collapsed {
    transform: translateX(0);
    width: var(--sidebar-w);
  }

  .admin-main {
    margin-left: 0 !important;
  }

  .admin-content {
    padding: 16px;
  }

  .stat-widget {
    padding: 14px;
  }

  .modal-dialog {
    margin: 0.5rem;
  }

  .modal-content {
    max-height: calc(100vh - 1rem) !important;
  }
}