:root {
  --boston-red: #dc3545;
  --boston-blue: #0d6efd;
  --boston-dark: #212529;
  --boston-gray: #6c757d;
  --boston-light: #f8f9fa;
  --boston-white: #ffffff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--boston-light);
  overflow-x: hidden;
}

/* Boston Brand Colors */
.text-boston-red { color: var(--boston-red) !important; }
.text-boston-blue { color: var(--boston-blue) !important; }
.bg-boston-red { background-color: var(--boston-red) !important; }
.bg-boston-blue { background-color: var(--boston-blue) !important; }
.border-boston-red { border-color: var(--boston-red) !important; }
.border-boston-blue { border-color: var(--boston-blue) !important; }

/* Custom button classes */
.btn-boston-red {
  background-color: var(--boston-red);
  border-color: var(--boston-red);
  color: white;
}

.btn-boston-red:hover {
  background-color: #c82333;
  border-color: #bd2130;
  color: white;
}

.btn-outline-boston-red {
  color: var(--boston-red);
  border-color: var(--boston-red);
}

.btn-outline-boston-red:hover {
  background-color: var(--boston-red);
  border-color: var(--boston-red);
  color: white;
}

/* Dashboard Navbar */
.dashboard-navbar {
  background: var(--boston-white) !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.dashboard-brand {
  font-weight: 700;
  font-size: 1.5rem;
  text-decoration: none;
}

.dashboard-brand:hover {
  text-decoration: none;
}

/* Connection Status */
.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* Dashboard Main - DEFAULT DESKTOP */
.dashboard-main {
  height: calc(100vh - 140px);
  display: flex;
}

/* Dashboard Tabs */
.dashboard-tabs {
  background: var(--boston-white);
  border-bottom: 1px solid #dee2e6;
  position: sticky;
  top: 80px;
  z-index: 999;
}

.dashboard-tabs .nav-link {
  border: none;
  border-radius: 0;
  padding: 1rem 1.5rem;
  color: var(--boston-gray);
  font-weight: 500;
  position: relative;
  transition: all 0.3s ease;
  background: transparent !important;
}

.dashboard-tabs .nav-link:hover {
  color: var(--boston-red);
  border-color: transparent;
}

.dashboard-tabs .nav-link.active {
  color: var(--boston-red);
  border-color: transparent;
}

.dashboard-tabs .nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--boston-red);
  border-radius: 2px 2px 0 0;
}

/* Map Container - DEFAULT DESKTOP */
.map-container {
  flex: 1;
  position: relative;
  background: #e9ecef;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.map-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.loading-text {
  margin-top: 1rem;
  color: var(--boston-gray);
  font-weight: 500;
}

/* Deliveries Sidebar - DEFAULT DESKTOP */
.deliveries-sidebar {
  width: 400px;
  background: var(--boston-white);
  border-left: 1px solid #dee2e6;
  overflow-y: auto;
  padding: 1rem;
  flex-shrink: 0;
}

.delivery-card {
  border: 1px solid #dee2e6;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--boston-white);
  transition: all 0.3s ease;
  cursor: pointer;
}

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

.delivery-card.active {
  border-color: var(--boston-red);
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.2);
}

.delivery-status {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
}

.delivery-status.active {
  background-color: rgba(40, 167, 69, 0.1);
  color: #28a745;
}

.delivery-status.completed {
  background-color: rgba(108, 117, 125, 0.1);
  color: #6c757d;
}

.delivery-status.pending {
  background-color: rgba(255, 193, 7, 0.1);
  color: #856404;
}

/* Custom Scrollbar */
.deliveries-sidebar::-webkit-scrollbar {
  width: 6px;
}

.deliveries-sidebar::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.deliveries-sidebar::-webkit-scrollbar-thumb {
  background: var(--boston-red);
  border-radius: 10px;
}

.deliveries-sidebar::-webkit-scrollbar-thumb:hover {
  background: #c82333;
}

/* Map Styles */
.leaflet-popup-content {
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
}

.delivery-popup {
  min-width: 200px;
}

.delivery-popup h6 {
  color: var(--boston-red);
  margin-bottom: 0.5rem;
}

