/* ==========================================================================
   DeliTMS UI / LAYOUT
   - File: delitms.css
   - Purpose: layout + components (Bootstrap-like UI tweaks)
   - Depends on: style.css (:root variables)
   ========================================================================== */
a {
  text-decoration: none;
}

td {
  vertical-align: middle !important;
}

footer {
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.85rem;
}

footer b, footer a:hover {
  color: var(--red) !important;
}

.dropdown-menu {
  z-index: 9999;
}

.dropdown-submenu {
  position: relative;
}

.dropdown-submenu > .dropdown-menu {
  top: 0;
  left: 100%;
  margin-left: .1rem;
  margin-right: .1rem;
}

@media (max-width: 991px) {
  .dropdown .dropdown-profile {
    right: -42px !important;
  }
}

.border-dashed {
  border-style: dashed !important;
}

/* Tùy chọn: hiển thị mũi tên nhỏ cho item có submenu */
.dropdown-submenu > .dropdown-item.dropdown-toggle::after {
  float: right;
  margin-left: .25rem;
  margin-top: 10px;
}

.nav-avatar-container {
    position: relative;
    display: inline-block;
}


.notification-dot {
    position: absolute;
    left: -7px;
    top: -7px;
    width: 15px;
    height: 15px;
    background-color: #ff3b30; /* Màu đỏ nổi bật */
    border: 2px solid #fff;    /* Viền trắng để tách biệt với avatar */
    border-radius: 50%;
    display: block;
}


/* Hiệu ứng nhấp nháy nhẹ để gây chú ý (tùy chọn) */
.dot-pulse {
    animation: pulse-red 2s infinite;
}


@keyframes pulse-red {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 5px rgba(255, 59, 48, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}

.table thead th {
  white-space: nowrap;
}

.toolbar .form-control,
.toolbar .form-select {
  min-width: 180px;
}

.toolbar .btn-clear {
  white-space: nowrap;
}


.highlight-scroll {
    position: relative;
    animation: highlightGlow 2.6s ease-out;
    background-color: rgba(255, 104, 104, 0.18) !important;
    box-shadow: inset 0 0 0 2px rgba(255, 104, 104, 0.55),
                0 0 12px rgba(255, 104, 104, 0.45);
    transition: background-color 0.4s ease-out, box-shadow 0.4s ease-out;
}


@keyframes highlightGlow {
    0% {
        background-color: rgba(255, 104, 104, 0.30);
        box-shadow: inset 0 0 0 3px rgba(255, 104, 104, 0.75),
                    0 0 22px rgba(255, 104, 104, 0.75);
    }
    40% {
        background-color: rgba(255, 104, 104, 0.22);
        box-shadow: inset 0 0 0 2px rgba(255, 104, 104, 0.55),
                    0 0 14px rgba(255, 104, 104, 0.55);
    }
    70% {
        background-color: rgba(255, 104, 104, 0.15);
        box-shadow: inset 0 0 0 1px rgba(255, 104, 104, 0.35),
                    0 0 6px rgba(255, 104, 104, 0.35);
    }
    100% {
        background-color: rgba(255, 104, 104, 0.08);
        box-shadow: inset 0 0 0 0 rgba(255, 104, 104, 0),
                    0 0 0 rgba(255, 104, 104, 0);
    }
}

.link-clean {
  text-decoration: none;
}

.link-clean:hover {
  text-decoration: underline;
}

/* Map canvas full height minus navbar */
#map {
  height: calc(100vh - 56px);
  width: 100%;
}


/* ==========================================================================
   3) NAVBAR / BRANDING
   ========================================================================== */
.navbar {
  background: linear-gradient(180deg, #0f1627 0%, #0c1220 100%);
  border-bottom: 1px solid var(--border);
}


.nav-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1e293b;
  border: 1px solid rgba(255,255,255,.10);
  flex-shrink: 0;
}

.nav-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nav-avatar-text {
  font-size: .7rem;
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1;
}


