/* ECOTrac Design System - Component Library */

/* ===== RESET & BASE STYLES ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background: var(--color-background);
}

/* ===== WEBSOCKET STATUS INDICATOR ===== */
.ws-status {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
  /*margin-right: var(--space-md);*/
}

.ws-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-error);
  transition: var(--transition-all);
}

.ws-status.connected .ws-indicator {
  background: var(--color-success);
}

.ws-status.connecting .ws-indicator {
  background: var(--color-warning);
  animation: pulse 1.5s infinite;
}

.ws-text {
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== BUTTON COMPONENTS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-family-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-all);
  background: var(--color-primary);
  color: var(--color-text-on-primary);
}

.btn:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:focus {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Button Variants */
.btn-secondary {
  background: var(--color-secondary);
  color: var(--color-text-on-primary);
}

.btn-secondary:hover {
  background: var(--color-primary);
}

.btn-success {
  background: var(--color-success);
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-warning {
  background: var(--color-warning);
  color: white;
}

.btn-warning:hover {
  background: #d97706;
}

.btn-danger {
  background: var(--color-error);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-ghost {
  background: transparent;
  color: var(--brand-900);
  border: 1px solid var(--brand-900);
}

.btn-ghost:hover {
  background: var(--brand-900);
  color: white;
}

/* Button Sizes */
.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-sm);
}

.btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-lg);
}

.btn-full {
  width: 100%;
}

/* ===== FORM COMPONENTS ===== */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  margin-bottom: var(--space-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-family-primary);
  font-size: var(--font-size-base);
  background-color: var(--color-background);
  color: var(--color-text-primary);
  transition: var(--transition-all);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.form-textarea {
  resize: vertical;
  min-height: calc(var(--space-md) * 3);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: var(--color-surface-light);
}

/* Form Input Sizes */
.form-input-sm,
.form-select-sm {
  padding: var(--space-xs);
  font-size: var(--font-size-sm);
}

.form-input-lg,
.form-select-lg {
  padding: var(--space-md);
  font-size: var(--font-size-lg);
}

/* ===== CARD COMPONENTS ===== */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: var(--transition-all);
}
/*
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
*/
.card-header {
  padding: var(--space-md);
  background: var(--color-surface-light);
  border-bottom: 1px solid var(--color-border);
}

.card-body {
  padding: var(--space-md);
}

.card-footer {
  padding: var(--space-md);
  background: var(--color-surface-light);
  border-top: 1px solid var(--color-border);
}

