/* =========================================
   ROOT VARIABLES
========================================= */
:root {
  --sidebar-w: 260px;
  --sidebar-w-collapsed: 72px;

  --sidebar-bg: rgba(255,255,255,0.25);
  --sidebar-blur: blur(12px);

  --shadow-soft: 0 8px 24px rgba(0,0,0,0.08);
  --radius: 16px;
  --transition: .3s ease;
}

/* =========================================
   GLOBAL RESET
========================================= */
html, body {
  height: 100%;
  font-family: "Inter", system-ui, sans-serif;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #f2f7fc;
}

.app-root {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* =========================================
   SIDEBAR MODERN
========================================= */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;

  background: var(--sidebar-bg);
  backdrop-filter: var(--sidebar-blur);
  box-shadow: var(--shadow-soft);

  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: .5rem;

  position: relative;
  transition: var(--transition);
  z-index: 1000;
  border-right: 1px solid rgba(255,255,255,0.35);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* COLLAPSED SIDEBAR */
.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
  min-width: var(--sidebar-w-collapsed);
  padding: 1rem .5rem;
}

.sidebar-logo {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: .7rem;
}

/* ukuran logo */
.brand-icon {
  width: 32px;
  height: 32px;
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}


/* HIDE TEXT WHEN COLLAPSED */
.sidebar.collapsed .label,
.sidebar.collapsed span {
  display: none !important;
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .small-muted {
  display: none;
}

/* Sembunyikan Medan — Indonesia */
.sidebar.collapsed .location-text {
  display: none !important;
}

/* Sembunyikan versi */
.sidebar.collapsed .version-text {
  display: none !important;
}


/* NAV ITEMS */
.nav-link {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .65rem .75rem;
  border-radius: 10px;
  color: #063b50;
  font-weight: 600;
  transition: var(--transition);
}

.nav-link i {
  font-size: 1.25rem;
}

.nav-link:hover {
  background: rgba(255,255,255,0.35);
  transform: translateX(6px);
}

.nav-link.active {
  background: rgba(255,255,255,0.55);
  box-shadow: var(--shadow-soft);
}

/* LOGOUT BUTTON */
#logoutBtn {
  margin-top: auto;
  padding: .65rem;
  border-radius: 10px;
  border: none;
  background: rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  gap: .75rem;
  cursor: pointer;
  transition: var(--transition);

  /* Tambahan: warna teks seperti nav-link */
  color: #063b50;
  font-weight: 600;
}

#logoutBtn:hover {
  background: rgba(0,0,0,0.12);
}

/* Icon warna emas tetap */
#logoutBtn i {
  color: #ffbf00;
}

.sidebar.collapsed .logout-text {
  display: none !important;
}
.sidebar-footer .version-text {
  color: #063b50;
  font-weight: 600;
}

.sidebar.collapsed .location-box {
  justify-content: center !important;
}


/* Collapse Button */
#collapseBtn {
  position: absolute;
  top: 5%;
  right: 0px;
  transform: translateY(-50%);

  width: 38px;
  height: 58px;
  background: #063b50;
  color: white;
  border-radius: 50% 0 0 50%;

  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;

  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  transition: var(--transition);
}

.sidebar.collapsed #collapseBtn {
  right: -40px;
}

/* =========================================
   MOBILE SIDEBAR
========================================= */
@media (max-width: 992px) {
  .sidebar {
    position: fixed;
    left: -260px;
  }

  .sidebar.show {
    left: 0;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 900;
    display: none;
  }

  .sidebar-overlay.active {
    display: block;
  }
}

/* =========================================
   MAIN CONTENT
========================================= */
main.main-content {
  flex: 1;
  background: #f9fcff;
  padding: 1rem;
  overflow-y: auto;
  height: 100vh;
  transition: margin-left .3s ease;
}

@media (min-width: 992px) {
  .main-content {
    margin-left: var(--sidebar-w);
  }
  .sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-w-collapsed);
  }
}

/* =========================================
   TAB CONTENT (SECTION)
========================================= */
section.tab-section {
  display: none;
  min-height: calc(100vh - 120px);
  overflow-y: auto;
}

section.tab-section.active {
  display: block;
}

/* Card modern */
.card {
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  border: none;
}



/* =========================================
   HEADER
========================================= */
header.app-header {
  height: 64px;
  background: #ffffff;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  padding: .5rem 1rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 700;
}

.page-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: #033b56;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .75rem;
}

/* =========================================
   MAIN CONTENT
========================================= */
main.content {
  flex: 1 1 auto;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #f5faff;
}

