@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --white: #ffffff;
  --bg: #f5f7fb;
  --bg-card: #ffffff;
  --border: #eef0f5;
  --border-light: #f2f4f9;
  --text: #1a2332;
  --text-secondary: #6b7a99;
  --text-muted: #9aa6b9;
  --primary: #4f6ef7;
  --primary-light: #eef1fe;
  --primary-dark: #3b56d6;
  --success: #22c55e;
  --success-light: #e6f9ef;
  --warning: #f59e0b;
  --warning-light: #fef4e6;
  --danger: #ef4444;
  --danger-light: #fde8e8;
  --info: #3b82f6;
  --info-light: #e8f0fe;
  --gray-50: #f8f9fc;
  --gray-100: #f1f3f8;
  --gray-200: #e5e7ef;
  --gray-300: #d1d5db;
  --sidebar-width: 250px;
  --topbar-height: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.03);
  --shadow-md: 0 4px 12px rgba(0,0,0,.04), 0 2px 4px rgba(0,0,0,.02);
  --transition: .2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: .875rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ===== SIDEBAR HIDDEN (desktop toggle) ===== */
body.sidebar-hidden .sidebar { transform: translateX(-100%); }
body.sidebar-hidden .main-content { margin-left: 0; }
body.sidebar-hidden .topbar { left: 0; }

.sidebar, .main-content, .topbar { transition: all .25s ease; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border);
  z-index: 1040;
  transition: transform var(--transition);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 22px 16px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-brand:hover { color: var(--text); }

.sidebar-brand .brand-icon {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #fff;
}

.sidebar-nav { flex: 1; padding: 8px 0; }
.sidebar-nav .nav-item { margin: 0 8px; }

.sidebar-heading {
  padding: 20px 18px 6px;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
}

.sidebar .nav-link {
  color: var(--text-secondary);
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  text-decoration: none;
  transition: all .15s;
}

.sidebar .nav-link:hover {
  background: var(--gray-100);
  color: var(--text);
}

.sidebar .nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.sidebar .nav-link i { font-size: 1.05rem; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar .nav-link .chevron {
  margin-left: auto;
  font-size: .65rem;
  transition: transform var(--transition);
  color: var(--text-muted);
}

.sidebar .nav-link[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.sidebar .collapse .nav-link {
  padding-left: 42px;
  font-size: .82rem;
  border-left: 2px solid transparent;
  border-radius: 0;
  margin-left: 18px;
}

.sidebar .collapse .nav-link.active {
  border-left-color: var(--primary);
  background: transparent;
}

.sidebar-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-footer small { color: var(--text-muted); font-size: .75rem; }

/* ===== TOPBAR ===== */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: rgba(255,255,255,.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 1035;
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 12px;
  transition: left var(--transition);
}

.topbar-brand { display: none; font-weight: 700; font-size: 1rem; color: var(--text); }

.sidebar-toggle {
  display: block;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
}

.sidebar-toggle:hover { background: var(--gray-100); }

.topbar .breadcrumb {
  margin-bottom: 0;
  font-size: .8rem;
}

.topbar .breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }

.topbar .breadcrumb-item a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
}

.topbar .breadcrumb-item a:hover { color: var(--primary); }
.topbar .breadcrumb-item.active { color: var(--text); font-weight: 600; }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 28px 32px;
  min-height: calc(100vh - var(--topbar-height));
  transition: margin-left var(--transition);
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
  margin-bottom: 0;
}

/* ===== STAT CARDS ===== */
.stat-row { margin-bottom: 24px; }

.stat-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: all var(--transition);
  height: 100%;
}

.stat-card:hover {
  border-color: var(--gray-300);
  box-shadow: var(--shadow-md);
}

.stat-card .card-body { padding: 1.25rem 1.5rem; }

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.stat-card .stat-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

/* ===== REPORT TABLE ===== */
.report-table tbody td { font-size: .82rem; padding: .55rem .7rem !important; }
.report-table tfoot td { font-size: .82rem; padding: .65rem .7rem !important; }
.report-table thead th { font-size: .7rem; padding: .6rem .7rem !important; }
.report-table td.border-end, .report-table th.border-end { border-right: 1px solid var(--border) !important; }
.report-table td.border-start, .report-table th.border-start { border-left: 1px solid var(--border) !important; }

/* ===== CARDS ===== */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: .85rem 1.25rem;
  font-weight: 600;
  font-size: .85rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 1.25rem; }

/* ===== TABLES ===== */
.table { margin-bottom: 0; }

.table > :not(caption) > * > * {
  padding: .7rem .85rem;
  vertical-align: middle;
  border-bottom-color: var(--border-light);
}

.table thead th {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  background: var(--gray-50);
  border-bottom: 1px solid var(--border) !important;
  white-space: nowrap;
  padding: .65rem .85rem;
}

