/* ============================================================
   ROOT VARIABLES (AUTO LIGHT/DARK)
============================================================ */
:root {
  --sidebar-w: 260px;
  --sidebar-mini-w: 65px;
  --topbar-h: 65px;

  --bs-body-bg: #ffffff;
  --bs-body-color: #212529;
  --bs-border-color: #eaeaea;
}

/* Dark theme override */
html.dark {
  --bs-body-bg: #0f1113;
  --bs-body-color: #e8eef2;
  --bs-border-color: #222;
}


/* ============================================================
   SIDEBAR
============================================================ */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;

  background: var(--bs-body-bg);
  border-right: 1px solid var(--bs-border-color);
  color: var(--bs-body-color);

  overflow-y: auto;
  transition:
    width 0.45s cubic-bezier(.18, .78, .35, 1.15),
    left 0.45s cubic-bezier(.18, .78, .35, 1.15),
    background-color .35s ease,
    border-color .35s ease;
  z-index: 1050;
}

.sidebar .sidebar-header {
  padding: 7px 16px;
  border-bottom: 1px solid var(--bs-border-color);
}

.sidebar .nav-link {
  color: var(--bs-body-color);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  transition: .15s;
  font-weight: 500;
  white-space: nowrap;
}

.sidebar .nav-link:hover {
  background: rgba(0,0,0,0.05);
  text-decoration: none;
}

.sidebar .nav-link i {
  font-size: 1.1rem;
}

/* Submenu indent */
.submenu .nav-link {
  padding-left: 20px !important;
}

/* Arrow rotate when open */
.nav-link[aria-expanded="true"] .arrow {
  transform: rotate(180deg);
}

.arrow {
  transition: transform 0.3s ease;
}

/* ================= ACTIVE MENU ================= */
.sidebar .nav-link.active {
  background: rgba(99, 161, 255, 0.12);
  color: #000;
  border-radius: 8px;
}

.sidebar .submenu .nav-link.active {
  background: rgba(99, 161, 255, 0.12);
  color: #000;
  font-weight: 600;
}

/* Dark mode */
html.dark .sidebar .nav-link.active {
  background: rgba(77, 163, 255, 0.15);
  color: #4da3ff;
}

html.dark .sidebar .submenu .nav-link.active {
  background: rgba(77, 163, 255, 0.2);
  color: #4da3ff;
}

/* ============================================================
   SIDEBAR MINI MODE
============================================================ */
.sidebar.mini {
  width: var(--sidebar-mini-w) !important;
}

.sidebar.mini .text-sidebar {
  opacity: 0 !important;
  width: 0 !important;
  overflow: hidden;
  white-space: nowrap;
  transition: .2s ease;
}

.sidebar.mini .arrow {
  opacity: 0 !important;
}

.sidebar.mini #toggleMini i {
  transform: rotate(180deg);
}


/* ============================================================
   TOPBAR (MENEMPEL KE SIDEBAR)
============================================================ */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);

  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 0 20px;
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);

  transition:
    left 0.45s cubic-bezier(.18, .78, .35, 1.15),
    background-color .35s ease,
    border-color .35s ease;
  z-index: 1045;
}

/* Topbar mini follow */
.sidebar.mini ~ .topbar {
  left: var(--sidebar-mini-w) !important;
}

.page-title {
  margin: 0;
  font-size: 1.1rem;
  color: var(--bs-body-color);
}


/* ============================================================
   CONTENT AREA
============================================================ */
#content {
  margin-top: var(--topbar-h);
  margin-left: var(--sidebar-w);
  transition: margin-left .25s ease;
}

.sidebar.mini ~ #content {
  margin-left: var(--sidebar-mini-w);
}


/* ============================================================
   OVERLAY (MOBILE)
============================================================ */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;

  width: 100%;
  height: 100vh;

  background: rgba(0,0,0,0.45);
  z-index: 1040;
  display: none;
}

.sidebar-overlay.show {
  display: block;
}

