/* css/dashboard.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
@import 'variables.css';

:root {
  --sidebar-width: 260px;
  --topbar-height: 70px;
  --dash-bg: #030712;
  --dash-surface: rgba(15, 23, 42, 0.6); /* Deeper glass background */
  --dash-border: rgba(0, 180, 216, 0.15);
  --font-dash: 'Inter', sans-serif; /* Upgraded font */
}

body.dashboard-app {
  display: flex;
  height: 100vh;
  background: var(--dash-bg);
  background-image: 
    radial-gradient(at 0% 0%, rgba(0, 180, 216, 0.1) 0, transparent 50%),
    radial-gradient(at 100% 100%, rgba(124, 58, 237, 0.1) 0, transparent 50%);
  font-family: var(--font-dash);
  color: var(--c-white);
  margin: 0;
  overflow: hidden;
}

/* Sidebar */
.dash-sidebar {
  width: var(--sidebar-width);
  background: rgba(10, 15, 30, 0.95);
  border-right: 1px solid var(--dash-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dash-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.dash-brand:hover .logo-svg path:nth-of-type(1) {
  transform: translateX(1.5px);
}
.dash-brand:hover .logo-svg path:nth-of-type(2) {
  transform: translateX(3px);
}
.dash-brand:hover .logo-svg path:nth-of-type(3) {
  transform: translateX(4.5px);
}
.dash-brand .logo-svg path {
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center;
}

.dash-nav {
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0.75rem;
  gap: 0.25rem;
  flex-grow: 1;
}

.dash-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  color: var(--c-gray-400);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.dash-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--c-white);
  transform: translateX(4px);
}

.dash-nav-item.active {
  background: rgba(0, 180, 216, 0.1);
  color: var(--c-cyan);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--c-cyan);
}

.dash-nav-item svg {
  width: 18px;
  height: 18px;
  opacity: 0.8;
}
.dash-nav-item.active svg {
  opacity: 1;
}

/* Main Content Area */
.dash-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Topbar */
.dash-topbar {
  height: var(--topbar-height);
  background: rgba(3, 7, 18, 0.5);
  border-bottom: 1px solid var(--dash-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.dash-search input {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  color: #fff;
  width: 320px;
  font-family: var(--font-dash);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}
.dash-search input:focus {
  border-color: var(--c-cyan);
  background-color: rgba(0, 180, 216, 0.05);
  box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.1);
}

.dash-user-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.notification-bell {
  position: relative;
  cursor: pointer;
  color: var(--c-gray-400);
  padding: 0.5rem;
  border-radius: 8px;
  transition: all 0.2s;
}
.notification-bell:hover { 
  color: var(--c-white); 
  background: rgba(255,255,255,0.05);
}
.notification-dot {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--c-rose);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--c-rose);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 8px;
  transition: background 0.2s;
}
.user-profile:hover { background: rgba(255,255,255,0.05); }
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--grad-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  box-shadow: 0 4px 10px rgba(0,180,216,0.3);
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 0.85rem; font-weight: 600; }
.user-role { font-size: 0.75rem; color: var(--c-gray-400); }

/* Content Scroll */
.dash-content-scroll {
  flex-grow: 1;
  overflow-y: auto;
  padding: 2rem;
}

/* Grids & Widgets */
.dash-grid-top {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.dash-grid-main {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.dash-widget {
  background: var(--dash-surface);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 16px;
  padding: 1.5rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
  transition: transform 0.2s, box-shadow 0.2s;
}
.dash-widget:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 15px 35px -10px rgba(0,0,0,0.6);
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}
.widget-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--c-gray-300);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -1px;
}

.kpi-trend {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.5rem;
  font-weight: 500;
}
.trend-up { color: var(--c-emerald); }
.trend-down { color: var(--c-rose); }