.card-title {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.card-subtitle {
  margin: var(--space-xs) 0 0 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* Card Variants */
.card-bordered {
  border: 1px solid var(--color-border);
}

.card-elevated {
  box-shadow: var(--shadow-lg);
}

.card-flat {
  box-shadow: none;
  border: 1px solid var(--color-border);
}

/* ===== HEADER COMPONENT ===== */
.header {
  background: var(--brand-900);
  color: var(--color-text-on-dark);
  padding: var(--space-sm) var(--space-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  box-shadow: var(--shadow-header);
  min-height: 80px;
}

.header-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.logo {
  width: 316px;
  height: 60px;
  object-fit: contain;
}

/* ===== SIDEBAR COMPONENTS ===== */
.sidebar {
  position: fixed;
  top: 80px;
  left: 60px;
  width: 320px;
  height: calc(100vh - 140px);
  background: var(--color-surface);
  border-right: 2px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-panel);
  transform: translateX(-100%);
  transition: transform var(--transition-slow);
  z-index: var(--z-fixed);
  overflow-y: auto;
  backdrop-filter: blur(10px);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  background: var(--color-background-light);
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-title {
  color: var(--color-text-primary);
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}

.sidebar-content {
  padding: var(--space-md);
}

.close-btn {
  background: none;
  border: none;
  font-size: var(--font-size-xl);
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: var(--transition-all);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background: var(--color-error);
  color: white;
}

/* ===== NAVIGATION COMPONENTS ===== */
.nav-column {
  width: 60px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md) 0;
  gap: var(--space-md);
  z-index: var(--z-sticky);
}

.nav-btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  border: none;
  background: var(--color-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xl);
  transition: var(--transition-all);
  box-shadow: var(--shadow-sm);
  color: var(--color-text-primary);
}

.nav-btn:hover {
  background: var(--brand-600);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.nav-btn.active {
  background: var(--brand-600);
  color: white;
}

/* ===== LIST COMPONENTS ===== */
.list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.list-item {
  background: var(--color-surface-light);
  padding: var(--space-sm);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 2px solid transparent;
  border-left: 4px solid var(--color-success);
  cursor: pointer;
  transition: var(--transition-all);
}

.list-item:hover {
  background: var(--color-surface);
  transform: translateX(2px);
}

.list-item.selected {
  background: #e8f4fd;
  border-left-color: var(--color-info);
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.1);
}

.list-item-title {
  margin-bottom: var(--space-xs);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.list-item-description {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  line-height: var(--line-height-normal);
}

/* ===== FOOTER COMPONENTS ===== */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  z-index: var(--z-dropdown);
}

/* Footer Real-time Indicator */
.footer-realtime-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  background: var(--color-success);
  color: white;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  animation: pulse-indicator 0.6s ease-in-out infinite alternate;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.footer-realtime-indicator.hidden {
  display: none;
}

.realtime-pulse-icon {
  font-size: var(--font-size-base);
  animation: pulse-icon 1s ease-in-out infinite;
}

.realtime-text {
  white-space: nowrap;
  font-weight: var(--font-weight-semibold);
}

@keyframes pulse-indicator {
  0% {
    background: var(--color-success);
    transform: scale(1);
  }
  100% {
    background: #059669;
    transform: scale(1.02);
  }
}

@keyframes pulse-icon {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

.footer-info {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
}

.info-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.info-item .icon {
  font-size: var(--font-size-lg);
}

.info-item .value {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

/* ===== PANEL COMPONENTS ===== */
.panel {
  position: fixed;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  box-shadow: var(--shadow-panel);
  transform: translateY(100%);
  transition: transform var(--transition-slow);
  z-index: var(--z-dropdown);
  overflow-y: auto;
  backdrop-filter: blur(10px);
}

.panel.open {
  transform: translateY(0);
}

.panel-header {
  background: var(--color-background-light);
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  color: var(--color-text-primary);
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}

.panel-content {
  padding: var(--space-md);
}

/* ===== GRID COMPONENTS ===== */
.grid {
  display: grid;
  gap: var(--space-md);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ===== INFO CARD COMPONENT ===== */
.info-card {
  background: var(--color-background-light);
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--brand-600);
}

.info-card-title {
  margin: 0 0 var(--space-sm) 0;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.info-card-value {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--brand-600);
  margin: 0;
}

/* ===== LOADING & ERROR STATES ===== */
.loading {
  text-align: center;
  padding: var(--space-xl);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.error {
  background: #f8d7da;
  color: #721c24;
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
  border-left: 4px solid var(--color-error);
}

.success {
  background: #d1edff;
  color: #0c4a6e;
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
  border-left: 4px solid var(--color-success);
}

/* ===== RESPONSIVE UTILITIES ===== */
@media (max-width: 768px) {
  .nav-column {
    width: 50px;
  }

  .nav-btn {
    width: 40px;
    height: 40px;
    font-size: var(--font-size-lg);
  }

  .sidebar {
    left: 50px;
    width: 280px;
  }

  .footer-info {
    gap: var(--space-md);
  }

  .info-item {
    font-size: var(--font-size-xs);
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .header-title {
    font-size: var(--font-size-xl);
  }

  .logo {
    width: 250px;
    height: 48px;
  }
}

/* ===== LAYOUT COMPONENTS ===== */
.main-content {
  position: fixed;
  top: 80px;
  left: 0;
  right: 0;
  bottom: 50px;
  display: flex;
}

.right-column {
  flex: 1;
  position: relative;
  z-index: 1;
}

.map-container {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* ===== LOGIN COMPONENTS ===== */
.login-section {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
}

.login-form {
  max-width: 400px;
  width: 100%;
  margin: 2rem;
  background: var(--color-surface);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 1rem;
  margin-top: 1rem;
}

.login-header .logo {
  width: 315px;
  height: 65px;
  margin-bottom: 0rem;
}

.login-header h1 {
  font-size: 2.5rem;
  color: var(--brand-900);
  margin: 0;
  font-weight: 700;
}

.login-header h2 {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--color-text-secondary);
}

/* ===== GLASS MORPHISM & MODERN LAYOUT ===== */
.glass {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  border-radius: 14px;
  background-clip: padding-box; /* ensure background doesn't bleed into border */
  overflow: hidden;            /* clip backdrop to rounded corners */
  isolation: isolate;          /* ensure proper backdrop compositing in Chromium/Edge */
}

/* Floating top navigation */
.top-nav {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 50%;
  height: 64px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
}

.top-nav .logo {
  width: 220px;
  height: auto;
}

.top-nav .nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Make main content truly full-screen (map base layer) */
.main-content {
  top: 0;
  bottom: 0;
}

.map-container {
  position: fixed;
  inset: 0;
}

/* Floating left rail */
.left-rail {
  position: fixed;
  top: 96px; /* below top-nav */
  left: 16px;
  /*bottom: 72px; /* above footer bar (56px + 16px margin) */
  /*width: 64px;*/
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 950;
  overflow-y: auto; /* Allow scrolling if content exceeds available height */
}

.rail-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.06);
  color: rgb(31, 31, 31);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .2s ease, background .2s ease;
}
.rail-btn svg {
  width: 100%;
  height: auto;   /* mantiene le proporzioni */
  transform: scale(2.0); /* ingrandisce del 50% */
}

.rail-btn:hover {
  transform: translateY(-2px);
}

.rail-btn.active {
  background: var(--brand-light);
  color: white;
  border-color: transparent;
}

/* SVG icon sizing for rail buttons */
.rail-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  display: block;
}

/* Sliding panels */
.panel {
  position: fixed;
  top: 96px; /* below top-nav */
  left: 96px; /* right of left rail */
  width: 380px;
  max-width: calc(100vw - 128px);
  height: calc(100vh - 20vh);
  padding: 12px;
  display: flex;
  flex-direction: column;
  z-index: 900;
  transform: translateX(-120%);
  opacity: 0;
  transition: transform .3s ease, opacity .2s ease;
}

.panel.open {
  transform: translateX(0);
  opacity: 1;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.panel-title {
  font-weight: 700;
  color: var(--color-text-primary);
}

.panel-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: var(--transition-all);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-close:hover {
  background: var(--color-error);
  color: white;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.metric-card {
  background: var(--color-background-light);
  border-radius: 10px;
  padding: 10px;
  border-left: 4px solid var(--brand-600);
}

.metric-card h4 {
  margin: 0 0 6px 0;
  font-size: .9rem;
  color: var(--color-text-primary);
}

.metric-card .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brand-700);
}

.vehicles-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
}

/* Bottom floating footer bar + expandable panel */
.footer-bar {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  height: 56px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 960;
}

.footer-bar .footer-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.footer-bar .footer-expand-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--brand-600);
  color: #fff;
}