.sidebar.show {
  animation: sidebarSlideIn .45s cubic-bezier(.18, .78, .35, 1.15);
}

@keyframes sidebarSlideIn {
  0%   { transform: translateX(-15px); opacity: .6; }
  100% { transform: translateX(0);     opacity: 1; }
}

.sidebar:not(.mini) {
  animation: sidebarExpand .3s ease-out;
}

@keyframes sidebarExpand {
  from { transform: translateX(-5px); opacity: .95; }
  to   { transform: translateX(0);    opacity: 1;   }
}

/* ============================================================
   MOBILE RESPONSIVE
============================================================ */
@media (max-width: 991px) {

  /* Sidebar jadi slide */
  .sidebar {
    left: -260px !important;
    width: 260px !important;
  }

  .sidebar.show {
    left: 0 !important;
  }

  /* Matikan mini-mode di mobile */
  .sidebar.mini,
  .sidebar.mini:hover {
    width: 260px !important;
  }

  /* TOPBAR harus full width */
  .topbar {
    left: 0 !important;
    width: 100% !important;
  }

  /* Content full */
  #content {
    margin-left: 0 !important;
    width: 100% !important;
  }
}


/* ============================================================
   CARDS, TABLE, UI ELEMENTS (MINIMALIST FLAT)
============================================================ */
.card {
  border: 1px solid var(--bs-border-color);
  border-radius: 10px;
  background: transparent;
}

.table {
  color: var(--bs-body-color) !important;
}


/* ============================================================
   TOOLTIP GLASS STYLE (ONLY WHEN MINI)
============================================================ */
.tooltip {
  opacity: 0 !important;
  pointer-events: none;
  z-index: 9999 !important;
  margin-left: -20px !important;
}

.tooltip.show {
  opacity: 1 !important;
}

@keyframes slideRightFade {
  0% { opacity: 0; transform: translateX(-8px); }
  100% { opacity: 1; transform: translateX(2px); }
}

.tooltip-inner {
  padding: 8px 12px !important;
  font-size: .75rem !important;
  border-radius: 10px !important;

  animation: slideRightFade .25s ease forwards;
  transform: translateX(-8px);

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  border: 1px solid rgba(255,255,255,.15);
  box-shadow: 0 8px 20px rgba(0,0,0,.15);
}

.tooltip-arrow {
  display: none !important;
}

html:not(.dark) .tooltip-inner {
  background: rgba(255,255,255,.75) !important;
  color: #111 !important;
}

html.dark .tooltip-inner {
  background: rgba(0,0,0,.45) !important;
  color: #fafafa !important;
}

.bs-tooltip-auto[data-popper-placement^="right"] > .tooltip-inner,
.bs-tooltip-end[data-popper-placement^="right"] > .tooltip-inner {
  margin-left: -20px !important; /* versi popper baru */
}

/* ============================================================
   DARK MODE — FULL COVERAGE FIX
============================================================ */

html.dark body {
  background: #111 !important;
  color: #e8eef2 !important;
}

/* Sidebar */
html.dark .sidebar {
  background: #141414 !important;
  border-right-color: #222 !important;
}

html.dark .sidebar .nav-link {
  color: #e8eef2 !important;
}

html.dark .sidebar .nav-link:hover {
  background: #1f1f1f !important;
}

/* Submenu */
html.dark .sidebar .submenu .nav-link {
  color: #dcdcdc !important;
}

/* Topbar */
html.dark .topbar {
  background: #141414 !important;
  border-bottom-color: #222 !important;
}

/* Content */
html.dark #content {
  background: #111 !important;
}

/* Cards */
html.dark .card {
  background: #181818 !important;
  border-color: #2a2a2a !important;
  color: #e8eef2 !important;
}

/* Table */
html.dark table {
  color: #e8eef2 !important;
}

html.dark .table > :not(caption) > * > * {
  background-color: #1a1a1a !important;
  border-color: #333 !important;
}

/* Borders */
html.dark,
html.dark * {
  --bs-border-color: #2a2a2a !important;
}

