/* 100k Premium UI Overhaul */
:root {
  --primary: #0F172A;
  --primary-hover: #020617;
  --secondary: #334155;
  --accent: #0369A1; 
  
  --status-available: #22C55E;
  --status-unavailable: #9CA3AF;
  
  --text-primary: #020617;
  --text-secondary: #475569;
  --bg-main: #F8FAFC;
  --bg-filter: rgba(255, 255, 255, 0.85);
  --border-color: rgba(15, 23, 42, 0.08);
  
  --header-height: 72px;
  --sidebar-width: 360px;
}

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

body {
  font-family: 'Open Sans', -apple-system, sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-main);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

h1, h2, h3, h4, h5, h6, .logo-title { font-family: 'Poppins', sans-serif; }

/* Map Area (Full Bleed) */
.app-main { width: 100%; height: 100%; }
.map-container { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 0; }
#map { width: 100%; height: 100%; }

/* Header - Floating Glass Pill */
.app-header {
  position: absolute; top: 24px; left: 50%; transform: translateX(-50%);
  width: calc(100% - 48px); max-width: 1400px; height: var(--header-height);
  background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: 24px; box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.3), inset 0 1px 0 rgba(255,255,255,0.1);
  color: white; padding: 0 32px; display: flex; align-items: center; z-index: 1001; 
}
.header-content { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.logo-title { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }

/* Search Bar */
.search-container { display: flex; max-width: 440px; width: 100%; position: relative; margin: 0 20px; }
.search-container input {
  width: 100%; padding: 12px 48px 12px 20px; border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.05); color: white;
  font-size: 15px; outline: none; font-family: inherit; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.search-container input::placeholder { color: rgba(255,255,255,0.5); }
.search-container input:focus {
  background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.25);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.05);
}
.search-container button {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: rgba(255,255,255,0.6); cursor: pointer; transition: color 0.2s;
}
.search-container button:hover { color: white; }
.mobile-toggle { display: none; }

/* Sidebar - Floating Panel */
.sidebar-filters {
  position: absolute; top: calc(24px + var(--header-height) + 24px); left: calc(50% - 700px);
  width: var(--sidebar-width); max-height: calc(100vh - var(--header-height) - 96px);
  background: var(--bg-filter); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-radius: 24px; box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.15), inset 0 1px 0 rgba(255,255,255,1);
  border: 1px solid rgba(255,255,255,0.6); overflow-y: auto; padding: 32px 24px;
  display: flex; flex-direction: column; gap: 28px; z-index: 1000;
}
@media (max-width: 1448px) { .sidebar-filters { left: 24px; } }

.filter-header-mobile { display: none; }
.filter-group h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; color: var(--primary); letter-spacing: -0.2px; }
.checkbox-label { display: flex; align-items: center; font-size: 15px; cursor: pointer; gap: 12px; padding: 8px 12px; border-radius: 12px; transition: background 0.2s; }
.checkbox-label:hover { background: rgba(15, 23, 42, 0.03); }
.checkbox-label input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

/* Pulse Dots */
.status-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; position: relative; }
.dot-available { background: var(--status-available); box-shadow: 0 0 8px rgba(34, 197, 94, 0.4); }
.dot-available::after {
  content: ''; position: absolute; top: -4px; left: -4px; right: -4px; bottom: -4px;
  border-radius: 50%; border: 2px solid var(--status-available); opacity: 0;
  animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
.dot-unavailable { background: var(--status-unavailable); }
@keyframes pulse-ring { 0% { transform: scale(0.6); opacity: 0.8; } 100% { transform: scale(1.5); opacity: 0; } }

/* Base Buttons & Inputs */
.custom-select {
  width: 100%; padding: 12px 16px; border: 1px solid var(--border-color); border-radius: 12px;
  font-family: inherit; font-size: 14px; background-color: rgba(255,255,255,0.7); outline: none;
  margin-bottom: 12px; transition: all 0.2s; cursor: pointer; -webkit-appearance: none; appearance: none;
  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='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px;
}
.custom-select:hover, .custom-select:focus { background-color: white; border-color: rgba(15, 23, 42, 0.2); box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05); }

