/* ─── Base ─────────────────────────────────────────────────────────────────── */
html,
body {
  height: 100%;
  margin: 0;
  font-size: 14px;
}

body {
  background-color: #f4f6f9;
}

/* ─── Layout wrapper ────────────────────────────────────────────────────────── */
#wrapper {
  min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
#sidebar {
  width: 260px;
  min-height: 100vh;
  min-width: 260px;
  transition: width 0.25s ease;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1000;
}

#sidebar.collapsed {
  width: 60px;
  min-width: 60px;
}

#sidebar.collapsed .sidebar-brand span,
#sidebar.collapsed .sidebar-brand-name,
#sidebar.collapsed .sidebar-user,
#sidebar.collapsed .sidebar-signout-label,
#sidebar.collapsed .sidebar-label,
#sidebar.collapsed .nav-link span,
#sidebar.collapsed .nav-link .bi-chevron-down,
#sidebar.collapsed #refDataMenu {
  display: none !important;
}

#sidebar.collapsed .nav-link {
  padding: 0.5rem 0;
  margin: 0.1rem 0;
  justify-content: center;
  width: 100%;
}

#sidebar.collapsed .sidebar-signout {
  padding-left: 0;
  padding-right: 0;
}

#sidebar.collapsed .nav-link i {
  margin: 0 !important;
}

#sidebar .sidebar-brand {
  min-height: 60px;
}

.sidebar-logo {
  height: 44px;
  width: 44px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  padding: 4px;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.35),
    0 1px 4px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
  transition:
    box-shadow 0.2s ease,
    transform 0.2s ease,
    height 0.25s ease,
    width 0.25s ease;
  flex-shrink: 0;
}

.sidebar-logo:hover {
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.4),
    0 2px 6px rgba(0, 0, 0, 0.25);
  transform: translateY(-3px);
}

#sidebar.collapsed .sidebar-logo {
  height: 34px;
  width: 34px;
}

.login-logo {
  max-height: 80px;
  max-width: 280px;
  width: auto;
  object-fit: contain;
}

.customer-logo-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.customer-logo {
  height: 50px;
  width: auto;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  mix-blend-mode: multiply;
}

#sidebar .nav-link {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  margin: 0.1rem 0.5rem;
  transition: background-color 0.15s;
  display: flex;
  align-items: center;
}

#sidebar .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

#sidebar .nav-link.active {
  background-color: #0d6efd;
  color: #fff !important;
}

#sidebar .sidebar-label {
  letter-spacing: 0.05em;
  font-size: 0.7rem;
}

#sidebar .collapse .nav-link {
  padding: 0.3rem 0.75rem;
  margin: 0.05rem 0.25rem;
  font-size: 0.8rem;
}

/* ─── Page content ──────────────────────────────────────────────────────────── */
#page-content {
  min-width: 0;
  transition: all 0.25s ease;
}

.topbar {
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 999;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  border-radius: 0.5rem;
}

.card-header {
  background-color: #fff;
  border-bottom: 2px solid #f0f0f0;
  font-weight: 600;
}

.stat-card {
  border-radius: 0.5rem;
  transition: transform 0.15s;
}

.stat-card:hover {
  transform: translateY(-2px);
}

a:has(.stat-card) {
  cursor: pointer;
}

/* ─── DataTables ─────────────────────────────────────────────────────────────── */
.dataTables_wrapper .dataTables_filter {
  display: flex;
  align-items: center;
}

.dataTables_wrapper .dataTables_filter label {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: #495057;
}

.dataTables_wrapper .dataTables_filter input {
  flex: 1;
  border-radius: 0.5rem;
  border: 1.5px solid #ced4da;
  padding: 0.45rem 0.75rem;
  font-size: 0.95rem;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.dataTables_wrapper .dataTables_filter input:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
  outline: none;
}

.dataTables_wrapper .dataTables_length {
  display: inline-flex !important;
  align-items: center;
  float: none !important;
  padding-top: 0 !important; /* override dataTables.bootstrap5.css padding-top: .85em */
  flex-shrink: 0;
}

.dataTables_wrapper .dataTables_length label {
  font-size: 0.85rem;
  color: #495057;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  margin: 0;
}

.dataTables_wrapper .dataTables_length select {
  width: auto;
  border-radius: 0.375rem;
  border: 1px solid #ced4da;
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
  padding-left: 0.5rem;
  /* padding-right is left to Bootstrap's .form-select default (2.25rem) to preserve space for the dropdown arrow */
  font-size: 0.85rem;
  display: inline-block;
}

