:root {
  /* Layout */
  --sidebar-width: 280px;
  --header-height: 60px;

  /* Main Color Scheme - Red Theme */
  --color-primary: #dc3545;
  --color-primary-light: #e4606d;
  --color-primary-lighter: #ec8c97;
  --color-primary-dark: #a71d2a;
  --color-primary-darker: #721c24;

  /* Accent Colors */
  --color-accent: #ff6b6b;
  --color-accent-light: #ff8e8e;
  --color-accent-dark: #e64c4c;

  /* Text Colors */
  --color-text: #212529;
  --color-text-light: #6c757d;
  --color-text-lighter: #adb5bd;

  /* Background Colors */
  --color-bg: #ffffff;
  --color-bg-secondary: #f4f4f4;
  --color-bg-tertiary: #e9ecef;

  /* Border Colors */
  --color-border: #dee2e6;
  --color-border-light: #e9ecef;
  --color-border-dark: #ced4da;

  /* Status Colors */
  --color-success: #28a745;
  --color-warning: #ffc107;
  --color-danger: #dc3545;
  --color-info: #17a2b8;
  --color-primary-soft: rgba(220, 53, 69, 0.1);
  --color-success-soft: rgba(40, 167, 69, 0.1);
  --color-danger-soft: rgba(220, 53, 69, 0.1);
  --color-info-soft: rgba(23, 162, 184, 0.1);
  --color-warning-soft: rgba(255, 193, 7, 0.1);
}

/* Dark Theme */
[data-bs-theme="dark"] {
  /* Main Colors */
  --color-primary: #ff6b6b;
  --color-primary-light: #ff8e8e;
  --color-primary-lighter: #ffb3b3;
  --color-primary-dark: #e64c4c;
  --color-primary-darker: #cc3333;

  /* Accent Colors */
  --color-accent: #ff8e8e;
  --color-accent-light: #ffb3b3;
  --color-accent-dark: #e64c4c;

  /* Text Colors */
  --color-text: #f0f6fc;
  --color-text-light: #8b949e;
  --color-text-lighter: #6e7681;

  /* Background Colors */
  --color-bg: #1a1d21;
  --color-bg-secondary: #24292e;
  --color-bg-tertiary: #2f363d;

  /* Border Colors */
  --color-border: #30363d;
  --color-border-light: #3b424a;
  --color-border-dark: #484f58;

  /* Status Colors */
  --color-success: #2ea043;
  --color-warning: #d29922;
  --color-danger: #f85149;
  --color-info: #58a6ff;
  --color-primary-soft: rgba(255, 107, 107, 0.15);
  --color-success-soft: rgba(46, 160, 67, 0.15);
  --color-danger-soft: rgba(248, 81, 73, 0.15);
  --color-info-soft: rgba(88, 166, 255, 0.15);
  --color-warning-soft: rgba(210, 153, 34, 0.15);
}

/* ========== DARK MODE ========== */
[data-bs-theme="dark"] .card {
  border-color: var(--color-border);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: var(--color-bg-secondary);
  border-color: var(--color-border);
  color: var(--color-text);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: var(--color-bg-secondary);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 0.25rem rgba(255, 107, 107, 0.25);
}

[data-bs-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-bs-theme="dark"] .table th,
[data-bs-theme="dark"] .table td {
  border-color: var(--color-border);
}

/* ========== GLOBAL ========== */
body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  transition: all 0.3s ease;
  background-color: var(--color-bg);
  color: var(--color-text);
}

/* ========== NAVBAR & SIDEBAR ========== */
.header {
  background-color: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-height);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1040;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.sidebar {
  background-color: var(--color-bg);
  border-right: 1px solid var(--color-border);
  color: var(--color-text);
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  overflow-x: hidden;
  transform: translateX(-100%);
  transition: all 0.3s ease;
  z-index: 1030;
  display: flex;
  flex-direction: column;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 60px;
  /* Space for the fixed footer */
}

.sidebar-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 0.5rem;
  font-weight: bold;
  background-color: var(--color-bg);
  border-top: 1px solid var(--color-border);
  z-index: 1040;
}