/* Search Bar */
html.dark .search-topbar {
  background: #1c1c1c !important;
  color: #fff !important;
  border-color: #333 !important;
}

html.dark .search-topbar::placeholder {
  color: #aaa !important;
}

/* Buttons */
html.dark .btn-outline-secondary {
  color: #e8eef2 !important;
  border-color: #444 !important;
}

html.dark .btn-outline-secondary:hover {
  background: #222 !important;
}

/* Collapse arrows */
html.dark .arrow {
  color: #ccc !important;
}

/* =====================================================
   FIX: POSISI TOGGLE SELALU DI ATAS SAAT SIDEBAR MINI
===================================================== */

.sidebar-header {
  position: relative;
  z-index: 10;
}

/* Pastikan tombol toggle tetap di atas */
#toggleMini {
  position: relative;
  z-index: 20;
}

/* Mode mini membutuhkan posisi absolute agar tidak turun */
.sidebar.mini #toggleMini {
  position: absolute;
  top: 15px;
  right: 12px;
}

/* Agar icon tidak hilang saat mini */
.sidebar.mini #toggleMini i {
  margin: 0;
}

/* ============================================================
   FIX CARD, CONTAINER, SECTION AGAR IKUT TEMA LIGHT / DARK
============================================================= */

/* LIGHT MODE */
html:not(.dark) .card {
  background: rgba(255, 255, 255, 0.9) !important;
  color: var(--bs-body-color) !important;
  border-color: var(--bs-border-color) !important;
}

/* DARK MODE */
html.dark .card {
  background: rgba(255, 255, 255, 0.03) !important;
  color: #e8eef2 !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Card body text */
html.dark .card p,
html.dark .card span {
  color: #cfd5da !important;
}

/* Card title */
html.dark .card .card-title,
html.dark h2,
html.dark h3,
html.dark h4 {
  color: #ffffff !important;
}


/* ============================================================
   FIX BACKGROUND HALAMAN UTAMA (CONTENT SECTION)
============================================================= */

html.dark body,
html.dark #content {
  background: var(--bs-body-bg) !important;
}

html:not(.dark) body,
html:not(.dark) #content {
  background: var(--bs-body-bg) !important;
}


/* ============================================================
   FIX BORDER YANG MASIH TERANG DI DARK MODE
============================================================= */
html.dark .border,
html.dark .card,
html.dark .content {
  border-color: rgba(255, 255, 255, 0.12) !important;
}

/* ===========================================
   THEME SWITCH ANIMATION (SUN <-> MOON)
=========================================== */
.theme-switch {
  position: relative;
  width: 46px;
  height: 24px;
  background: var(--bs-border-color);
  border-radius: 30px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-switch-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--bs-body-bg);
  border-radius: 50%;
  transition: transform 0.35s cubic-bezier(.4, 0, .2, 1),
              background 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

/* icon di dalam bulatan */
.theme-switch-slider i {
  position: absolute;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* posisi moon/sun */
.theme-switch .sun   { opacity: 1; transform: scale(1); }
.theme-switch .moon  { opacity: 0; transform: scale(0.4); }

/* SWITCH ON (dark mode) */
.theme-switch input:checked + .theme-switch-slider {
  transform: translateX(22px);
}

/* Swap animasi ikon */
.theme-switch input:checked + .theme-switch-slider .sun  {
  opacity: 0; transform: scale(0.4);
}
.theme-switch input:checked + .theme-switch-slider .moon {
  opacity: 1; transform: scale(1);
}

/* Mode dark: warna switch sedikit berbeda */
html.dark .theme-switch {
  background: #444;
}

/* ===========================================
   ANIMASI TRANSISI TEMA UTAMA (GLOBAL)
=========================================== */
html, body, .sidebar, .topbar, #content, .card {
  transition: background-color 0.35s ease,
              color 0.35s ease,
              border-color 0.35s ease;
}

/* Tambahan smooth pada hover dan icon */
.sidebar .nav-link i,
.sidebar .nav-link,
.topbar, 
.card {
  transition: color 0.35s ease, background-color 0.35s ease;
}