.dataTables_wrapper .dt-buttons {
  float: none !important;
  flex-shrink: 0;
}

.dataTables_wrapper .dt-buttons .btn {
  font-size: 0.8rem;
}

table.dataTable thead th {
  background-color: #f8f9fa;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid #dee2e6;
}

/* ─── Badges & status ────────────────────────────────────────────────────────── */
.badge-active {
  background-color: #198754;
}
.badge-inactive {
  background-color: #6c757d;
}

/* ─── Tabs ───────────────────────────────────────────────────────────────────── */
.nav-tabs .nav-link {
  font-size: 0.85rem;
  color: #495057;
}

.nav-tabs .nav-link.active {
  font-weight: 600;
  border-bottom: 2px solid #0d6efd;
}

/* ─── Map ────────────────────────────────────────────────────────────────────── */
#map {
  height: 450px;
  width: 100%;
}

/* ─── Dashboard nav tree ─────────────────────────────────────────────────────── */
.nav-tree-region {
  color: #343a40;
  transition: background 0.12s;
}

.nav-tree-region:hover {
  background: #f8f9fa !important;
}

.nav-tree-chevron {
  transition: transform 0.2s ease;
  color: #6c757d;
}

[aria-expanded="true"] > .nav-tree-chevron,
[aria-expanded="true"] .nav-tree-chevron {
  transform: rotate(90deg);
}

.nav-tree-toggle {
  color: #6c757d;
  line-height: 1;
}

.nav-tree-agent {
  transition: background 0.12s;
  border-radius: 0.25rem;
}

.nav-tree-agent:hover {
  background: #f0f4ff;
  color: #0d6efd !important;
}

/* ─── Auth / Login page ──────────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a3a5c 0%, #0d6efd 100%);
}

.login-card {
  width: 420px;
  border-radius: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: #6c757d;
  font-size: 0.8rem;
  margin: 1.25rem 0;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid #dee2e6;
}

.login-divider::before {
  margin-right: 0.75rem;
}
.login-divider::after {
  margin-left: 0.75rem;
}

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-label {
  font-weight: 500;
  font-size: 0.85rem;
}

.required-star::after {
  content: " *";
  color: #dc3545;
}

/* ─── File upload zone ───────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed #0d6efd;
  border-radius: 0.5rem;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  background: #f8f9fa;
  transition: background 0.15s;
}

.upload-zone:hover {
  background: #e8f0fe;
}

/* ─── Shepherd.js tour ───────────────────────────────────────────────────────── */
.shepherd-element.nwm-tour-step {
  max-width: 360px;
}

.shepherd-element.nwm-tour-step .shepherd-header {
  background: #0d6efd !important;
  border-radius: 0.5rem 0.5rem 0 0;
  padding: 0.75rem 1rem;
}

.shepherd-element.nwm-tour-step .shepherd-title {
  color: #fff !important;
  font-weight: 600;
  font-size: 0.95rem;
}

.shepherd-element.nwm-tour-step .shepherd-cancel-icon {
  color: rgba(255, 255, 255, 0.7) !important;
}

.shepherd-element.nwm-tour-step .shepherd-cancel-icon:hover {
  color: #fff !important;
}

.shepherd-element.nwm-tour-step .shepherd-text {
  font-size: 0.875rem;
  color: #343a40;
  padding: 0.85rem 1rem;
}

.shepherd-element.nwm-tour-step .shepherd-footer {
  padding: 0.5rem 1rem 0.75rem;
  gap: 0.5rem;
}

.shepherd-element.nwm-tour-step .shepherd-button {
  border-radius: 0.375rem;
  font-size: 0.8rem;
  padding: 0.35rem 0.85rem;
}

.shepherd-element.nwm-tour-step .shepherd-button-primary {
  background: #0d6efd;
  border: none;
}

.shepherd-element.nwm-tour-step .shepherd-button-primary:hover {
  background: #0b5ed7;
}

.shepherd-element.nwm-tour-step .shepherd-button-secondary {
  background: transparent;
  border: 1px solid #dee2e6;
  color: #6c757d;
}

.shepherd-element.nwm-tour-step .shepherd-button-secondary:hover {
  background: #f8f9fa;
  color: #343a40;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: -260px;
    height: 100vh;
  }

  #sidebar.mobile-open {
    left: 0;
  }
}