.footer-bar .footer-expand-btn:hover {
  background: var(--brand-700);
}

/* Bottom expandable panel */
.footer-panel {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 88px; /* sits above the footer bar */
  height: 240px;
  padding: 12px;
  overflow: auto;
  transform: translateY(120%);
  opacity: 0;
  transition: transform .3s ease, opacity .2s ease;
  z-index: 955;
}

.footer-panel.open {
  transform: translateY(0);
  opacity: 1;
}

/* ===== TRACK FILTER COMPONENTS ===== */
/* Track filter container */
.footer-track-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

/* Footer controls container */
.footer-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Footer details button */
.footer-details-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  font-family: var(--font-family-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--color-primary);
  color: var(--color-text-on-primary);
}

.footer-details-btn:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.footer-details-btn:active {
  transform: translateY(0);
}

/* Popup controls - visible only during realtime tracking */
.popup-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.popup-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.popup-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.popup-toggle-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-primary);
  white-space: nowrap;
}

/* ===== DETAILS PANEL COMPONENTS ===== */
/* Details panel */
.details-panel {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 88px; /* sits above the footer bar */
  height: 400px;
  padding: 12px;
  overflow: hidden;
  transform: translateY(120%);
  opacity: 0;
  transition: transform .3s ease, opacity .2s ease;
  z-index: 955;
}

