:root {
  --wafd-navy: #003087;
  --wafd-navy-dark: #002060;
  --wafd-gold: #C5A648;
  --wafd-gold-light: #D4BA6A;
  --wafd-gray: #F5F5F5;
  --wafd-text: #333333;
  --sidebar-width: 320px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--wafd-text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top Navigation */
.top-nav {
  background: var(--wafd-navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  flex-shrink: 0;
  z-index: 1000;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-brand .logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--wafd-gold);
}

.nav-brand .divider {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.3);
}

.nav-brand .title {
  font-size: 15px;
  font-weight: 400;
  opacity: 0.9;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lead-badge {
  background: var(--wafd-gold);
  color: var(--wafd-navy);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-gold {
  background: var(--wafd-gold);
  color: var(--wafd-navy);
}

.btn-gold:hover {
  background: var(--wafd-gold-light);
}

.btn-outline {
  background: transparent;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.6);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* Main Content Area */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: white;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-left 0.3s ease;
  z-index: 500;
  overflow: hidden;
}

.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-toggle {
  position: absolute;
  left: var(--sidebar-width);
  top: 8px;
  z-index: 600;
  background: white;
  border: 1px solid #ddd;
  border-left: none;
  border-radius: 0 6px 6px 0;
  padding: 8px 6px;
  cursor: pointer;
  transition: left 0.3s ease;
  box-shadow: 2px 0 4px rgba(0,0,0,0.1);
}

.sidebar.collapsed + .sidebar-toggle {
  left: 0;
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid #eee;
}

.sidebar-section h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  margin-bottom: 12px;
}

/* Search */
.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.search-box input:focus {
  border-color: var(--wafd-navy);
  box-shadow: 0 0 0 2px rgba(0, 48, 135, 0.1);
}

.search-box .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #aaa;
  font-size: 14px;
}

.search-results {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 8px;
}

.search-result-item {
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-result-item:hover {
  background: var(--wafd-gray);
}

.search-result-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.search-result-item .dot.branch {
  background: #16A34A;
}

.search-result-item .dot.lead {
  background: #2563EB;
}

/* Legend */
.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}

.legend-marker {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: white;
  flex-shrink: 0;
}

.legend-marker.branch {
  background: #16A34A;
}

.legend-marker.lead {
  background: #2563EB;
}

/* Filters */
.filter-group {
  margin-bottom: 12px;
}

.filter-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
}

.filter-group label input[type="checkbox"] {
  accent-color: var(--wafd-navy);
  width: 16px;
  height: 16px;
}

.filter-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  margin-top: 4px;
}

.filter-group select:focus {
  border-color: var(--wafd-navy);
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-card {
  background: var(--wafd-gray);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.stat-card .number {
  font-size: 22px;
  font-weight: 700;
  color: var(--wafd-navy);
}

.stat-card .label {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

/* Sidebar scrollable list area */
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
}

/* Map Container */
.map-container {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

/* Custom Leaflet Popup Styles */
.leaflet-popup-content-wrapper {
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-content {
  margin: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
}

.popup-header {
  font-size: 15px;
  font-weight: 600;
  color: var(--wafd-navy);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--wafd-gold);
}

.popup-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 4px;
  color: #555;
}

.popup-row .icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.popup-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
}

.popup-status.new-lead {
  background: #DBEAFE;
  color: #1E40AF;
}

.popup-status.contacted {
  background: #FEF3C7;
  color: #92400E;
}

.popup-status.in-progress {
  background: #D1FAE5;
  color: #065F46;
}

.popup-notes {
  margin-top: 8px;
  padding: 8px;
  background: #f9f9f9;
  border-radius: 4px;
  font-size: 12px;
  color: #666;
  font-style: italic;
}

.popup-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--wafd-navy);
  font-weight: 500;
  text-decoration: none;
  font-size: 12px;
}

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

/* Service badges in branch popups */
.service-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.service-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: #EFF6FF;
  color: #1E40AF;
  white-space: nowrap;
}

/* Branch loading spinner (sidebar) */
.branch-loading-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid #ddd;
  border-top-color: var(--wafd-navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* Footer */
.footer {
  background: var(--wafd-navy-dark);
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  padding: 6px;
  font-size: 11px;
  flex-shrink: 0;
}

/* Loading overlay */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.loading-overlay.active {
  display: flex;
}

.loading-box {
  background: white;
  border-radius: 12px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #eee;
  border-top-color: var(--wafd-navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-box p {
  font-size: 14px;
  color: #555;
}

.loading-box .progress-text {
  font-size: 12px;
  color: #999;
  margin-top: 8px;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: white;
  border-radius: 8px;
  padding: 12px 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
  border-left: 4px solid var(--wafd-navy);
}

.toast.success {
  border-left-color: #16A34A;
}

.toast.error {
  border-left-color: #DC2626;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* File input hidden */
.file-input-hidden {
  display: none;
}

/* Custom marker styles */
.branch-marker {
  background: #2563EB;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.lead-marker {
  background: #EA580C;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 800;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.1);
  }

  .nav-brand .title {
    display: none;
  }
}