.brand {
  font-weight: 800;
  letter-spacing: 0.2px;
  color: #fff;
}


/**
 * authentication 
 */

.auth-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 12px;
  background: radial-gradient(
      1200px 600px at 10% -10%,
      rgba(96, 165, 250, 0.08),
      transparent 60%
    ),
    radial-gradient(
      1200px 600px at 110% 110%,
      rgba(27, 214, 120, 0.06),
      transparent 60%
    ),
    var(--bg);
}

.auth-card {
  width: min(500px, 96vw);
  background: linear-gradient(145deg, #111827, #0f172a);
  box-shadow: 0 0 25px rgba(96, 165, 250, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.35);
  border-radius: 14px;
  padding: 18px 18px 14px;
}

.brand-lg {
  font-weight: 900;
  letter-spacing: 0.2px;
  color: #fff;
  font-size: 28px;
}

.subtle {
  color: #9fb0c8;
}

.foot-meta {
  color: #9fb0c8;
  font-size: 0.85rem;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Handle kéo để sắp xếp */
.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: grab;
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(148, 163, 184, 0.08);
}

.drag-handle:hover {
  color: #e2e8f0;
  border-color: #60a5fa;
  background: rgba(96, 165, 250, 0.12);
}

/* ==========================================================================
   4) FILTER BAR (HORIZONTAL OVERLAY)
   - Vùng filter ngang bên trên map
   ========================================================================== */
.filter-bar {
  position: absolute;
  top: 68px;
  left: 50px;
  right: 12px;
  z-index: 1001;
  background: rgba(21, 26, 38, 0.7);
  border: 1px solid var(--border);
  border-radius: 14px;
  backdrop-filter: saturate(1.1) blur(3px);
  width: calc(100vw - 490px);
}


/* Legend dots (màu chú thích) */
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.text-invalid {
  font-size: .875em;
  color: var(--bs-form-invalid-color);
}

/* KPI badges trong filter bar */
.kpi-badge {
  background: #0f1626;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.45rem 0.4rem;
  display: flex;
  align-items: center;
  /*  gap: .2rem;*/
  font-weight: 600;
  cursor: pointer;
}

.kpi-badge.active,
.filter.active,
#transportKPIs .pill.active {
  border-color: #60a5fa !important;
}


.kpi-title {
  color: var(--muted);
  font-size: 0.85rem;
}

.kpi-value {
  font-weight: 800;
  color: #e5edf7;
}


/* ==========================================================================
   5) RIGHT PANEL / OVERLAY SUMMARY (SCROLLABLE)
   - Thẻ thông tin bên phải (dạng card, cuộn độc lập)
   ========================================================================== */
.map-overlay {
  position: absolute;
  top: 68px;
  right: 12px;
  z-index: 1000;
  width: min(420px, 92vw);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #333 #151a26;
  background: rgba(21, 26, 38, 0.7);
  backdrop-filter: blur(3px);
  border-radius: 14px;
}


/* Scrollbar (WebKit) */
.map-overlay::-webkit-scrollbar {
  width: 8px;
}

.map-overlay::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}

.map-overlay::-webkit-scrollbar-track {
  background: #151a26;
}


/* Panel header & stats card */
.panel {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 0.75rem;
}

.panel-header {
  font-weight: 700;
  color: #e2e8f0;
}

.small-hint-l {
  color: var(--muted);
  font-size: 0.85rem;
}

.small-hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.small-hint-s {
  color: var(--muted);
  font-size: 0.72rem;
}

.step-number {
  flex: 0 0 1.6rem;
  line-height: 1;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  margin-right: 0.5rem;
  color: #e2e8f0;
}

.stat-card {
  background: #0f1626;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 0.75rem;
}


/* ==========================================================================
   6) ISSUE LIST / ITEMS
   ========================================================================== */
.issue-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f1626;
}

.issue-left {
  display: flex;
  gap: 0.55rem;
}