.primary-btn, .secondary-btn, .outline-btn {
  padding: 12px 20px; border-radius: 12px; font-family: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none;
}
.btn-full { width: 100%; }
.primary-btn { background: linear-gradient(135deg, var(--accent), #0284C7); color: white; box-shadow: 0 8px 16px -4px rgba(3, 105, 161, 0.3); }
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 20px -4px rgba(3, 105, 161, 0.4); }
.secondary-btn { background-color: white; color: var(--primary); border: 1px solid var(--border-color); box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.05); }
.secondary-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 12px -2px rgba(15, 23, 42, 0.08); }
.outline-btn { background-color: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); width: 100%; }
.outline-btn:hover { background-color: white; color: var(--primary); border-color: rgba(15, 23, 42, 0.2); }

/* Overlays */
.state-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: var(--bg-filter); backdrop-filter: blur(8px);
  z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: opacity 0.5s; border-radius: 24px;
}
.state-overlay.hidden { display: none; opacity: 0; pointer-events: none; }
.spinner { width: 48px; height: 48px; border: 4px solid rgba(3, 105, 161, 0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 20px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Floating Radius Control */
.floating-radius-control { position: absolute; top: calc(24px + var(--header-height) + 24px); right: calc(50% - 700px); background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border-radius: 16px; box-shadow: 0 12px 24px -12px rgba(15, 23, 42, 0.2), inset 0 1px 0 rgba(255,255,255,1); border: 1px solid var(--border-color); display: flex; align-items: center; padding: 4px; z-index: 1000; }
@media (max-width: 1448px) { .floating-radius-control { right: 24px; } }
@media (max-width: 1024px) { .floating-radius-control { top: calc(16px + var(--header-height) + 16px); right: 20px; } }
@media (max-width: 768px) { .floating-radius-control { top: auto; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); left: 16px; right: auto; } }

/* Floating Filters FAB — mobile only */
.mobile-filter-fab { display: none; }

/* Mobile search result chip — hidden on desktop, slides in below header on mobile */
.mobile-search-chip {
    display: none; /* shown only on mobile via media query + JS .visible class */
}
@media (max-width: 768px) {
    .mobile-search-chip {
        display: block;
        position: fixed;
        top: 0;
        left: 50%;
        transform: translateX(-50%) translateY(-60px);
        z-index: 1200;
        background: rgba(15, 23, 42, 0.88);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        color: white;
        font-size: 13px;
        font-weight: 600;
        font-family: inherit;
        padding: 8px 18px;
        border-radius: 50px;
        white-space: nowrap;
        box-shadow: 0 4px 16px rgba(15, 23, 42, 0.25);
        pointer-events: none;
        transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s ease;
        opacity: 0;
    }
    .mobile-search-chip.visible {
        /* header: top 16px + ~56px auto height + 8px gap = ~80px; +24px for iPhone status bar env */
        transform: translateX(-50%) translateY(104px);
        opacity: 1;
    }
    .mobile-search-chip.found  { background: rgba(3, 105, 161, 0.92); }
    .mobile-search-chip.empty  { background: rgba(180, 83, 9, 0.92); }
}
.floating-icon-btn { background: transparent; border: none; padding: 10px; cursor: pointer; color: var(--primary); display: flex; align-items: center; justify-content: center; border-radius: 12px; transition: all 0.2s; }
.floating-icon-btn:hover { background: rgba(15, 23, 42, 0.05); color: var(--accent); }
.vertical-divider { width: 1px; height: 24px; background: var(--border-color); margin: 0 4px; }
.floating-select { background: transparent; border: none; padding: 10px 32px 10px 12px; font-weight: 600; color: var(--primary); font-family: inherit; font-size: 14px; cursor: pointer; -webkit-appearance: none; appearance: none; outline: none; 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='%230F172A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; border-radius: 12px; transition: all 0.2s; }
.floating-select:hover { background-color: rgba(15, 23, 42, 0.05); }

/* Leaflet Overrides for 100k Look */
.leaflet-popup-content-wrapper { background: rgba(255,255,255,0.95); backdrop-filter: blur(16px); border-radius: 20px; box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.2); padding: 4px; border: 1px solid rgba(255,255,255,1); }
.leaflet-popup-tip { background: rgba(255,255,255,0.95); }
.leaflet-popup-content { margin: 16px; line-height: 1.5; }
.popup-header { margin-bottom: 12px; }
.popup-header h3 { font-size: 18px; color: var(--primary); margin: 0 0 4px 0; }
.popup-services { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
.popup-status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; padding: 6px 12px; background: rgba(15, 23, 42, 0.04); border-radius: 12px; margin-bottom: 16px; color: var(--primary); }
.popup-actions { display: flex; gap: 8px; }
.popup-btn { flex: 1; padding: 10px; font-size: 14px; border-radius: 10px; cursor: pointer; border: none; font-weight: 600; text-align: center; transition: all 0.2s; }
.popup-btn-primary { background: linear-gradient(135deg, var(--accent), #0284C7); color: white; box-shadow: 0 4px 8px rgba(3, 105, 161, 0.2); }
.popup-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 12px rgba(3, 105, 161, 0.3); }
.popup-btn-secondary { background: rgba(15, 23, 42, 0.05); color: var(--primary); }
.popup-btn-secondary:hover { background: rgba(15, 23, 42, 0.08); }

/* Custom Map Markers */
.custom-pin svg { filter: drop-shadow(0 8px 12px rgba(15, 23, 42, 0.25)); transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); }
.custom-pin:hover svg, .custom-pin.leaflet-marker-icon:focus svg { transform: scale(1.15) translateY(-4px); filter: drop-shadow(0 12px 20px rgba(15, 23, 42, 0.35)); z-index: 1000 !important; }
.user-location-pin svg { filter: drop-shadow(0 8px 12px rgba(59, 130, 246, 0.4)); animation: gently-bob 3s ease-in-out infinite; }
@keyframes gently-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* Leaflet Zoom Control Position Adjustment */
.leaflet-control-zoom { border: none !important; box-shadow: 0 8px 16px rgba(15, 23, 42, 0.1) !important; margin-bottom: 24px !important; margin-right: 24px !important;}
.leaflet-control-zoom-in, .leaflet-control-zoom-out { background: rgba(255,255,255,0.9) !important; backdrop-filter: blur(8px); border-color: rgba(15,23,42,0.1) !important; color: var(--primary) !important;  }
.leaflet-control-zoom-in { border-top-left-radius: 12px !important; border-top-right-radius: 12px !important; }
.leaflet-control-zoom-out { border-bottom-left-radius: 12px !important; border-bottom-right-radius: 12px !important; }

/* Modal 100k Aesthetics */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade-in 0.3s ease-out; }
.modal-overlay.hidden { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-container { background: white; border-radius: 32px; width: 100%; max-width: 540px; max-height: 90vh; box-shadow: 0 40px 80px -20px rgba(15, 23, 42, 0.3); position: relative; display: flex; flex-direction: column; overflow: hidden; animation: slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes slide-up { from { transform: translateY(40px) scale(0.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.modal-close { position: absolute; top: 20px; right: 20px; background: rgba(15, 23, 42, 0.05); border: none; font-size: 24px; color: var(--text-secondary); cursor: pointer; z-index: 10; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.modal-close:hover { background: rgba(15, 23, 42, 0.1); color: var(--primary); transform: scale(1.05); }
.modal-content-scroll { padding: 40px; overflow-y: auto; }

/* Footer - Inside Sidebar (Sticky Bottom) */
.app-footer { position: sticky; bottom: -32px; margin-top: auto; margin-left: -24px; margin-right: -24px; padding: 24px; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(24px); border-top: 1px solid var(--border-color); font-size: 13px; font-weight: 500; color: var(--text-secondary); display: flex; flex-direction: column; gap: 6px; z-index: 10; }
.results-count { font-weight: 600; color: var(--primary); }

/* Modal Inner Classes */
.modal-hero { display: flex; gap: 24px; margin-bottom: 28px; align-items: center; }
.modal-trade-icon {
  width: 80px; height: 80px; border-radius: 24px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #0284C7);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 24px -6px rgba(3, 105, 161, 0.3);
  color: white;
}
.modal-title { font-size: 26px; color: var(--primary); margin-bottom: 6px; letter-spacing: -0.5px; }
.modal-subtitle { font-size: 15px; color: var(--text-secondary); margin-bottom: 10px; }
.modal-rating { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: #F59E0B; background: rgba(245, 158, 11, 0.1); padding: 4px 10px; border-radius: 10px; font-size: 14px; }
.modal-info-card { background: rgba(15, 23, 42, 0.03); padding: 20px; border-radius: 20px; margin-bottom: 24px; border: 1px solid rgba(15, 23, 42, 0.05); }
.modal-status { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; margin-bottom: 16px; color: var(--primary); }
.modal-services { font-size: 14px; color: var(--text-secondary); margin-bottom: 12px; }
.modal-services strong, .modal-zones strong { color: var(--primary); display: block; margin-bottom: 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; }
.modal-zones { font-size: 14px; color: var(--text-secondary); }

/* Tag chips — trade sub-category labels on profile card */
.tag-chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag-chip {
  background: rgba(3, 105, 161, 0.08); color: var(--accent);
  border: 1px solid rgba(3, 105, 161, 0.15);
  padding: 4px 10px; border-radius: 8px; font-size: 12px; font-weight: 600;
}

/* Zone badges — service area labels on profile card */
.zone-badges-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.zone-badge {
  background: rgba(15, 23, 42, 0.05); color: var(--secondary);
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 4px 10px; border-radius: 8px; font-size: 12px; font-weight: 500;
}

.modal-bio { margin-top: 0; font-size: 15px; color: var(--text-secondary); line-height: 1.6; padding-bottom: 24px; border-bottom: 1px solid var(--border-color); }
.modal-actions { margin-top: 24px; display: flex; flex-direction: column; gap: 12px; }

/* Responsive Adjustments */
@media (max-width: 1024px) {
  .app-header { width: calc(100% - 32px); top: 16px; border-radius: 20px; padding: 0 20px; }
  .sidebar-filters { top: calc(16px + var(--header-height) + 16px); left: 16px; }
}
@media (max-width: 768px) {
  /* Full-width search — hide header Filters toggle, use FAB instead */
  .app-header { height: auto; padding: 12px 16px; }
  .header-content { gap: 0; }
  .search-container { max-width: 100%; flex: 1; margin: 0; }
  .mobile-toggle { display: none !important; }
  .mobile-filter-fab {
    display: flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    z-index: 1100;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px -4px rgba(3, 105, 161, 0.5);
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
  }
  .mobile-filter-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -4px rgba(3, 105, 161, 0.6); }
  .sidebar-filters { position: fixed; top: 0; left: 0; bottom: 0; width: 320px; max-height: 100vh; border-radius: 0; border-top-right-radius: 32px; border-bottom-right-radius: 32px; transform: translateX(-100%); transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 20px 0 40px rgba(15, 23, 42, 0.2); z-index: 2000; }
  .sidebar-filters.open { transform: translateX(0); }
  .filter-header-mobile { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border-color); }
  .filter-header-mobile h2 { font-size: 20px; color: var(--primary); }
  #close-mobile-filters { background: rgba(15, 23, 42, 0.05); border: none; width: 36px; height: 36px; border-radius: 50%; font-size: 24px; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; }
}
@media (max-width: 480px) {
  .logo-title { display: none; }
  .search-container { margin: 0; max-width: 100%; }
  .modal-content-scroll { padding: 24px; }
}

/* Accessibility */
:focus-visible { outline: 3px solid rgba(3, 105, 161, 0.5); outline-offset: 4px; border-radius: inherit; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; } }

/* Demo Banner */
.demo-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3000;
  background-color: #FEF3C7;
  color: #92400E;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.05);
}