/* =========================================
   TAB SECTION FULL WIDTH / HEIGHT
========================================= */
.tab-section {
  width: 100%;
  height: calc(100vh - 64px);
  overflow: hidden;
  padding: .75rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.section-with-buttons {
  padding-bottom: 90px;   /* aman untuk footer 60px–70px */
}


.tab-section .card {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  border-radius: 12px;
  box-shadow: var(--soft-shadow);
}

.tab-section .card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: .75rem;
  overflow: hidden;
}

#searchVisit {
  margin-bottom: .5rem;
}

/* TABLE RESPONSIVE */
.tab-section .table-responsive {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
}

/* TABLE AUTO FIT WIDTH */
.tab-section table {
  width: 100%;
  table-layout: auto;
}

/* =========================================
   MOBILE ADJUSTMENT
========================================= */
@media (max-width: 768px) {
  .tab-section {
    padding: .4rem;
    height: calc(100vh - 56px);
  }

  .tab-section .card-body {
    padding: .5rem;
  }

  .tab-section table th,
  .tab-section table td {
    font-size: .78rem;
  }
}

/* ==========================================================================
   SECTION — LAPORAN PENJUALAN
   ========================================================================== */

#tab-laporan-penjualan {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: .75rem 1rem;
  overflow-y: auto;
  width: 100%;
  box-sizing: border-box;
}

#tab-laporan-penjualan > .container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  width: 100%;
}


/* --- Card Body ----------------------------------------------------------- */

#tab-laporan-penjualan .card-body {
  padding: 0.75rem 0.75rem 90px 0.75rem; /* top right bottom left */
  overflow: hidden; /* tetap agar scroll di table */
  display: flex;
  flex-direction: column;
}

/* Override card-body padding */
#tab-laporan-penjualan .card-body {
  flex: 1;
  padding: .5rem;
}


/* --- Filter Row ---------------------------------------------------------- */

#tab-laporan-penjualan .d-flex.filter-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: nowrap;
}

#tab-laporan-penjualan .filter-row label {
  white-space: nowrap;
  font-weight: 600;
  color: #033b56;
}

#tab-laporan-penjualan .filter-row input {
  flex: 1;
  min-width: 0;
}

#tab-laporan-penjualan .filter-row button {
  flex-shrink: 0;
}


/* --- Summary Section ----------------------------------------------------- */

#laporanSummary {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  width: 100%;
}


/* --- Summary Card Mobile Fix -------------------------------------------- */

@media (max-width: 768px) {
  #laporanSummary {
    display: flex;
    flex-direction: column !important;
    width: 100%;
  }

  #laporanSummary .card {
    width: 100% !important;
  }
}


/* --- Table Container ----------------------------------------------------- */

#tab-laporan-penjualan .table-responsive {
  flex: 1;
  width: 100%;
  overflow-y: auto;
}


/* --- Mobile Adjustments -------------------------------------------------- */

@media (max-width: 576px) {

  #tab-laporan-penjualan .container {
    width: 100%;
    padding-left: 0;
    padding-right: 0;
  }

  /* Summary card full width */
  #laporanSummary .col-md-4 {
    flex: 1 1 100%;
    max-width: 100%;
  }

  /* Card-body padding extra for scroll */
  #tab-laporan-penjualan .card-body {
    padding: 0.75rem 0.75rem 90px 0.75rem;
  }

  /* Tabel responsive lebar penuh */
  #tab-laporan-penjualan .table-responsive {
  flex: 1;
  width: 100%;
  overflow-x: auto !important;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* smooth scroll di mobile */
}

}


/* ==========================================================================
   TABLE WRAPPER
   ========================================================================== */

.table-wrapper {
  height: calc(100vh - 200px);
  overflow-y: auto;
  overflow-x: auto;
  background: #fff;
  padding: 12px;
  border-radius: 12px;
  box-shadow: var(--soft-shadow);
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .table-wrapper {
    height: calc(100vh - 160px);
  }
}

/* =========================================
   MODAL
========================================= */
.modal-content {
  border-radius: 14px;
}

/* =========================================
   FOOTER FIXED
========================================= */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #ffffff;
  padding: 12px;
  text-align: center;
  color: #03506f;
  font-weight: 600;
  border-top: 1px solid rgba(0,0,0,0.08);
  z-index: 99;
}



/* =========================================
   LIST KUNJUNGAN
========================================= */
.visit-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 1rem;
}

.list-group-item {
  cursor: pointer;
  transition: background 0.2s ease;
}

