/* Reset default styles */
* {
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

html, body {
    height: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
}

h1, h2, h3 {
    color: #333;
    margin-bottom: 10px;
}

/* Main map container - MUST be full screen */
#map {
    height: 100vh !important;
    width: 100vw !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 1 !important;
}

/* Controls Panel */
.map-controls {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    max-width: 250px;
    backdrop-filter: blur(5px);
}

.controls-panel {
    padding: 20px;
    min-width: 200px;
}

.controls-panel h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 16px;
    font-weight: bold;
}

/* Layer Controls */
.layer-controls {
    margin-bottom: 15px;
}

.layer-controls label {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
}

.layer-controls label:hover {
    color: #333;
}

.layer-controls input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.layer-indicator {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 6px;
    border: 1px solid #666;
    border-radius: 2px;
}

.visitors-indicator {
    background: linear-gradient(45deg, #b8d1a7 50%, #3d8c40 50%);
}

.overlap-indicator {
    background: transparent;
    border: 2px dashed rgba(134, 116, 161, 0.8);
}

/* Action Controls */
.action-controls {
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
}

/* Vendor Controls */
.vendor-controls {
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
    margin-top: 15px;
}

.vendor-controls h4 {
    margin-bottom: 10px;
    color: #333;
    font-size: 14px;
    font-weight: bold;
}

.vendor-controls label {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #555;
}

.vendor-controls label:hover {
    color: #333;
}

.vendor-controls input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.vendor-controls select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    cursor: pointer;
}

.vendor-controls select:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 3px rgba(0, 124, 186, 0.3);
}

.export-btn {
    background: #007cba;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    width: 100%;
    transition: background-color 0.3s;
}

.export-btn:hover {
    background: #005a87;
}

.export-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Enhanced legend styles for vendor choropleth */
.map-legend-control .legend-section {
    margin-bottom: 12px !important;
    padding-bottom: 8px !important;
    border-bottom: 1px solid #eee !important;
}

.map-legend-control .legend-section:last-child {
    border-bottom: none !important;
}

.map-legend-control .legend-section h5 {
    margin: 0 0 8px 0 !important;
    font-size: 13px !important;
    font-weight: bold !important;
    color: #333 !important;
    text-align: left !important;
}

.map-legend-control .legend-subsection {
    margin-bottom: 8px !important;
}

.map-legend-control .legend-subsection h6 {
    margin: 5px 0 3px 0 !important;
    font-size: 11px !important;
    font-weight: bold !important;
    color: #555 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

.map-legend-control .vendor-colors-list {
    max-height: 120px !important;
    overflow-y: auto !important;
    padding-right: 5px !important;
}

.map-legend-control .vendor-colors-list::-webkit-scrollbar {
    width: 4px !important;
}

.map-legend-control .vendor-colors-list::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
    border-radius: 2px !important;
}

.map-legend-control .vendor-colors-list::-webkit-scrollbar-thumb {
    background: #888 !important;
    border-radius: 2px !important;
}

.map-legend-control .vendor-colors-list::-webkit-scrollbar-thumb:hover {
    background: #555 !important;
}

/* Vendor highlight animations */
.vendor-highlight {
    animation: highlightPulse 2s ease-in-out infinite !important;
}

@keyframes highlightPulse {
    0%, 100% { 
        opacity: 1;
        stroke-width: 4;
    }
    50% { 
        opacity: 0.6;
        stroke-width: 6;
    }
}

/* Efficiency tier indicators */
.efficiency-high {
    background: rgba(46, 204, 113, 1.0) !important;
}

.efficiency-medium {
    background: rgba(46, 204, 113, 0.6) !important;
}

.efficiency-low {
    background: rgba(46, 204, 113, 0.3) !important;
}

/* Low performer highlight border */
.low-performer-border {
    border: 4px dashed #dc3545 !important;
    animation: lowPerformerBlink 3s ease-in-out infinite !important;
}

@keyframes lowPerformerBlink {
    0%, 100% { 
        border-color: #dc3545;
        opacity: 1;
    }
    50% { 
        border-color: #ff6b6b;
        opacity: 0.7;
    }
}

/* Map legend control (now on the map) */
.map-legend-control {
    background: rgba(255, 255, 255, 0.95) !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2) !important;
    padding: 10px !important;
    font-family: Arial, sans-serif !important;
    font-size: 12px !important;
    border: 2px solid #333 !important;
    max-width: 180px !important;
}