.issue-idx {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  background: #141a28;
  border: 1px solid var(--border);
  color: #cbd5e1;
}


.issue-title {
  font-weight: 600;
  color: #e5edf7;
  line-height: 1.1;
}

.issue-desc {
  color: #9fb0c8;
  font-size: 0.85rem;
}


/* ==========================================================================
   7) 3RD-PARTY INTEGRATIONS TWEAKS
   - Leaflet, Autocomplete input...
   ========================================================================== */
.leaflet-div-icon {
  background: transparent;
  border: none;
}


/* autoComplete.js input style to fit dark theme */
.autoComplete_wrapper {
  width: 100%;
}

.autoComplete_wrapper > input {
  width: 100%;
  height: auto;
  background-color: initial;
  /*  border: var(--bs-border-width) solid white;*/
}

.autoComplete_wrapper > input::placeholder {
  color: white;
}


/* ==========================================================================
   8) TOGGLE "TÓM TẮT VẤN ĐỀ"
   ========================================================================== */
.toggle-row {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 4px;
}

.toggle-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #0f1626;
  border: 1px solid var(--border);
  color: #e5edf7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  line-height: 1;
}


/* ==========================================================================
   9) TRANSPORT STATUS PILLS
   ========================================================================== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #0f1626;
  color: #cbd5e1;
  font-size: 0.85rem;
  cursor: pointer;
}

.pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}


/* Status colors */

.dot-main {
  background: #64748b;
}

.dot-free {
  background: #e5edf7;
}

.dot-assigned {
  background: #22d3ee;
}

.dot-enroute {
  background: var(--green);
}

.dot-delivering {
  background: #60a5fa;
}

.dot-returning {
  background: var(--orange);
}

.dot-paused {
  background: #b48cf2;
}


/* === transport-overview additions (new selectors) === */

.page-wrap {
  min-height: calc(100vh - 56px);
}

.kpi {
  background: #0f1626;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem;
  height: 100%;
}

.kpi .label {
  color: var(--muted);
  font-size: 0.9rem;
}

.kpi .val {
  font-weight: 800;
  font-size: 1.5rem;
  color: #e5edf7;
}

.kpi .sub {
  font-size: 0.85rem;
  color: #b6c3d9;
}

.kpi .delta-up {
  color: var(--green);
  font-weight: 700;
}

.kpi .delta-down {
  color: var(--red);
  font-weight: 700;
}

.filters .filter-chip {
  background: #0f1626;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.25rem 0.5rem;
  color: #cbd5e1;
  white-space: nowrap;
}

.chart-card {
  background: #0f1626;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}

.alert-tile {
  border: 1px solid var(--border);
  border-left: 4px solid var(--red);
  border-radius: 10px;
  padding: 0.75rem;
  background: #0f1626;
}

.alert-tile.ok {
  border-left-color: var(--green);
}

.alert-tile.warn {
  border-left-color: var(--yellow);
}

.alert-tile .meta {
  color: #9fb0c9;
  font-size: 0.85rem;
}

.sec-title {
  font-weight: 800;
  font-size: 1rem;
  color: #e5edf7;
}

a.link-soft {
  color: #9ad1ff;
  text-decoration: none;
}

a.link-soft:hover {
  text-decoration: underline;
}


/* Order card in popup */
.order-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
}

.order-card.at-risk {
  border-left: 3px solid #ff6868;
  background: rgba(255, 104, 104, 0.08);
}

.order-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
}


.ineff-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ineff-row {
  display: grid;
  grid-template-columns: 26px 100px 1fr auto;
  gap: 0.6rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.6rem;
  padding: 0.45rem 0.6rem;
}

.ineff-rank {
  width: 26px;
  height: 26px;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e2e8f0;
  font-weight: 700;
  font-size: 0.85rem;
}

.ineff-plate a {
  color: #e5e7eb;
  font-weight: 700;
  text-decoration: none;
}

.ineff-plate a:hover {
  text-decoration: underline;
}

