:root {
  color-scheme: light;
  --timelsa-blue: #0066cc;
  --timelsa-yellow: #ffcc00;
  --timelsa-red: #ff3333;
  --timelsa-white: #ffffff;
  --surface: #f8fafc;
  --text: #0f172a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: "Cairo", system-ui, -apple-system, sans-serif;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.map-page {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding-top: 73px; /* Header height only */
  padding-bottom: 73px; /* Bottom nav height */
  margin: 0;
  box-sizing: border-box;
  z-index: 1;
}

.map-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  flex: 1;
}


.filter-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Cairo', sans-serif;
}

.filter-btn:hover {
  border-color: var(--timelsa-blue);
  color: var(--timelsa-blue);
}

.filter-btn.is-active {
  background: var(--timelsa-blue);
  color: #fff;
  border-color: var(--timelsa-blue);
  box-shadow: 0 10px 20px rgba(0, 102, 204, 0.25);
}

.stats {
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}

.map-shell {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: calc(100vh - 146px); /* Header (73px) + Bottom nav (73px) */
  height: calc(100vh - 146px);
  overflow: hidden;
  transition: width 0.3s ease;
}

/* Sidebar open on desktop - adjust map */
@media (min-width: 1024px) {
  .map-shell {
    width: calc(100% - 380px);
  }
}

#map {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  /* تحسينات للهاتف */
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-x pan-y pinch-zoom;
}

.map-error {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  color: var(--timelsa-red);
  font-weight: 700;
  padding: 1.5rem;
  text-align: center;
  z-index: 10;
}

.marker-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: #fff;
  font-weight: 800;
  border: 3px solid #fff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.marker-store {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}
.marker-company {
  background: linear-gradient(135deg, #f97316, #ea580c);
}
.marker-gps {
  background: linear-gradient(135deg, #10b981, #0f766e);
}

.popup-card {
  min-width: 220px;
  max-width: 260px;
  direction: rtl;
}

.popup-title {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 800;
  color: var(--timelsa-blue);
}

.popup-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(0, 102, 204, 0.1);
  color: var(--text);
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.popup-meta {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 0.85rem;
}

.popup-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-weight: 700;
  color: var(--timelsa-blue);
  text-decoration: none;
}

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

.leaflet-popup-content-wrapper {
  border-radius: 14px;
  border: 1px solid #e2e8f0;
}

.leaflet-control-zoom {
  border-radius: 10px;
  overflow: hidden;
}

.leaflet-control-attribution {
  display: none;
}


/* للحاسوب الكبير */
@media (min-width: 1024px) {
  .map-page {
    padding-top: 73px;
    padding-bottom: 73px;
  }
  
  .map-shell {
    min-height: calc(100vh - 146px);
  }
  
  #map {
    min-height: calc(100vh - 146px);
    height: calc(100vh - 146px);
  }
}

/* للتابلت */
@media (min-width: 769px) and (max-width: 1023px) {
  .map-page {
    padding-top: 73px;
    padding-bottom: 73px;
  }
  
  .map-shell {
    min-height: calc(100vh - 146px);
  }
  
  #map {
    min-height: calc(100vh - 146px);
    height: calc(100vh - 146px);
  }
}

/* للهاتف */
@media (max-width: 768px) {
  .map-page {
    padding-top: 73px;
    padding-bottom: 73px;
  }
  
  .map-shell {
    min-height: calc(100vh - 146px);
  }
  
  #map {
    min-height: calc(100vh - 146px);
    height: calc(100vh - 146px);
  }
  
  .map-controls-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .controls {
    justify-content: flex-start;
    width: 100%;
    gap: 0.4rem;
  }
  
  .filter-btn {
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
  }
  
  .stats {
    width: 100%;
    text-align: right;
    font-size: 0.9rem;
  }
}

/* للهواتف الصغيرة */
@media (max-width: 480px) {
  .map-page {
    padding-top: 73px;
    padding-bottom: 73px;
  }
  
  .map-shell {
    min-height: calc(100vh - 146px);
  }
  
  #map {
    min-height: calc(100vh - 146px);
    height: calc(100vh - 146px);
  }
  
  .filter-btn {
    padding: 0.4rem 0.65rem;
    font-size: 0.8rem;
  }
}

/* Companies Sidebar */
.companies-sidebar {
  position: fixed;
  top: 73px;
  right: 0;
  width: 380px;
  height: calc(100vh - 146px);
  background: white;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 45;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(0);
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  flex-shrink: 0;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
}

.sidebar-count {
  font-size: 0.875rem;
  color: #64748b;
  font-weight: 600;
}

.sidebar-search {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.sidebar-search input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: 'Cairo', sans-serif;
  transition: all 0.2s;
  direction: rtl;
}

.sidebar-search input:focus {
  outline: none;
  border-color: var(--timelsa-blue);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.companies-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  direction: rtl;
}

.companies-list::-webkit-scrollbar {
  width: 8px;
}

.companies-list::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.companies-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.companies-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  margin-bottom: 0.5rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  border: 2px solid transparent;
}

.sidebar-item:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
  transform: translateX(-2px);
}

.sidebar-item-active {
  background: #eff6ff;
  border-color: var(--timelsa-blue);
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.15);
}

.sidebar-item-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-item-content {
  flex: 1;
  min-width: 0;
}

.sidebar-item-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-item-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.sidebar-item-category {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  background: rgba(0, 102, 204, 0.1);
  color: #1e293b;
  font-weight: 600;
  font-size: 0.8rem;
}

.sidebar-item-city {
  color: #64748b;
  font-size: 0.875rem;
  font-weight: 500;
}

.sidebar-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #64748b;
}

/* Sidebar Toggle Button (Mobile) */
.sidebar-toggle {
  position: fixed;
  top: 80px;
  right: 1rem;
  width: 48px;
  height: 48px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 46;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.2s;
}

.sidebar-toggle:hover {
  background: #f8fafc;
  border-color: var(--timelsa-blue);
}

.sidebar-toggle svg {
  color: #0f172a;
}

/* Mobile Sidebar */
@media (max-width: 1023px) {
  .companies-sidebar {
    width: 320px;
    transform: translateX(100%);
    top: 73px;
    height: calc(100vh - 146px);
  }
  
  .companies-sidebar.sidebar-open {
    transform: translateX(0);
  }
  
  .sidebar-toggle {
    display: flex;
  }
  
  .map-shell {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 768px) {
  .companies-sidebar {
    width: 100%;
    top: 73px;
    height: calc(100vh - 146px);
  }
  
  .sidebar-toggle {
    top: 80px;
  }
}

@media (max-width: 480px) {
  .companies-sidebar {
    top: 73px;
    height: calc(100vh - 146px);
  }
  
  .sidebar-toggle {
    top: 155px;
  }
}