.sidebar.show {
  transform: translateX(0);
}

.nav-item-main {
  padding: 0 1.5rem;
  margin-top: 0.5rem;
  font-weight: bold;
  color: var(--color-primary);
}

.nav-item {
  margin: 0.1rem;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  margin: 0 0.5rem;
  border-radius: 6px;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  transition: all 0.5s ease;
  position: relative;
  cursor: pointer;
}

.nav-link:hover {
  background-color: var(--color-bg-tertiary);
  color: var(--color-primary);
}

.nav-link.active {
  background-color: var(--color-primary) !important;
  color: white !important;
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.2);
}

.nav-link i {
  width: 20px;
  margin-right: 12px;
  font-size: 1.1rem;
  color: var(--color-text-light);
  transition: all 0.2s ease;
}

.nav-link:hover i,
.nav-link.active i {
  color: inherit;
}

/* Submenu */
.submenu {
  padding-left: 0;
  margin-left: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 1s ease;
  background-color: rgba(0, 0, 0, 0.02);
  border-radius: 0 0 8px 8px;
}

.submenu.show {
  max-height: 500px;
  transition: max-height 2s ease;
}

.submenu .nav-link {
  padding: 0.5rem 0 0.5rem 3rem;
  font-size: 0.9rem;
}

.nav-dropdown-toggle::after {
  content: "\F285";
  font-family: "bootstrap-icons";
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--color-text-light);
  transition: transform 1s ease;
  border: none;
}

.nav-dropdown-toggle.show::after {
  transform: rotate(90deg);
  color: var(--color-primary);
}

/* ========== DROPDOWN MENU ========== */
.dropdown-menu {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.dropdown-item {
  color: var(--color-text);
  padding: 0.5rem 1.5rem;
  transition: all 0.2s ease;
}

.dropdown-item:hover {
  background-color: var(--color-bg-tertiary);
  color: var(--color-primary);
}

/* ========== MAIN CONTENT ========== */
.main-content {
  margin: var(--header-height) 0;
  padding: 1rem;
  background-color: var(--color-bg-secondary);
  min-height: calc(100vh - var(--header-height));
  transition: all 0.3s ease;
}

.main-content.sidebar-open {
  margin-left: var(--sidebar-width);
}

/* ========== FORMS ========== */
.form-control,
.form-select {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

/* ========== THEME TOGGLE BUTTON ========== */
.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 1.1rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s ease;
  cursor: pointer;
}

.theme-toggle-btn:hover {
  background-color: var(--color-bg-tertiary);
  color: var(--color-primary);
  border-color: var(--color-primary-light);
}

.dark-theme .theme-toggle-btn {
  color: var(--color-text-light);
  border-color: var(--color-border-dark);
}

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

/* ========== LOADING SPINNER ========== */
.spinner-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: var(--color-bg-tertiary);
  display: grid;
  place-items: center;
  z-index: 99999;
  opacity: 1;
  overflow: hidden;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.5rem;
  background: var(--color-bg-secondary);
  border-radius: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  width: auto;
  min-width: 240px;
  max-width: 85vw;
  border: 1px solid var(--color-border-light);
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid var(--color-bg-tertiary);
  border-radius: 50%;
  border-top-color: var(--color-primary);
  animation: spin 0.8s ease-in-out infinite;
  margin: 0 auto 1.5rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.loading-text {
  color: var(--color-text);
  font-size: 1.1rem;
  font-weight: 500;
  margin-top: 1rem;
  letter-spacing: 0.5px;
  animation: pulse 1.5s infinite alternate;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* ========== KEYFRAMES ========== */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0% {
    opacity: 0.7;
    transform: scale(0.98);
    color: var(--color-text-light);
  }

  100% {
    opacity: 1;
    transform: scale(1);
    color: var(--color-primary);
  }
}

/* ========== PLACEHOLDER ========== */

::-webkit-input-placeholder {
  color: var(--color-text-lighter) !important;
}

::-moz-placeholder {
  color: var(--color-text-lighter) !important;
}

/* ========== BOTTOM NAVIGATION (MOBILE) ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 65px;
  background-color: var(--color-bg);
  border-top: 1px solid var(--color-border);
  display: none;
  /* Sembunyikan di desktop */
  justify-content: space-around;
  align-items: center;
  z-index: 1040;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  padding: 0 5px;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  justify-content: center;
  height: 100%;
  position: relative;
}