.form-section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.info-card {
  background: #0f1626;
  border: 1px solid var(--border);
  padding: 1rem 1.25rem;
  border-radius: 12px;
}

.info-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.info-value {
  font-size: 1rem;
  font-weight: 600;
  color: #e2e8f0;
}

.template-badge {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  border: 1px solid rgba(148, 163, 184, 0.5);
  color: #e2e8f0;
}

.preview-table-wrap {
  overflow: auto;
  border-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  max-height: clamp(260px, 50vh, 520px);
}

.preview-table-wrap table {
  flex: 1 1 auto;
  min-height: 200px;
  overflow: auto;
}

#previewTable thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0f1626;
}

.preview-empty {
  padding: 1.25rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 0.9rem;
  min-height: 140px;
}

.purpose-badge {
  padding: 0.2rem 0.55rem;
  border-radius: 0.4rem;
  font-size: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(255, 255, 255, 0.05);
}


/* 1) Hide select gốc để không bị 2 control */
select.tomselected{ display:none !important; }


/* 2) Wrapper full width */
.ts-wrapper{ width:100% !important; padding: 0px;border:none;position: relative !important;}


/* 3) Làm cho TomSelect nhìn như Bootstrap .form-select (dark theme DeliTMS) */
.ts-control{
  display:flex !important;
  align-items:center;
  gap:.25rem;

  /* giống form-select */
  width:100%;
  min-height: calc(2.25rem + 2px);
  padding: .375rem .75rem;

  border: 1px solid rgba(255,255,255,.14);
  border-radius: .5rem;

  background: rgba(255,255,255,.02);
  color:#e2e8f0;

  box-shadow: none !important;
}

.ts-control.is-invalid{
  border-color: var(--bs-form-invalid-border-color) !important;
}

.ts-wrapper.focus .ts-control.is-invalid{
  box-shadow: 0 0 0 .2rem rgba(220,53,69,.25) !important; /* bs danger ring */
}

/* Placeholder giống bootstrap */
.ts-control .placeholder{
  color:var(--muted) !important;
}


/* Input search phải “hoà” vào control, không tạo 1 ô xanh to */
.ts-control > input{
  flex:1 1 auto !important;
  width:100% !important;
  min-width: 2rem !important;

  border:0 !important;
  outline:0 !important;
  background: transparent !important;
  color:#e2e8f0 !important;
  box-shadow:none !important;

  padding:0 !important;
  margin:0 !important;
}


/* Item đã chọn: không tạo chip, chỉ hiển thị text như select */
.ts-control .item{
  background: transparent !important;
  border:0 !important;
  padding:0 !important;
  margin:0 !important;
  color:#e2e8f0 !important;
}


/* 4) Focus giống bootstrap */
.ts-wrapper.focus .ts-control{
  border-color: rgba(59,130,246,.65) !important;
  box-shadow: 0 0 0 .2rem rgba(59,130,246,.25) !important;
}


/* 5) Dropdown giống dropdown select */
.ts-dropdown{
  position: absolute !important;
  top: calc(100% + 4px) !important;
  left: 0;
  right: 0;
  z-index: 3000 !important;
  width:100% !important;
  border: 1px solid rgba(255,255,255,.14) !important;
  border-radius: .5rem !important;
  overflow:hidden;
  background: #0f1626 !important;
  color:#e2e8f0 !important;
}


/* option spacing */
.ts-dropdown .option{
  padding: .55rem .75rem !important;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.ts-dropdown .option:last-child{
  border-bottom:0;
}

.ts-dropdown-content{
  max-height: 280px;
  overflow-y: auto;
}


/* hover/active giống bootstrap */
.ts-dropdown .option.active,
.ts-dropdown .option:hover{
  background: rgba(255,255,255,.08) !important;
}


/* 6) Bỏ caret riêng của TomSelect để nhìn như form-select native (caret của browser vẫn có) */
.ts-wrapper .ts-control:after{
  display:none !important;
}