.table tbody td { font-size: .84rem; color: var(--text); }
.table tbody tr:hover { background: var(--gray-50); }
.table tbody tr[onclick]:hover { background: #dbeafe; cursor: pointer; transition: all .12s; }
.table tbody tr[onclick]:hover td { color: var(--text); }
.table tbody tr[onclick]:hover code { background: #fff; border-color: var(--primary); }
.table tbody tr[onclick]:hover td:first-child { border-left: 3px solid var(--primary); padding-left: calc(0.85rem - 3px); }
.table code { font-size: .78rem; background: var(--gray-100); padding: 2px 6px; border-radius: 4px; color: var(--text); }

/* DataTables toolbar */
.dt-toolbar { background: var(--gray-50); }

.dt-toolbar .dataTables_filter { margin-bottom: 0 !important; }

.dt-toolbar .dataTables_filter label { margin-bottom: 0; display: flex; align-items: center; }

.dt-toolbar .dataTables_filter input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px 5px 28px;
  font-size: .8rem;
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239aa6b9' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") no-repeat 9px center;
  width: 170px;
  transition: all .15s;
}

.dt-toolbar .dataTables_filter input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(79,110,247,.1);
  width: 210px;
}

.dt-toolbar .dataTables_length label {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.dt-toolbar .dataTables_length select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: .8rem;
  width: auto;
  min-width: 60px;
}

/* DataTables info & pagination */
div.dataTables_wrapper div.dataTables_info {
  font-size: .8rem;
  color: var(--text-muted);
}

div.dataTables_wrapper div.dataTables_paginate {
  display: flex;
  align-items: center;
  gap: 2px;
}

div.dataTables_wrapper .pagination .page-item .page-link {
  padding: 5px 11px;
  font-size: .8rem;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--white);
  margin: 0 2px;
  transition: all .12s;
}

div.dataTables_wrapper .pagination .page-item .page-link:hover {
  background: var(--gray-100);
  border-color: var(--gray-200);
  color: var(--text);
}

div.dataTables_wrapper .pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

div.dataTables_wrapper .pagination .page-item.disabled .page-link {
  background: var(--gray-50);
  border-color: var(--border);
  color: var(--text-muted);
  opacity: .5;
}

/* Chart wrapper */
.chart-wrapper {
  position: relative;
  height: 260px;
  width: 100%;
}

/* ===== BADGES ===== */
.badge-online {
  background: var(--success-light);
  color: #15803d;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: .75rem;
}

.badge-offline {
  background: var(--danger-light);
  color: #b91c1c;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: .75rem;
}

/* ===== FORMS ===== */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  padding: .5rem .75rem;
  font-size: .85rem;
  transition: all .15s;
  background: var(--white);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79,110,247,.1);
}

.form-label {
  font-weight: 500;
  font-size: .82rem;
  color: var(--text);
  margin-bottom: 4px;
}

/* Select2 — pastikan border terlihat */
.select2-container--bootstrap-5 .select2-selection {
  border: 1px solid var(--gray-200) !important;
  border-radius: var(--radius-sm) !important;
  min-height: 36px;
}

.select2-container--bootstrap-5 .select2-selection:hover {
  border-color: var(--gray-300) !important;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(79,110,247,.1) !important;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
  color: var(--text);
  font-size: .85rem;
  line-height: 34px;
  padding-left: 12px;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
  height: 34px;
}

.select2-container--bootstrap-5 .select2-dropdown {
  border-color: var(--gray-200);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.select2-container--bootstrap-5 .select2-results__options {
  max-height: 240px;
  overflow-y: auto;
}

.form-control::placeholder { color: var(--text-muted); font-size: .82rem; }

/* ===== BUTTONS ===== */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  padding: .45rem 1.1rem;
  font-size: .84rem;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

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

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

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

.btn-outline-secondary { color: var(--text-secondary); border-color: var(--gray-200); }
.btn-outline-secondary:hover { background: var(--gray-100); border-color: var(--gray-300); }

.btn-sm { padding: .3rem .65rem; font-size: .78rem; }

/* ===== MAINTENANCE ===== */
.maintenance-card {
  text-align: center;
  padding: 64px 20px;
  border: 1px dashed var(--gray-200);
  border-radius: var(--radius-lg);
  background: var(--gray-50);
}

.maintenance-card i { font-size: 3rem; color: var(--text-muted); margin-bottom: 16px; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 36px 20px;
}

.empty-state i {
  font-size: 2.5rem;
  color: var(--gray-200);
  margin-bottom: 12px;
}

.empty-state h6 {
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 2px; }

/* ===== SIDEBAR BACKDROP ===== */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 1039;
  opacity: 0;
  transition: opacity .2s;
}

.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .topbar { left: 0; }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .topbar-brand { display: block; }
}

@media (max-width: 767.98px) {
  .main-content { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .page-title { font-size: 1.15rem; }
  .stat-card .stat-value { font-size: 1.25rem; }
}

@media (max-width: 575.98px) {
  .main-content { padding: 16px 12px; }
  .card-body { padding: 1rem; }
  .card-header { padding: .7rem 1rem; }
}