.map-legend-control .legend-content h4 {
    margin: 0 0 8px 0 !important;
    font-size: 14px !important;
    font-weight: bold !important;
    color: #333 !important;
    text-align: center !important;
}

.map-legend-control .legend-item {
    display: flex !important;
    align-items: center !important;
    margin-bottom: 4px !important;
    font-size: 11px !important;
}

.map-legend-control .legend-color {
    width: 16px !important;
    height: 16px !important;
    margin-right: 6px !important;
    border: 1px solid #666 !important;
    flex-shrink: 0 !important;
}

.map-legend-control .legend-line {
    width: 16px !important;
    height: 16px !important;
    margin-right: 6px !important;
    flex-shrink: 0 !important;
}

/* Remove old legend styles */
.map-legend {
    display: none !important;
}

/* Enhanced overlap pattern for legend */
.overlap-legend-pattern {
    width: 16px !important;
    height: 16px !important;
    background-color: #8B4A9C !important;
    opacity: 0.4 !important;
    border: 2px dashed #8B4A9C !important;
    border-radius: 2px !important;
    margin-right: 6px !important;
}

/* ZIP code labels for PDF export */
.zip-label-visitor,
.zip-label-vendor,
.zip-label-print,
.zip-label-overlap {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

.zip-label-text {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid #333 !important;
    border-radius: 4px !important;
    padding: 2px 6px !important;
    font-size: 11px !important;
    font-weight: bold !important;
    color: #333 !important;
    text-align: center !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}

.zip-label-text-overlap {
    background: rgba(139, 74, 156, 0.95) !important;
    border: 2px solid #8B4A9C !important;
    border-radius: 6px !important;
    padding: 3px 8px !important;
    font-size: 10px !important;
    font-weight: bold !important;
    color: white !important;
    text-align: center !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4) !important;
}