/* ============================================================
   PREMIUM SIDEBAR SLIDE / RESIZE TRANSITION
============================================================ */

.sidebar {
  transition:
    width 0.38s cubic-bezier(.25, .1, .25, 1),
    left 0.38s cubic-bezier(.25, .1, .25, 1),
    background-color 0.32s ease,
    border-color 0.32s ease,
    transform 0.38s cubic-bezier(.25, .1, .25, 1);
}

/* Saat mini, smooth shrink */
.sidebar.mini {
  width: var(--sidebar-mini-w) !important;
  overflow-x: hidden;
}

/* MOBILE: slide-in halus */
@media (max-width: 991px) {
  .sidebar {
    left: -260px;
    transition:
      left 0.38s cubic-bezier(.25, .1, .25, 1),
      background-color 0.32s ease;
  }

  .sidebar.show {
    left: 0;
  }
}

/* ToggleMini button animasi */
#toggleMini i {
  transition: transform 0.35s ease;
}

.sidebar.mini #toggleMini i {
  transform: rotate(180deg);
}

/* Lebih smooth saat sidebar muncul (desktop hover / mobile slide) */
@keyframes sidebarSmoothSlide {
  0%   { transform: translateX(-12px); opacity: 0.7; }
  100% { transform: translateX(0);     opacity: 1;   }
}

.sidebar.show,
.sidebar:not(.mini) {
  animation: sidebarSmoothSlide .35s cubic-bezier(.18, .78, .35, 1.1);
}

.sidebar:not(.mini) {
  animation: expandSidebar 0.32s ease-out;
}

/* ============================================================
   ELASTIC SIDEBAR + TOPBAR + CONTENT TRANSITION
============================================================ */

.sidebar,
.topbar,
#content {
  transition:
    width .55s cubic-bezier(.34, 1.56, .64, 1),
    left .55s cubic-bezier(.34, 1.56, .64, 1),
    margin-left .55s cubic-bezier(.34, 1.56, .64, 1),
    transform .55s cubic-bezier(.34, 1.56, .64, 1),
    background-color .35s ease,
    border-color .35s ease;
}

.sidebar.mini {
  width: var(--sidebar-mini-w) !important;
  transform: translateX(0);
}

/* Topbar ikut mengecil */
.sidebar.mini ~ .topbar {
  left: var(--sidebar-mini-w) !important;
}

/* Konten ikut mengecil */
.sidebar.mini ~ #content {
  margin-left: var(--sidebar-mini-w) !important;
  width: calc(100% - var(--sidebar-mini-w)) !important;
}

.sidebar:not(.mini) {
  width: var(--sidebar-w);
  transform: translateX(0);
}

.sidebar:not(.mini) ~ .topbar {
  left: var(--sidebar-w);
}

.sidebar:not(.mini) ~ #content {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
}

@media (max-width: 991px) {

  .sidebar {
    left: -260px;
    transition: left .55s cubic-bezier(.34, 1.56, .64, 1);
  }

  .sidebar.show {
    left: 0;
  }

  /* topbar tetap full */
  .topbar {
    left: 0 !important;
  }
}

/* ============================================================
   SMOOTH SIDEBAR OPEN / CLOSE ANIMATION
============================================================ */
.sidebar {
  transition:
    width .45s cubic-bezier(.25, .45, .25, 1),
    left .45s cubic-bezier(.25, .45, .25, 1),
    transform .45s cubic-bezier(.25, .45, .25, 1),
    background-color .35s ease,
    border-color .35s ease;
}

/* MINIMIZE (desktop) */
.sidebar.mini {
  width: var(--sidebar-mini-w) !important;
  transform: translateX(0);
}

/* EXPAND (desktop) */
.sidebar:not(.mini) {
  width: var(--sidebar-w);
}

/* Mobile slide-in */
@media (max-width: 991px) {

  .sidebar {
    left: -260px;
    transform: translateX(-8px);
    opacity: .85;
  }

  .sidebar.show {
    left: 0;
    transform: translateX(0);
    opacity: 1;
  }
}