.bottom-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--color-text-light);
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 500;
  width: 100%;
  transition: all 0.2s ease;
}

.bottom-nav-link i {
  font-size: 1.3rem;
}

.bottom-nav-link.active {
  color: var(--color-primary);
}

.bottom-nav-popup {
  position: absolute;
  bottom: 75px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: var(--color-bg);
  min-width: 220px;
  max-width: 90vw;
  max-height: 70vh;
  overflow-y: auto;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--color-border);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 2001;
}

.bottom-nav-popup.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Specific alignments for side items override the generic center alignment */
.bottom-nav-item:nth-child(1) .bottom-nav-popup,
.bottom-nav-item:nth-child(2) .bottom-nav-popup {
  left: 0;
  transform: translateY(20px);
}

.bottom-nav-item:nth-child(1) .bottom-nav-popup.show,
.bottom-nav-item:nth-child(2) .bottom-nav-popup.show {
  transform: translateY(0) !important;
}

.bottom-nav-item:nth-last-child(1) .bottom-nav-popup,
.bottom-nav-item:nth-last-child(2) .bottom-nav-popup {
  left: auto;
  right: 0;
  transform: translateY(20px);
}

.bottom-nav-item:nth-last-child(1) .bottom-nav-popup.show,
.bottom-nav-item:nth-last-child(2) .bottom-nav-popup.show {
  transform: translateY(0) !important;
}

.popup-header {
  padding: 10px 15px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-lighter);
  background-color: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border-light);
}

.bottom-nav-popup a {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--color-border-light);
  transition: background 0.2s;
}

.bottom-nav-popup a:last-child {
  border-bottom: none;
}

.bottom-nav-popup a:active,
.bottom-nav-popup a.active {
  background-color: var(--color-bg-tertiary);
  color: var(--color-primary);
  font-weight: 600;
}

.bottom-nav-popup a i {
  margin-right: 12px;
  font-size: 1.1rem;
  color: var(--color-primary);
}

[data-bs-theme="dark"] .bottom-nav {
  background-color: var(--color-bg-secondary);
}

[data-bs-theme="dark"] .bottom-nav-popup {
  background-color: var(--color-bg-secondary);
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.4);
}

/* Utility to override Bootstrap colors if needed */

:-ms-input-placeholder {
  color: var(--color-text-lighter) !important;
}

:-moz-placeholder {
  color: var(--color-text-lighter) !important;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-light);
}

/* ========== SCROLL TO TOP ========== */
.scroll-progress {
  position: fixed;
  right: 20px;
  bottom: 120px;
  height: 46px;
  width: 46px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--color-border);
  z-index: 1054;
  opacity: 0;
  visibility: hidden;
  transform: translateY(15px);
  transition: all 200ms linear;
  background-color: var(--color-bg);
}

.scroll-progress.active-progress {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-progress i {
  font-size: 24px;
  color: var(--color-primary);
  transition: all 200ms linear;
  z-index: 1;
}

.scroll-progress:hover i {
  color: var(--color-primary-dark);
}

.scroll-progress svg.progress-circle {
  position: absolute;
  left: 0;
  top: 0;
}

.scroll-progress svg.progress-circle path {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 4;
  box-sizing: border-box;
  transition: all 200ms linear;
}

.card-stat {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-stat:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.12);
}
 
