/* FAFADOO TMS — application styles */

:root {
  --tms-sidebar-collapsed: 56px;
  --tms-sidebar-expanded: 240px;
  --tms-primary: #376bff;
  --tms-primary-dark: #2c5ce4;
  --tms-primary-navy: #1e3a5f;
  --tms-status-pending: #f59f00;
  --tms-status-transit: #4299e1;
  --tms-status-delivered: #2fb344;
  --tms-status-rejected: #d63939;
}

body {
  background: #f4f6fa;
}

.page {
  display: flex;
  min-height: 100vh;
}

.page-wrapper {
  flex: 1;
  min-width: 0;
}

/* Legacy sidebar — only if old tms-sidebar class is used */
.tms-sidebar ~ .page-wrapper {
  margin-left: var(--tms-sidebar-collapsed);
  transition: margin-left 0.3s ease;
}

.tms-sidebar.sidebar-expanded ~ .page-wrapper,
.tms-sidebar.sidebar-pinned ~ .page-wrapper {
  margin-left: var(--tms-sidebar-expanded);
}

.tms-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--tms-sidebar-collapsed);
  z-index: 1030;
  transition: width 0.3s ease;
  overflow: hidden;
  background: #1e293b;
  border-right: 1px solid rgba(255,255,255,0.08);
}

.tms-sidebar.sidebar-expanded,
.tms-sidebar.sidebar-pinned {
  width: var(--tms-sidebar-expanded);
}

.tms-sidebar .nav-link-title,
.tms-sidebar .brand-text,
.tms-sidebar .tms-user-block,
.tms-sidebar .tms-sidebar-pin {
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.tms-sidebar.sidebar-expanded .nav-link-title,
.tms-sidebar.sidebar-expanded .brand-text,
.tms-sidebar.sidebar-expanded .tms-user-block,
.tms-sidebar.sidebar-expanded .tms-sidebar-pin,
.tms-sidebar.sidebar-pinned .nav-link-title,
.tms-sidebar.sidebar-pinned .brand-text,
.tms-sidebar.sidebar-pinned .tms-user-block,
.tms-sidebar.sidebar-pinned .tms-sidebar-pin {
  opacity: 1;
}

.tms-sidebar .nav-link {
  color: rgba(255,255,255,0.75);
  padding: 0.6rem 0.75rem;
}

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

.tms-sidebar .nav-link-icon {
  width: 1.5rem;
  display: inline-flex;
  justify-content: center;
}

.tms-logo {
  max-height: 32px;
  margin-right: 0.5rem;
}

.tms-brand .brand-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
}

.tms-user-block {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 0.5rem;
}

.tms-user-name {
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
}

.tms-user-role {
  font-size: 0.75rem;
  text-transform: capitalize;
}

.tms-sidebar-pin {
  position: absolute;
  bottom: 1rem;
  left: 0;
  right: 0;
  text-align: center;
}

.tms-header {
  background: #fff;
  border-bottom: 1px solid #e6e8eb;
}

/* Login */
.tms-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #376bff 50%, #4299e1 100%);
}

.tms-login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 2rem;
}

/* KPI widgets */
.kpi-card {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: none;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.kpi-card.active {
  outline: 2px solid var(--tms-primary);
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.kpi-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #626976;
}

/* Dashboard map layout */
.dashboard-split {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 280px);
}

.dashboard-map-pane {
  flex: 7;
  min-height: 480px;
  position: relative;
}

.dashboard-side-pane {
  flex: 3;
  min-width: 280px;
  max-width: 400px;
  border-left: 1px solid #e6e8eb;
  background: #fff;
  display: flex;
  flex-direction: column;
}

#fleet-map,
#fleet-map-full {
  width: 100%;
  height: 100%;
  min-height: 480px;
}

#fleet-map-full {
  min-height: calc(100vh - 160px);
}

.filter-bar {
  background: #fff;
  border-bottom: 1px solid #e6e8eb;
  padding: 0.75rem 1rem;
}

.filter-bar .form-select,
.filter-bar .form-control {
  font-size: 0.8125rem;
}

.order-feed-card {
  border-bottom: 1px solid #eee;
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
}

.order-feed-card:hover,
.order-feed-card.selected {
  background: #f0f4ff;
}

.order-feed-card .status-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
}

.status-pending { background: #fff3cd; color: #856404; }
.status-in-progress, .status-picked-up { background: #cce5ff; color: #004085; }
.status-delivered, .status-completed { background: #d4edda; color: #155724; }
.status-urgent, .status-rejected { background: #f8d7da; color: #721c24; }
.status-in-transit { background: #dbeafe; color: #1e40af; }

/* Toast */
.app-toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.app-toast {
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  background: #1e293b;
  color: #fff;
  font-size: 0.875rem;
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.3s;
  max-width: 360px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.app-toast.show { opacity: 1; transform: translateX(0); }
.app-toast-success { background: #2fb344; }
.app-toast-error { background: #d63939; }
.app-toast-warn { background: #f59f00; }

/* Tracking grid */
.tracking-toolbar {
  background: #fff;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid #e6e8eb;
}

.tabulator {
  font-size: 0.8125rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e6e8eb;
}

.tabulator-row.tabulator-selected {
  background: #e7f1ff !important;
}

.context-menu {
  min-width: 180px;
}

.context-menu ul li:hover {
  background: #f0f4ff;
}

.map-fullscreen .dashboard-map-pane {
  flex: 1;
  max-width: none;
}

.map-fullscreen .dashboard-side-pane {
  max-width: 360px;
}

.map-layer-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  background: #fff;
  padding: 0.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.map-layer-drivers-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}
.map-layer-drivers-wrap .tms-driver-pop-anchor {
  min-width: 1.25rem;
  line-height: 1;
  font-size: 0.75rem;
}

@media (max-width: 991px) {
  .page-wrapper { margin-left: 0; }
  .tms-sidebar { transform: translateX(-100%); }
  .tms-sidebar.show { transform: translateX(0); width: var(--tms-sidebar-expanded); }
  .dashboard-split { flex-direction: column; }
  .dashboard-side-pane { max-width: none; min-height: 300px; }
}