/* Tables */
.dash-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.5rem;
}
.dash-table th {
  text-align: left;
  padding: 0.5rem 1rem;
  color: var(--c-gray-400);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.dash-table td {
  padding: 1rem;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.02);
}
.dash-table tr td:first-child { border-radius: 8px 0 0 8px; font-weight: 500; }
.dash-table tr td:last-child { border-radius: 0 8px 8px 0; }
.dash-table tr:hover td {
  background: rgba(255,255,255,0.05);
}

.status-badge {
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.status-transit { background: rgba(0,180,216,0.1); color: var(--c-cyan); }
.status-transit::before { background: var(--c-cyan); }
.status-delivered { background: rgba(6,214,160,0.1); color: var(--c-emerald); }
.status-delivered::before { background: var(--c-emerald); }
.status-loading { background: rgba(255,159,28,0.1); color: var(--c-amber); }
.status-loading::before { background: var(--c-amber); }
.status-alert { background: rgba(244,63,94,0.1); color: var(--c-rose); }
.status-alert::before { background: var(--c-rose); }

/* Map Container */
#fleetMap {
  height: 400px;
  border-radius: 0 0 16px 16px;
}

/* Animations */
@keyframes dashFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.dash-widget {
  animation: dashFadeIn 0.5s ease forwards;
  opacity: 0;
}
.dash-grid-top .dash-widget:nth-child(1) { animation-delay: 0.1s; }
.dash-grid-top .dash-widget:nth-child(2) { animation-delay: 0.2s; }
.dash-grid-top .dash-widget:nth-child(3) { animation-delay: 0.3s; }
.dash-grid-top .dash-widget:nth-child(4) { animation-delay: 0.4s; }
.dash-grid-main .dash-widget:nth-child(1) { animation-delay: 0.5s; }
.dash-grid-main .dash-widget:nth-child(2) { animation-delay: 0.6s; }

/* Responsive */
@media (max-width: 1200px) {
  .dash-grid-top { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 992px) {
  .dash-grid-main { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .dash-sidebar { position: absolute; left: -100%; height: 100vh; }
  .dash-sidebar.open { left: 0; }
  .dash-grid-top { grid-template-columns: 1fr; }
  .dash-search input { width: 200px; }
}

/* ── Custom Animated Map Elements ── */
.animated-route {
  stroke-dasharray: 6 6;
  animation: routeFlow 2.5s linear infinite;
  filter: drop-shadow(0 0 2px rgba(0, 180, 216, 0.4));
}

@keyframes routeFlow {
  to {
    stroke-dashoffset: -24;
  }
}

/* Dark theme Leaflet Popups styling */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: rgba(15, 23, 42, 0.95) !important;
  color: var(--c-white) !important;
  border: 1px solid rgba(0, 180, 216, 0.2) !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 8px !important;
}

.leaflet-popup-content {
  margin: 12px 16px !important;
  font-family: var(--font-dash) !important;
  font-size: 0.85rem !important;
  line-height: 1.5 !important;
}

.leaflet-popup-close-button {
  color: var(--c-gray-400) !important;
  font-size: 1.1rem !important;
  padding: 8px !important;
}

@keyframes pulse-emerald {
  0% {
    box-shadow: 0 0 0 0 rgba(6, 214, 160, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(6, 214, 160, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(6, 214, 160, 0);
  }
}

.dash-table tbody tr {
  transition: background 0.2s ease;
}

.dash-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02) !important;
}

/* Mini Tabs inside widgets */
.tab-btn-mini {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--c-gray-400);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.tab-btn-mini:hover {
  color: var(--c-white);
  background: rgba(255,255,255,0.06);
}
.tab-btn-mini.active {
  color: var(--c-cyan);
  background: rgba(0, 180, 216, 0.1);
  border-color: rgba(0, 180, 216, 0.3);
}

.log-entry {
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  animation: logSlideIn 0.3s ease-out forwards;
}

@keyframes logSlideIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Custom premium scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 229, 255, 0.35); /* Glow cyan on hover */
}

/* Firefox support */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) rgba(0, 0, 0, 0.15);
}