.zip-label-text-overlap small {
    font-size: 8px !important;
    opacity: 0.9 !important;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error message */
.error-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.error-content {
    background-color: white;
    padding: 20px;
    border-radius: 5px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

.error-content h3 {
    color: #d32f2f;
    margin-bottom: 10px;
}

.error-content p {
    margin-bottom: 20px;
}

.close-error-btn {
    background-color: #d32f2f;
}

.close-error-btn:hover {
    background-color: #b71c1c;
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-50px);
    background: rgba(40, 167, 69, 0.95);
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.notification.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Notification system */
.notification.error {
    background: rgba(220, 53, 69, 0.95);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .map-controls {
        top: 5px;
        right: 5px;
        left: 5px;
        max-width: none;
        padding: 10px;
    }
    
.map-legend {
        bottom: 5px;
        right: 5px;
        left: 5px;
        max-width: none;
    }
    
    .layer-controls label {
        font-size: 13px;
    }
    
    .legend-item {
        font-size: 11px;
    }
}

/* Leaflet popup styling */
.leaflet-popup-content-wrapper {
    border-radius: 6px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
}

.leaflet-popup-content {
    margin: 12px;
    font-size: 13px;
    line-height: 1.4;
    color: #333;
}

/* Tooltip styling */
.leaflet-tooltip {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px;
    font-size: 12px;
    line-height: 1.4;
}

.leaflet-tooltip-top:before {
    border-top-color: rgba(0, 0, 0, 0.8);
}

.leaflet-tooltip-bottom:before {
    border-bottom-color: rgba(0, 0, 0, 0.8);
}

.leaflet-tooltip-left:before {
    border-left-color: rgba(0, 0, 0, 0.8);
}

.leaflet-tooltip-right:before {
    border-right-color: rgba(0, 0, 0, 0.8);
}

/* Pattern specific styles */
.pattern-overlap {
    /* These patterns will be set dynamically in JavaScript */
    background-repeat: repeat !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

.overlap-pattern {
    /* For the legend pattern square */
    background-repeat: repeat !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

/* Print styles */
@media print {
    body {
        background-color: white;
        padding: 0;
        margin: 0;
    }
    
    .container {
        box-shadow: none;
        padding: 0;
    }
    
    .map-container {
        border: none;
    }
    
    .map-controls, .btn, .notification {
        display: none !important;
    }
    
    .legend {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* Ensure Leaflet controls don't interfere */
.leaflet-top.leaflet-left {
    top: 80px;
    left: 10px;
}

.leaflet-top.leaflet-right {
    top: 280px;
    right: 10px;
}

/* Enhanced Vendor Selection Interface */
#vendor-checkbox-container {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

#vendor-checkbox-container::-webkit-scrollbar {
    width: 8px;
}

#vendor-checkbox-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#vendor-checkbox-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#vendor-checkbox-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Vendor tooltip enhancements for overlaps - Wider for table data including notes */
.vendor-tooltip {
    background: white !important;
    border: 1px solid #ccc !important;
    border-radius: 6px !important;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2) !important;
    font-family: Arial, sans-serif !important;
    max-width: 650px !important;
    padding: 0 !important;
    z-index: 1004 !important;
}

.vendor-tooltip .leaflet-tooltip-content {
    margin: 0 !important;
    padding: 0 !important;
}

/* New styles for vendor dot tooltips */
.vendor-dot-tooltip {
    background: white !important;
    border: 2px solid #333 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
    font-family: Arial, sans-serif !important;
    max-width: 200px !important;
    padding: 0 !important;
}

.vendor-dot-tooltip .leaflet-tooltip-content {
    margin: 0 !important;
    padding: 8px !important;
    line-height: 1.3 !important;
}

.vendor-dot-tooltip::before {
    border-color: transparent transparent #333 transparent !important;
}

/* Store location tooltip styles - Enhanced visibility */
.store-tooltip {
    background: white !important;
    border: 2px solid #2c3e50 !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.3) !important;
    font-family: Arial, sans-serif !important;
    max-width: 250px !important;
    padding: 0 !important;
    z-index: 1003 !important;
}

.store-tooltip .leaflet-tooltip-content {
    margin: 0 !important;
    padding: 0 !important;
    color: #333 !important;
    text-shadow: none !important;
}

.store-tooltip::before {
    border-color: transparent transparent #2c3e50 transparent !important;
}

/* Store marker styling */
.store-marker {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    z-index: 1002 !important;
}

.store-marker div {
    cursor: pointer !important;
    transition: transform 0.2s ease !important;
}

.store-marker div:hover {
    transform: scale(1.2) !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5) !important;
}

/* Ensure SVG patterns are visible and properly applied */
svg#vendor-pattern-svg {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 0 !important;
    height: 0 !important;
    z-index: -1 !important;
    pointer-events: none !important;
}

/* Force pattern visibility */
path[fill^="url(#pattern-"] {
    fill-opacity: 1 !important;
    stroke-opacity: 1 !important;
}

/* Vendor overlap visualization enhancements */
.leaflet-interactive[style*="url(#pattern-"] {
    fill-opacity: 0.8 !important;
    stroke-width: 2px !important;
    stroke: #333 !important;
}

/* Remove any dark text shadows or overlays */
.leaflet-popup-content,
.leaflet-popup-content *,
.leaflet-tooltip-content,
.leaflet-tooltip-content * {
    text-shadow: none !important;
    background-color: transparent !important;
}

/* Ensure vendor names are always readable */
.vendor-name {
    color: #333 !important;
    background: none !important;
    text-shadow: none !important;
}

/* Pattern debugging - ensure patterns render */
pattern rect {
    shape-rendering: crispEdges !important;
}

/* Force refresh of pattern definitions */
defs pattern {
    color-rendering: optimizeQuality !important;
}

/* Enhanced scrollbar for vendor lists */
.vendor-colors-list::-webkit-scrollbar {
    width: 6px !important;
}

.vendor-colors-list::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
    border-radius: 3px !important;
}

.vendor-colors-list::-webkit-scrollbar-thumb {
    background: #c1c1c1 !important;
    border-radius: 3px !important;
}

.vendor-colors-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8 !important;
}

/* Loading states for better UX */
.vendor-loading::after {
    content: "Loading vendors...";
    color: #999;
    font-style: italic;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #vendor-checkbox-container {
        border-width: 2px;
    }
    
    .vendor-checkbox {
        border-width: 2px !important;
    }
}

/* New styles for vendor square tooltips */
.vendor-square-tooltip {
    background: white !important;
    border: 2px solid #333 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
    font-family: Arial, sans-serif !important;
    max-width: 200px !important;
    padding: 0 !important;
}

.vendor-square-tooltip .leaflet-tooltip-content {
    margin: 0 !important;
    padding: 8px !important;
    line-height: 1.3 !important;
}

.vendor-square-tooltip::before {
    border-color: transparent transparent #333 transparent !important;
}

/* Vendor square marker styling */
.vendor-square-marker {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.vendor-square-marker div {
    cursor: pointer !important;
    transition: transform 0.2s ease !important;
}

.vendor-square-marker div:hover {
    transform: rotate(45deg) scale(1.2) !important;
} 