/* =====================================================
   GLOBAL RESET & BASE
===================================================== */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background-color: #f8f9fa;
  overflow-x: hidden;
}

a {
  text-decoration: none;
}

/* =====================================================
   GLOBAL LAYOUT (SIDEBAR + CONTENT)
===================================================== */

.app-wrapper {
  display: flex;
}

/* =====================================================
   MAIN CONTENT (Desktop Default)
===================================================== */
.main-content {
  margin-left: 270px; /* Jarak untuk sidebar desktop */
  width: calc(100% - 270px);
  padding: 3.2rem 2rem 2rem; /* Padding nyaman untuk desktop */
  min-height: 100vh;
}

/* =====================================================
   SIDEBAR (GLOBAL)
===================================================== */

.sidebar {
  width: 270px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background-color: #ffffff;
  border-right: 1px solid #e5e7eb;
  z-index: 1020; /* Penting agar sidebar di atas konten pada desktop */
}

.sidebar-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* =====================================================
   NATIVE SCROLLBAR – MINIMAL & MEPET
===================================================== */

.sidebar-menu {
  flex: 1;
  overflow-y: auto;

  /* penting untuk kesan mepet */
  padding-right: 0;
  scrollbar-gutter: stable;

  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

/* Chrome / Edge / Safari */
.sidebar-menu::-webkit-scrollbar {
  width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
}

/* =====================================================
   SIDEBAR BRANDING
===================================================== */

.sidebar-heading {
  padding: 2rem 1rem 2rem;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.4;
  color: #435ebe;
  /* --- Perubahan Kunci (untuk menyelaraskan logo dan tombol) --- */
  display: flex; /* Aktifkan Flexbox */
  justify-content: space-between; /* Jaga logo di kiri, tombol di kanan */
  align-items: flex-start; /* Pastikan item sejajar dari atas */
  /* ------------------------------------------------------------- */
}

.sidebar-heading a {
  color: inherit;
  display: block;
}

.sidebar-heading a:hover {
  color: inherit;
}

/* =====================================================
   SIDEBAR CLOSE BUTTON (Baru)
===================================================== */
.btn-close-sidebar {
 background: none;
 border: none;
 font-size: 1.5rem;
 font-weight: 300;
 line-height: 1;
 color: #6c757d;
 cursor: pointer;
 padding: 0;
 /* Margin atas disesuaikan agar tombol '✕' sejajar dengan baris pertama teks */
 margin-top: 0.1rem; /* Sesuaikan nilai ini (misalnya 0.1rem atau -0.1rem) */
 transition: color 0.15s ease-in-out;
}

.btn-close-sidebar:hover {
 color: #495057;
}

/* =====================================================
   SIDEBAR MENU
===================================================== */

.sidebar-section-title {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  color: #6c757d;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 1rem;
}

.sidebar .nav-link {
  padding: 0.75rem 1rem;
  color: #435ebe;
  font-weight: 500;
  display: flex;
  align-items: center;
  transition: background-color 0.15s ease-in-out;
}

.sidebar .nav-link i {
  margin-right: 0.6rem;
  width: 1.2rem;
  text-align: center;
}

.sidebar .nav-link:hover {
  background-color: #f1f5ff;
  color: #0d6efd;
}

/* dropdown arrow */
.dropdown-arrow {
  margin-left: auto;
  transition: transform 0.3s ease;
}

.nav-link[aria-expanded="true"] .dropdown-arrow {
  transform: rotate(90deg);
}

/* submenu */
.submenu-content .nav-link {
  padding-left: 2.8rem;
  font-size: 0.9rem;
}

.submenu-content .nav-link:hover {
  background-color: #e2eafc;
}

/* =====================================================
   SIDEBAR LOGOUT
===================================================== */

.sidebar-logout {
  padding: 1rem;
  border-top: 1px solid #e5e7eb;
  background-color: #ffffff;
}

.btn-logout {
  width: 100%;
  background-color: #dc3545;
  color: #ffffff;
  font-weight: 600;
  border-radius: 0.5rem;
}

.btn-logout:hover {
  background-color: #bb2d3b;
  color: #ffffff;
}

/* =====================================================
   PAGE SPECIFIC STYLE
===================================================== */

/* === PAGE: DASHBOARD === */
/* .page-dashboard .card { } */

/* === PAGE: KARYAWAN === */
/* .page-karyawan .table { } */

/* =====================================
   RESPONSIVE GLOBAL (MOBILE)
===================================== */

@media (max-width: 991.98px) {
  .app-layout {
    position: relative;
  }

  .sidebar {
    /* Lebar dan posisi disesuaikan agar cocok untuk menu pop-out */
    position: fixed;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: #fff;
    z-index: 2000; /* Ditingkatkan agar muncul di atas semua konten */
    transition: left 0.3s ease;
    pointer-events: auto;
  }

  .sidebar.show {
    left: 0;
  }

  /* Konten utama mengambil lebar penuh dan padding disesuaikan */
  .main-content {
    margin-left: 0; /* Hapus margin kiri agar mengambil lebar penuh */
    width: 100%;
    padding: 1.5rem 1rem 1rem; /* Padding lebih kecil untuk mobile */
    position: relative;
    z-index: 1;
  }
}

@media (max-width: 576px) {
  h3 {
    font-size: 1.3rem;
  }

  .card-body h2 {
    font-size: 1.6rem;
  }
}

.table-responsive {
  -webkit-overflow-scrolling: touch;
}