.details-panel.open {
  transform: translateY(0);
  opacity: 1;
}

/* Details panel header */
.details-panel-header {
  background: var(--color-background-light);
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
}

.details-panel-header h3 {
  color: var(--color-text-primary);
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}

.details-panel-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.playback-button {
  background: var(--brand-600);
  border: none;
  color: white;
  cursor: pointer;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-sm);
  transition: var(--transition-all);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  height: 32px;
}

.playback-button:hover:not(:disabled) {
  background: var(--brand-700);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.playback-button:active:not(:disabled) {
  transform: translateY(0);
}

.playback-button:disabled {
  background: var(--color-background-light);
  color: var(--color-text-disabled);
  cursor: not-allowed;
  opacity: 0.5;
}

.playback-button.playing {
  background: var(--color-error);
}

.playback-button.playing:hover {
  background: #c53030;
}

.playback-button svg {
  width: 16px;
  height: 16px;
}

.close-details-panel {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: var(--transition-all);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-details-panel:hover {
  background: var(--color-error);
  color: white;
}

/* Details panel content */
.details-panel-content {
  padding: var(--space-md);
  height: calc(100% - 80px);
  overflow: hidden;
}

/* Details grid layout */
.details-grid {
  display: grid;
  grid-template-columns: 1fr 3fr;
  gap: var(--space-md);
  height: 100%;
  overflow: hidden;
}

/* Details summary section (left side) */
.details-summary {
  background: var(--color-background-light);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  border-left: 4px solid var(--brand-600);
  overflow-y: auto;
}

.details-summary h4 {
  margin: 0 0 var(--space-md) 0;
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
}

.summary-content {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
}

.summary-content p {
  margin: 0 0 var(--space-sm) 0;
}

.summary-content .summary-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
}

.summary-content .summary-label {
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

.summary-content .summary-value {
  font-weight: var(--font-weight-semibold);
  color: var(--brand-900);
}

/* Details data section (right side) */
.details-data {
  background: var(--color-background-light);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  border-left: 4px solid var(--color-info);
  display: flex;
  flex-direction: column;
  overflow-x: auto; /* Allow horizontal scrolling if needed */
  width: 100%;
}

.details-data h4 {
  margin: 0 0 var(--space-md) 0;
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
}

.table-container {
  flex: 1;
  overflow: auto; /* Allow scrolling for large datasets */
  width: 100%;
  min-width: 0; /* Allow shrinking */
}

/* GPS data table */
.gps-data-table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  height: 100%;
  table-layout: fixed;
}

.gps-data-table thead {
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 2;
}

.gps-data-table th {
  background: var(--color-background-light);
  color: var(--color-text-primary);
  font-weight: 600;
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border-light);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.gps-data-table th:last-child {
  border-right: none;
}

/* Sortable table headers */
.gps-data-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 2rem;
  transition: background-color 0.2s ease;
}

.gps-data-table th.sortable:hover {
  background: var(--color-surface-light);
}

.gps-data-table th.sortable[data-order="asc"] {
  background: rgba(59, 130, 246, 0.1);
  border-left: 3px solid var(--color-primary);
}

.gps-data-table th.sortable[data-order="desc"] {
  background: rgba(59, 130, 246, 0.1);
  border-left: 3px solid var(--color-primary);
}

/* Sort arrows */
.sort-arrow {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.gps-data-table th.sortable:hover .sort-arrow {
  opacity: 1;
}

.gps-data-table th.sortable[data-order="asc"] .sort-arrow,
.gps-data-table th.sortable[data-order="desc"] .sort-arrow {
  opacity: 1;
}

.gps-data-table td {
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--color-border-light);
  border-right: 1px solid var(--color-border-light);
  color: var(--color-text-secondary);
  white-space: nowrap;
  vertical-align: top;
}

.gps-data-table td:last-child {
  border-right: none;
}

.gps-data-table tbody tr:hover {
  background: var(--color-surface-light);
}

.gps-data-table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

.gps-data-table tbody tr:nth-child(even):hover {
  background: var(--color-surface-light);
}