/* ========== RESPONSIVE (TABLET < 991px) ========== */
@media (max-width: 991.98px) {

  /* Sembunyikan elemen desktop */
  .header,
  .sidebar,
  .sidebar-footer,
  #sidebarToggle {
    display: none !important;
  }

  /* Tampilkan elemen mobile */
  .bottom-nav {
    display: flex !important;
  }

  /* Penyesuaian Konten Utama */
  .main-content {
    background-color: var(--color-bg);
    margin-top: .5rem !important;
    margin-left: 0 !important;
    margin-bottom: 75px !important;
    padding: 0 !important;
  }

  /* Optimasi Baris Statistik */
  .stat-row .card-body {
    padding: 0.6rem 0.75rem !important;
  }

  .stat-row .small {
    font-size: 0.5rem !important;
    margin-bottom: 2px;
  }

  .stat-row h5 {
    font-size: 0.75rem !important;
    white-space: nowrap;
  }

  .stat-row .rounded-circle {
    width: 28px !important;
    height: 28px !important;
  }

  .chart-wrapper {
    height: 180px !important;
  }

  .card-dawn {
    border: none;
  }

  /* Optimasi Dashboard */
  .card-stat .card-body {
    padding: 0.6rem 0.75rem !important;
  }

  .card-stat p {
    font-size: 0.65rem !important;
    margin-bottom: 2px !important;
  }

  .card-stat h4 {
    font-size: 1.2rem !important;
    margin: 0 !important;
  }

  .font-35 {
    font-size: 1.2rem !important;
  }

  .table-responsive .table {
    font-size: 0.75rem !important;
  }

  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    text-align: center !important;
    float: none !important;
    display: flex;
    justify-content: center;
    margin: 10px 0;
  }

  /* ========== MOBILE CARD VIEW SYSTEM ========== */
  .card-mobile {
    zoom: .8;
  }
  .mobile-card-container {
    zoom: .9;
    display: grid;
    gap: 0.1rem;
    padding: 0.5rem 0;
  }

  .card {
    box-shadow: none !important;
  }

  .card-header h3, .card-header h5 {
    font-size: 1rem;
  }

  .card-header button, .modal-footer button {
    font-size: 0.8rem !important;
  }

  .data-card {
    background: var(--color-bg);
    padding: 0.4rem;
    position: relative;
    transition: transform 0.2s ease;
  }

  /* Efek striped untuk baris selang-seling */
  .data-card:nth-child(odd) {
    background: var(--color-bg);
  }

  .data-card:nth-child(even) {
    background: var(--color-bg-secondary);
  }

  /* Background hijau saat collapse terbuka */
  .data-card:has(.collapse.show) {
    background-color: var(--color-info-soft);
  }

  .data-card:active {
    transform: scale(0.99);
  }

  .data-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.4rem;
  }

  .data-card-title {
    font-size: 0.80rem;
    color: var(--color-primary);
    margin: 0;
    line-height: 1.2;
  }

  .data-card-body {
    display: grid;
    gap: 0.35rem;
  }

  .data-card-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--color-text-light);
    line-height: 1.2;
  }

  .data-card-info i {
    color: var(--color-primary);
    font-size: 0.85rem;
    width: 14px;
    text-align: center;
  }

  .data-card-actions {
    display: flex;
    gap: 0.4rem;
  }

  .data-card-actions .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.4rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
  }

  .data-card-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
  }

  .desktop-view-only {
    display: none !important;
  }
}

/* ========== SOFT BADGES ========== */
.bg-primary-soft { background-color: var(--color-primary-soft) !important; color: var(--color-primary) !important; }
.bg-success-soft { background-color: var(--color-success-soft) !important; color: var(--color-success) !important; }
.bg-warning-soft { background-color: var(--color-warning-soft) !important; color: var(--color-warning) !important; }
.bg-danger-soft { background-color: var(--color-danger-soft) !important; color: var(--color-danger) !important; }
.bg-info-soft { background-color: var(--color-info-soft) !important; color: var(--color-info) !important; }

.badge-soft {
  padding: 0.5em 0.8em;
  font-weight: 600;
  border-radius: 6px;
}

/* Utility for dynamic hiding based on view */
@media (min-width: 992px) {
  .mobile-view-only {
    display: none !important;
  }
}