/* Bounce halus untuk open */
@keyframes sidebarOpenSmooth {
  0%   { transform: translateX(-12px); opacity: 0; }
  70%  { transform: translateX(3px);  opacity: 1; }
  100% { transform: translateX(0);    opacity: 1; }
}

.sidebar-opening {
  animation: sidebarOpenSmooth .45s cubic-bezier(.25, .45, .25, 1);
}

/* Logo wrapper */
.brand-logo {
  width: 100px;
  height: 50px;
  overflow: hidden;
  border-radius: 8px;
  margin-left: 50px;
}

/* Logo image */
.brand-logo img.logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity .25s ease, transform .25s ease;
}

.sidebar.mini .brand-logo img {
  transform: scale(0.92);
}

/* =======================================================
   MODERN TOAST (GLASS + SLIDE-UP FROM BOTTOM-RIGHT)
======================================================= */
.toast-custom {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 12px 18px;
  color: var(--bs-body-color);
  border: 1px solid rgba(255,255,255,0.18);
  min-width: 260px;
  animation: toastSlideUp .45s cubic-bezier(.25,.8,.25,1) forwards;
  opacity: 0;
  transform: translateY(20px);
}

/* Light mode */
html:not(.dark) .toast-custom {
  background: rgba(255,255,255,0.85);
  color: #111;
}

/* Dark mode */
html.dark .toast-custom {
  background: rgba(20,20,20,0.65);
  color: #eaeaea;
}

/* Toast border colors */
.toast-success { border-left: 6px solid #28a745; }
.toast-error   { border-left: 6px solid #dc3545; }
.toast-warning { border-left: 6px solid #ffc107; }
.toast-info    { border-left: 6px solid #0d6efd; }

/* Slide-up animation */
@keyframes toastSlideUp {
  0%   { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   LOADING INDICATOR (Modern Glass + Auto Dark)
============================================================ */
.global-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  background: rgba(0,0,0,0.15);
  opacity: 0;
  pointer-events: none;
  z-index: 99999;
  transition: opacity .25s ease;
}

.global-loader.show {
  opacity: 1;
  pointer-events: auto;
}

.loader-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid transparent;
  border-top-color: var(--bs-primary);
  border-radius: 50%;
  animation: spinLoader 0.8s linear infinite;
}

@keyframes spinLoader {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.loader-text {
  margin-top: 12px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--bs-body-color);
}

/* Dark Mode */
html.dark .global-loader {
  background: rgba(255,255,255,0.05);
}

html.dark .loader-spinner {
  border-top-color: #4dabf7; /* blue-300 */
}

html.dark .loader-text {
  color: #e9ecef;
}

/* ============================================================
   GLOBAL PROGRESS BAR — ultrathin loading indicator
============================================================ */
.global-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  z-index: 99999;
  background: var(--progress-color, #0d6efd);
  box-shadow: 0 0 8px var(--progress-color, #0d6efd);
  transition: width 0.35s ease, opacity 0.4s ease;
  opacity: 0;
}

/* Light mode color */
html:not(.dark) .global-progress {
  --progress-color: #0d6efd;
}

/* Dark mode color */
html.dark .global-progress {
  --progress-color: #4da3ff;
}

/* Shimmer animation */
@keyframes progressShimmer {
  0%   { box-shadow: 0 0 4px var(--progress-color); }
  50%  { box-shadow: 0 0 14px var(--progress-color); }
  100% { box-shadow: 0 0 4px var(--progress-color); }
}

.global-progress.active {
  animation: progressShimmer 1.2s infinite ease-in-out;
}

/* Input iOS */
.ios-block {
    pointer-events: none; 
}

.readonly-lock {
  background: var(--bs-secondary-bg) !important;
  opacity: 0.85;
  cursor: not-allowed;
}

.btn-group .btn {
  padding: 3px 8px;
}
td .btn-group-sm i {
  font-size: 14px;
}