/* Selected GPS row styling */
.gps-data-table tbody tr.selected-gps-row {
  background: rgba(59, 130, 246, 0.2) !important;
  border-left: 4px solid var(--brand-600);
  font-weight: var(--font-weight-medium);
}

.gps-data-table tbody tr.selected-gps-row td {
  color: var(--color-text-primary);
}

/* Column widths using fixed table layout */
.gps-data-table {
  table-layout: fixed;
}

.gps-data-table th:nth-child(1),
.gps-data-table td:nth-child(1) {
  width: 15%; /* Server Timestamp */
}

.gps-data-table th:nth-child(2),
.gps-data-table td:nth-child(2) {
  width: 15%; /* Device Timestamp */
}

.gps-data-table th:nth-child(3),
.gps-data-table td:nth-child(3) {
  width: 10%; /* Latitudine */
}

.gps-data-table th:nth-child(4),
.gps-data-table td:nth-child(4) {
  width: 10%; /* Longitudine */
}

.gps-data-table th:nth-child(5),
.gps-data-table td:nth-child(5) {
  width: 6%; /* Velocità */
}

.gps-data-table th:nth-child(6),
.gps-data-table td:nth-child(6) {
  width: 6%; /* Direzione */
}

.gps-data-table th:nth-child(7),
.gps-data-table td:nth-child(7) {
  width: 8%; /* Accensione */
}

.gps-data-table th:nth-child(8),
.gps-data-table td:nth-child(8) {
  width: 12%; /* Contachilometri */
}

.gps-data-table th:nth-child(9),
.gps-data-table td:nth-child(9) {
  width: 6%; /* Satelliti */
}

.gps-data-table th:nth-child(10),
.gps-data-table td:nth-child(10) {
  width: 6%; /* Batteria */
}

.gps-data-table th:nth-child(11),
.gps-data-table td:nth-child(11) {
  width: 6%; /* Volt. Est. */
}

/* Individual track filter item */
.track-filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Track filter label */
.track-filter-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-primary);
  white-space: nowrap;
}

/* Track filter input */
.track-filter-input {
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-family-primary);
  font-size: 12px;
  background-color: var(--color-background);
  color: var(--color-text-primary);
  transition: all 0.2s ease;
  height: 28px;
  width: 140px;
}

.track-filter-input:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Track filter apply button */
.track-filter-apply-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  font-family: var(--font-family-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--color-primary);
  color: var(--color-text-on-primary);
  min-width: 120px;
}

.track-filter-apply-btn:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.track-filter-apply-btn:active {
  transform: translateY(0);
}

.track-filter-apply-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ===== LEGACY LAYOUT (keeping for compatibility) ===== */
.selection-btn {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-lg);
  color: var(--color-text-primary);
}