/* Custom Map Markers */
.delivery-marker {
  background: var(--boston-red);
  border: 3px solid var(--boston-white);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.delivery-marker:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Table improvements */
.table th {
  font-weight: 600;
  border-bottom: 2px solid var(--boston-red);
  color: var(--boston-dark);
  background-color: rgba(220, 53, 69, 0.05);
}

.table-hover tbody tr:hover {
  background-color: rgba(220, 53, 69, 0.05);
}

/* Card improvements */
.card {
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  border: none;
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.card-header {
  background: var(--boston-white);
  border-bottom: 1px solid #dee2e6;
  font-weight: 600;
  padding: 1rem 1.5rem;
  border-radius: 12px 12px 0 0 !important;
}

.card-footer {
  background: var(--boston-white);
  border-top: 1px solid #dee2e6;
  padding: 0.75rem 1.5rem;
  border-radius: 0 0 12px 12px !important;
}

/* Badge improvements */
.badge {
  font-weight: 500;
  padding: 0.5em 0.75em;
  border-radius: 6px;
}

.badge i {
  margin-right: 0.25rem;
}

/* Modal improvements */
.modal-header {
  border-bottom: 2px solid var(--boston-red);
}

.modal-title {
  font-weight: 600;
  color: var(--boston-dark);
}

.modal-footer {
  border-top: 1px solid #dee2e6;
}

/* Form improvements */
.form-label {
  font-weight: 500;
  color: var(--boston-dark);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--boston-red);
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.input-group-text {
  background-color: var(--boston-light);
  border-color: #ced4da;
  color: var(--boston-gray);
}

/* Button improvements */
.btn {
  border-radius: 8px;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: all 0.3s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

/* Alert improvements */
.alert {
  border-radius: 0;
  border: none;
  font-weight: 500;
}

.alert-info {
  background-color: rgba(13, 110, 253, 0.1);
  color: #084298;
  border-bottom: 3px solid var(--boston-blue);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease-out;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-in-right {
  animation: slideInRight 0.4s ease-out;
}

/* Demo specific styles */
.demo-badge {
  position: fixed;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  background: var(--boston-red);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  z-index: 1050;
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

/* === RESPONSIVE DESIGN === */

/* Tablet/Small Desktop - 993px to 1199px works fine with default layout */

/* Large Tablet - 769px to 992px */
@media (max-width: 992px) {
  .dashboard-main {
    flex-direction: column !important;
    height: calc(100vh - 140px);
  }
  
  .map-container {
    height: calc(60vh) !important;
    order: 1;
  }
  
  .deliveries-sidebar {
    width: 100% !important;
    height: calc(40vh - 60px);
    border-left: none;
    border-top: 1px solid #dee2e6;
    order: 2;
  }

  .dashboard-tabs .nav-link {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }
}

/* Mobile Large - 577px to 768px */
@media (max-width: 768px) {
  .dashboard-main {
    height: calc(100vh - 120px);
  }
  
  .map-container {
    height: calc(55vh) !important;
    min-height: 300px;
  }

  #map {
    min-height: 300px;
  }

  .deliveries-sidebar {
    height: calc(45vh - 120px);
    min-height: 200px;
    padding: 0.75rem;
  }
  
  .container-fluid {
    padding: 0.5rem !important;
  }
  
  .dashboard-brand {
    font-size: 1.25rem;
  }
}

/* Mobile Small - up to 576px */
@media (max-width: 576px) {
  .dashboard-main {
    height: calc(100vh - 100px);
  }
  
  .map-container {
    height: calc(50vh) !important;
    min-height: 280px;
  }

  #map {
    min-height: 280px;
  }

  .deliveries-sidebar {
    height: calc(50vh - 100px);
    min-height: 180px;
    padding: 0.5rem;
  }

  .dashboard-tabs .nav-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }
  
  .dashboard-tabs .nav-link i {
    display: none;
  }
  
  .demo-badge {
    display: none;
  }

  .container-fluid {
    padding: 0.25rem !important;
  }
}

/* Force map visibility on all devices */
.leaflet-container {
  width: 100% !important;
  height: 100% !important;
}

.leaflet-map-pane {
  width: 100% !important;
  height: 100% !important;
}

/* Loading states */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Tab content animations */
.tab-pane {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tab-pane.show.active {
  opacity: 1;
}

/* Statistics cards hover effect */
.stats-card {
  transition: all 0.3s ease;
}

.stats-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Empty state styles */
.empty-state {
  padding: 3rem;
  text-align: center;
  color: var(--boston-gray);
}

.empty-state i {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Delivery list item details */
.delivery-info h6 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--boston-dark);
}

.delivery-info .text-muted {
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.delivery-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
}

.delivery-time {
  font-size: 0.8rem;
  color: var(--boston-gray);
}

/* Custom styles for demo content */
.demo-content {
  padding: 2rem;
  text-align: center;
  color: var(--boston-gray);
}

.demo-content h5 {
  color: var(--boston-red);
  margin-bottom: 1rem;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 100px;
  right: 20px;
  z-index: 1055;
}

.toast {
  border-radius: 8px;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Custom delivery status colors */
.status-en-camino { background-color: rgba(255, 193, 7, 0.1); color: #856404; }
.status-entregado { background-color: rgba(40, 167, 69, 0.1); color: #155724; }
.status-pendiente { background-color: rgba(108, 117, 125, 0.1); color: #383d41; }
.status-cancelado { background-color: rgba(220, 53, 69, 0.1); color: #721c24; }

/* User role badges */
.role-admin { background-color: var(--boston-red); }
.role-delivery { background-color: var(--boston-blue); }
.role-manager { background-color: #28a745; }

/* Additional utility classes */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.border-start-thick {
  border-left: 4px solid var(--boston-red) !important;
}