.list-group-item:hover {
  background-color: #f2f8ff;
}

.small-muted {
  font-size: 0.8rem;
  color: rgba(0,0,0,0.6);
}

/* Mobile layout */
@media (max-width: 991.98px) {
  .visit-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .visit-layout {
    grid-template-columns: 1fr;
  }
  .visit-map {
    margin-top: 1rem;
  }
}
#tab-list-kunjungan .card-body {
  padding: 0.5rem;
  overflow: hidden; /* tetap agar scroll di table */
  display: flex;
  flex-direction: column;
}


/* =========================================
   SIDEBAR MOBILE OVERLAY
========================================= */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 998;
}

.sidebar-overlay.active {
  display: block;
}

/* =========================================
   SIDEBAR SLIDE-IN MOBILE
========================================= */
@media (max-width: 991.98px) {
  .sidebar {
    left: -280px;
    top: 0;
    bottom: 0;
    width: 260px;
    position: fixed;
    background: #fff;
    transition: left 0.28s ease;
    z-index: 999;
  }
  .sidebar.show-mobile {
    left: 0;
  }
}

/* =========================================
   FLOATING HANDLE (MOBILE)
========================================= */
.sidebar-handle {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 80px;
  background: #0b6ed3;
  border-radius: 0 15px 15px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  z-index: 1000;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  transition: left 0.28s ease;
}

.sidebar.show-mobile ~ .sidebar-handle {
  left: -40px; /* hide ketika sidebar terbuka */
}

/* Desktop tidak pakai overlay atau handle */
@media (min-width: 992px) {
  .sidebar-handle {
    display: none !important;
  }
  .sidebar-overlay {
    display: none !important;
  }
}

/* =========================================
   HOVER EFFECT LIST ITEM
========================================= */
.visit-item {
  transition: background 0.2s, transform 0.15s;
  cursor: pointer;
  border-radius: 8px;
  padding: 10px 14px;
}

.visit-item:hover {
  background: #e9f4ff;
  transform: translateX(5px);
}

/* Animasi badge */
.visit-item .badge {
  transition: transform 0.2s;
}

.visit-item:hover .badge {
  transform: scale(1.1);
}

/* =========================================
   RESPONSIVE FIX
========================================= */
@media (max-width: 991px) {
  .visit-layout {
    display: flex;
    flex-direction: column;
  }
}

/* =========================================
   CUSTOM SCROLLBAR
========================================= */
.table-wrapper::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.table-wrapper::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,0.25);
  border-radius: 3px;
}

/* =========================================
   LEAFLET MAP — MODERN RESPONSIVE
========================================= */
#map {
  width: 100%;
  height: 70vh;
  min-height: 200px;
  max-height: 820px;
  border-radius: 12px;
  box-shadow: var(--soft-shadow);
}

@media (max-width: 767px) {
  #map {
    height: 42vh;
  }
}

@media (min-width: 768px) and (max-width: 991px) {
  #map {
    height: 46vh;
  }
}

@media (min-width: 992px) {
  #map {
    height: 50vh;
  }
}

/* =========================================
   SUMMARY CARD RESPONSIVE
========================================= */
.summary-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .8rem 1rem;
  min-height: 82px;
  border-radius: 12px;
}

.summary-card .icon-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.78rem;
}

.summary-card .icon-label i {
  font-size: 1.45rem;
  margin-bottom: 2px;
}

.summary-card .separator {
  width: 1px;
  background: #ddd;
  height: 40px;
  margin: 0 10px;
}

.summary-card .value {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
}

@media (max-width: 576px) {
  .summary-card {
    flex-direction: column;
    text-align: center;
    gap: 4px;
  }

  .summary-card .separator {
    display: none;
  }

  .summary-card .value {
    margin-top: 4px;
    font-size: .95rem;
  }

  .summary-card .icon-label i {
    font-size: 1.25rem;
  }
}

/* Modern shadow hover effect */
.card.shadow-hover {
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card.shadow-hover:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

/* =========================================
   Proses Input Load, BS, piutang, BBM
========================================= */

/* kecil & rapih untuk repeater row */
.proses-row {
  border: 1px dashed rgba(0,0,0,0.08);
  padding: .5rem;
  border-radius: .4rem;
  margin-bottom: .5rem;
  background: #fff;
}
.proses-row .row > .col > label { font-size: .8rem; }
.proses-row .remove-row {
  cursor:pointer;
}
@media (max-width:576px){
  #salesNameDisplay { font-size: .8rem;}
}