.selection-btn:hover {
  background: var(--brand-400);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.selection-btn.active {
  background: var(--brand-400);
  color: white;
}

.sidebar {
  position: fixed;
  top: 80px;
  left: 60px;
  width: 320px;
  height: calc(100vh - 140px);
  background: var(--color-surface);
  border-right: 2px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15), 0 4px 20px rgba(0, 0, 0, 0.1), 0 0 40px rgba(0, 0, 0, 0.05);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 200;
  overflow-y: auto;
  backdrop-filter: blur(10px);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  background: var(--color-background-light);
  padding: 1rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h3 {
  color: var(--color-text-primary);
  margin: 0;
  font-size: 1.1rem;
}

.close-sidebar {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-sidebar:hover {
  background: var(--color-error);
  color: white;
}

.sidebar-content {
  padding: 1rem;
}

/* Footer expanded panel (legacy) */
.footer-expanded-panel {
  position: fixed;
  bottom: 50px;
  left: 0;
  right: 0;
  height: 200px;
  background: var(--color-surface);
  border-top: 2px solid var(--color-border);
  box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.15), 0 -2px 15px rgba(0, 0, 0, 0.1), 0 0 50px rgba(0, 0, 0, 0.08);
  transform: translateY(100%);
  transition: transform 0.3s ease;
  z-index: 99;
  overflow-y: auto;
  backdrop-filter: blur(10px);
}

.footer-expanded-panel.open {
  transform: translateY(0);
}

.expanded-panel-header {
  background: var(--color-background-light);
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.expanded-panel-header h3 {
  color: var(--color-text-primary);
  margin: 0;
}

.close-expanded-panel {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-expanded-panel:hover {
  background: var(--color-error);
  color: white;
}

.expanded-panel-content {
  padding: 1rem;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.info-card {
  background: var(--color-background-light);
  padding: 1rem;
  border-radius: 8px;
  border-left: 4px solid var(--brand-600);
}

.info-card h4 {
  margin: 0 0 0.5rem 0;
  color: var(--color-text-primary);
  font-size: 0.9rem;
}

.info-card .value {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--brand-600);
}

/* Lista veicoli */
.vehicles-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Trips and Stops Tables */
.table-container {
  max-height: unset; /*300px;*/
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-background);
}

.trips-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.trips-table th {
  background: var(--color-background-light);
  color: var(--color-text-primary);
  font-weight: 600;
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.trips-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text-secondary);
}

.trips-table tbody tr:hover {
  background: var(--color-background-light);
  cursor: pointer;
}

.trips-table tbody tr:last-child td {
  border-bottom: none;
}

.trips-section, .stops-section {
  margin-bottom: 1rem;
}

/* Selected trip/stop highlighting */
.trips-table tbody tr.selected-trip {
  background: var(--brand-100) !important;
  border-left: 3px solid var(--brand-600);
  font-weight: 600;
}

.trips-table tbody tr.selected-stop {
  background: rgba(214, 158, 46, 0.1) !important;
  border-left: 3px solid #D69E2E;
  font-weight: 600;
}

.trips-table tbody tr.selected-trip:hover,
.trips-table tbody tr.selected-stop:hover {
  background: var(--brand-200) !important;
}

/* Enhanced marker styles */
.route-point-marker,
.trip-start-marker,
.trip-end-marker,
.stop-marker {
  border: none !important;
  background: transparent !important;
}

.route-point-marker svg,
.trip-start-marker svg,
.trip-end-marker svg,
.stop-marker svg {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.vehicle-item {
  background: var(--color-surface-light);
  padding: 0.75rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.06), 0 0 20px rgba(0, 0, 0, 0.04);
  border: 2px solid transparent;
  border-left: 4px solid var(--color-success);
  cursor: pointer;
  transition: all 0.2s ease;
}

.vehicle-item:hover {
  background: var(--color-surface-light);
  transform: translateY(-2px);
}

.vehicle-item.selected {
  background: var(--color-background-light);
  border-left-color: var(--brand-600);
  box-shadow: 0 2px 8px rgba(86, 171, 47, 0.1);
}

/* Vehicle content layout */
.vehicle-content {
  display: flex;
  align-items: flex-start;
  /*gap: 12px;*/
  width: 100%;
}

.vehicle-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.vehicle-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.vehicle-name {
  color: var(--color-text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}

.vehicle-description {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

/* Loading e errori */
.loading {
  text-align: center;
  padding: 0rem;
  color: var(--color-text-muted);
}

.error {
  background: var(--color-surface-light);
  color: var(--color-error);
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  border-left: 4px solid var(--color-error);
}

/* Responsive per layout moderni */
@media (max-width: 768px) {
  .top-nav {
    left: 12px;
    right: 12px;
    height: 56px;
  }

  .left-rail {
    top: 84px;
    left: 12px;
    width: 56px;
  }

  .panel {
    top: 84px;
    left: 84px;
    width: min(86vw, 340px);
    height: calc(100vh - 112px);
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }

  .footer-bar {
    left: 12px;
    right: 12px;
    bottom: 12px;
    height: 48px;
  }

  .footer-panel {
    left: 12px;
    right: 12px;
    bottom: 76px;
    height: 200px;
  }

  /* Track filter responsive styles */
  .footer-track-filters {
    gap: 8px;
    flex-wrap: wrap;
  }

  .track-filter-item {
    flex: 1;
    min-width: 120px;
  }

  .track-filter-label {
    font-size: 10px;
  }

  .track-filter-input {
    width: 100%;
    min-width: 100px;
  }

  .track-filter-apply-btn {
    min-width: 100px;
    font-size: 11px;
    padding: 0 8px;
  }
}
