/* ABD Maps & Location Styles */

.abd-map-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.abd-business-map,
.abd-directory-map {
    width: 100%;
    min-height: 300px;
    border-radius: 12px;
}

/* Fix Leaflet overlapping icons and controls */
.leaflet-control-container .leaflet-top.leaflet-right {
    display: none !important; /* Hide default leaflet controls that overlap */
}

.leaflet-control-attribution {
    display: none !important; /* Hide attribution that might overlap */
}

.leaflet-control-zoom {
    margin: 8px !important; /* Better spacing for zoom control */
}

/* Beautiful small label-style map control buttons */
.abd-map-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 1000;
    display: flex;
    gap: 3px;
    opacity: 0.95;
}

.abd-map-style-btn {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #333;
    padding: 3px 6px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    min-width: 32px;
    text-align: center;
    line-height: 1.2;
}

.abd-map-style-btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.abd-map-style-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
    transform: translateY(-1px);
}

.abd-map-style-btn.active:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-1px);
}

/* Hide terrain button completely */
.abd-map-style-btn[data-style="terrain"] {
    display: none !important;
}

/* Ensure sidebar maps don't have overlapping elements */
.abd-sidebar-card .abd-map-container {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

.abd-sidebar-card .abd-business-map {
    border-radius: 8px;
    min-height: 250px;
}

.abd-sidebar-card .abd-map-controls {
    top: 6px;
    right: 6px;
}

.abd-sidebar-card .abd-map-style-btn {
    font-size: 9px;
    padding: 2px 5px;
    min-width: 28px;
}

/* Static Map */
.abd-static-map {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
}

.abd-static-map-notice {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px;
    margin: 0;
    font-size: 12px;
    text-align: center;
}

/* Custom marker styles */
.abd-enterprise-marker {
    background: transparent !important;
    border: none !important;
}

.abd-marker-container {
    position: relative;
    width: 50px;
    height: 50px;
}

.abd-base-marker {
    width: 40px;
    height: 40px;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.abd-logo-overlay {
    display: none;
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    background: white;
}

.abd-business-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Override any default Leaflet marker styles */
.leaflet-marker-icon.leaflet-zoom-animated.leaflet-interactive {
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
}

/* Directory Map */
.abd-directory-map-container {
    position: relative;
}

.abd-map-legend {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.abd-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.abd-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.abd-marker-enterprise {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 0 0 2px white, 0 0 0 3px #667eea;
}

.abd-marker-business {
    background: #28a745;
    box-shadow: 0 0 0 2px white, 0 0 0 3px #28a745;
}

.abd-marker-free {
    background: #6c757d;
    box-shadow: 0 0 0 2px white, 0 0 0 3px #6c757d;
}

/* Map Actions */
.abd-map-actions {
    margin-top: 15px;
    text-align: center;
}

.abd-directions-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.abd-directions-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    color: white;
    text-decoration: none;
}

.abd-directions-btn .dashicons {
    font-size: 16px;
}

/* Nearby Businesses */
.abd-nearby-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.abd-nearby-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.abd-nearby-item:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

.abd-nearby-info h4 {
    margin: 0 0 5px 0;
    font-size: 1.1em;
}

.abd-nearby-info h4 a {
    color: #2c3e50;
    text-decoration: none;
}

.abd-nearby-info h4 a:hover {
    color: #667eea;
}

.abd-nearby-distance {
    margin: 0;
    color: #666;
    font-size: 0.9em;
}

.abd-nearby-category {
    margin: 5px 0 0 0;
    color: #667eea;
    font-size: 0.85em;
    font-weight: 600;
}

.abd-nearby-btn {
    background: #667eea;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.abd-nearby-btn:hover {
    background: #5a6fd8;
    color: white;
    text-decoration: none;
}

/* Map Picker (for forms) */
.abd-map-picker {
    border: 2px dashed #ddd;
    border-radius: 8px;
    position: relative;
    cursor: crosshair;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #666;
}

.abd-map-picker.has-location {
    border-color: #28a745;
    border-style: solid;
}

.abd-map-picker::before {
    content: "📍 " attr(data-placeholder);
    position: absolute;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 15px;
    border-radius: 6px;
    pointer-events: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.abd-map-picker.has-location::before {
   content: "📍 Click to change location";
}

/* Loading States */
.abd-map-loading {
   display: flex;
   align-items: center;
   justify-content: center;
   background: #f8f9fa;
   color: #666;
   font-size: 14px;
}

.abd-map-loading::before {
   content: "";
   width: 20px;
   height: 20px;
   border: 2px solid #ddd;
   border-top-color: #667eea;
   border-radius: 50%;
   animation: spin 1s linear infinite;
   margin-right: 10px;
}

@keyframes spin {
   to { transform: rotate(360deg); }
}

/* Error States */
.abd-map-no-location,
.abd-map-no-businesses,
.abd-map-error {
   text-align: center;
   padding: 40px 20px;
   color: #666;
   background: #f8f9fa;
   border-radius: 8px;
   border: 1px solid #e9ecef;
}

.abd-map-error {
   color: #dc3545;
   background: #f8d7da;
   border-color: #f5c6cb;
}

/* Form Integration */
.abd-form-section {
   margin-bottom: 30px;
   padding: 25px;
   background: #f8f9fa;
   border-radius: 12px;
   border: 1px solid #e9ecef;
}

.abd-form-section-title {
   display: flex;
   align-items: center;
   gap: 10px;
   margin: 0 0 20px 0;
   font-size: 1.2em;
   font-weight: 700;
   color: #2c3e50;
}

.abd-form-section-title .dashicons {
   color: #667eea;
}

.abd-form-row {
   display: grid;
   grid-template-columns: 1fr 1fr;
   gap: 20px;
   margin-bottom: 20px;
}

.abd-form-group {
   display: flex;
   flex-direction: column;
}

.abd-form-group label {
   font-weight: 600;
   margin-bottom: 8px;
   color: #2c3e50;
}

.abd-form-group input[type="number"] {
   padding: 12px;
   border: 1px solid #ddd;
   border-radius: 6px;
   font-size: 14px;
   transition: border-color 0.3s ease;
}

.abd-form-group input[type="number"]:focus {
   border-color: #667eea;
   outline: none;
   box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.abd-form-help {
   font-size: 12px;
   color: #666;
   margin-top: 5px;
}

/* Admin Styles */
.abd-maps-admin {
   max-width: 800px;
}

.abd-maps-header {
   margin-bottom: 20px;
   padding-bottom: 15px;
   border-bottom: 1px solid #eee;
}

.abd-maps-header h4 {
   margin: 0 0 5px 0;
   color: #2c3e50;
}

.abd-preview-map {
   margin-top: 20px;
   padding-top: 20px;
   border-top: 1px solid #eee;
}

.abd-preview-map h4 {
   margin-bottom: 10px;
   color: #2c3e50;
}

/* Popup/Info Window Styles */
.abd-map-popup {
   background: white;
   border-radius: 8px;
   box-shadow: 0 4px 20px rgba(0,0,0,0.15);
   border: none;
   overflow: hidden;
   max-width: 250px;
}

.abd-popup-content {
   padding: 15px;
}

.abd-popup-title {
   font-weight: 700;
   margin: 0 0 8px 0;
   color: #2c3e50;
   font-size: 1.1em;
}

.abd-popup-address {
   color: #666;
   font-size: 0.9em;
   margin: 0 0 10px 0;
}

.abd-popup-actions {
   display: flex;
   gap: 8px;
}

.abd-popup-btn {
   padding: 6px 12px;
   border-radius: 4px;
   text-decoration: none;
   font-size: 0.85em;
   font-weight: 600;
   text-align: center;
   transition: all 0.3s ease;
}

.abd-popup-btn-primary {
   background: #667eea;
   color: white;
}

.abd-popup-btn-primary:hover {
   background: #5a6fd8;
   color: white;
   text-decoration: none;
}

.abd-popup-btn-secondary {
   background: #f8f9fa;
   color: #666;
   border: 1px solid #ddd;
}

.abd-popup-btn-secondary:hover {
   background: #e9ecef;
   color: #666;
   text-decoration: none;
}

/* Tier Badges */
.abd-tier-badge {
   display: inline-block;
   padding: 3px 8px;
   border-radius: 12px;
   font-size: 11px;
   font-weight: 600;
   text-transform: uppercase;
   letter-spacing: 0.5px;
}

.abd-tier-badge-free {
   background: #6c757d;
   color: white;
}

.abd-tier-badge-business {
   background: #28a745;
   color: white;
}

.abd-tier-badge-enterprise {
   background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
   color: white;
}

/* Clustering Styles */
.abd-cluster {
   background: rgba(102, 126, 234, 0.8);
   border: 3px solid white;
   border-radius: 50%;
   color: white;
   display: flex;
   align-items: center;
   justify-content: center;
   font-weight: 700;
   font-size: 12px;
   box-shadow: 0 2px 8px rgba(0,0,0,0.3);
   cursor: pointer;
   transition: all 0.3s ease;
}

.abd-cluster:hover {
   transform: scale(1.1);
   box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.abd-cluster-small {
   width: 30px;
   height: 30px;
}

.abd-cluster-medium {
   width: 40px;
   height: 40px;
}

.abd-cluster-large {
   width: 50px;
   height: 50px;
   font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
   .abd-form-row {
       grid-template-columns: 1fr;
       gap: 15px;
   }
   
   .abd-map-legend {
       flex-direction: column;
       gap: 10px;
   }
   
   .abd-nearby-item {
       flex-direction: column;
       align-items: flex-start;
       gap: 10px;
   }
   
   .abd-nearby-actions {
       align-self: stretch;
   }
   
   .abd-nearby-btn {
       display: block;
       text-align: center;
       width: 100%;
   }
   
   /* Smaller buttons on mobile */
   .abd-map-style-btn {
       font-size: 9px;
       padding: 2px 4px;
       min-width: 26px;
   }
   
   .abd-map-controls {
       top: 6px;
       right: 6px;
       gap: 2px;
   }
}

@media (max-width: 480px) {
   .abd-form-section {
       padding: 20px 15px;
   }
   
   .abd-map-picker {
       height: 200px;
   }
   
   .abd-popup-content {
       padding: 12px;
   }
   
   .abd-popup-actions {
       flex-direction: column;
   }
   
   .abd-popup-btn {
       text-align: center;
   }
   
   /* Even smaller buttons on small mobile */
   .abd-map-style-btn {
       font-size: 8px;
       padding: 2px 3px;
       min-width: 24px;
   }
}

/* Print Styles */
@media print {
   .abd-map-controls,
   .abd-map-actions,
   .abd-popup-actions {
       display: none;
   }
   
   .abd-business-map,
   .abd-directory-map {
       background: #f8f9fa;
       border: 1px solid #ddd;
   }
   
   .abd-business-map::after,
   .abd-directory-map::after {
       content: "Interactive map available online";
       display: flex;
       align-items: center;
       justify-content: center;
       color: #666;
       font-size: 14px;
   }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
   .abd-map-container {
       box-shadow: 0 4px 20px rgba(0,0,0,0.3);
   }
   
   .abd-map-style-btn {
       background: rgba(30, 30, 30, 0.95);
       border-color: rgba(255, 255, 255, 0.2);
       color: #ddd;
   }
   
   .abd-map-style-btn:hover {
       background: rgba(45, 45, 45, 1);
       border-color: #667eea;
       color: #667eea;
   }
   
   .abd-map-style-btn.active {
       background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
       color: white;
   }
   
   .abd-popup-content {
       background: #2c3e50;
       color: #ecf0f1;
   }
   
   .abd-popup-title {
       color: #ecf0f1;
   }
   
   .abd-map-legend {
       background: #2c3e50;
       border-color: #34495e;
       color: #ecf0f1;
   }
   
   .abd-nearby-item {
       background: #2c3e50;
       border-color: #34495e;
       color: #ecf0f1;
   }
   
   .abd-nearby-item:hover {
       background: #34495e;
   }
}

/* Animation Classes */
.abd-fade-in {
   animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
   from { opacity: 0; transform: translateY(10px); }
   to { opacity: 1; transform: translateY(0); }
}

.abd-slide-in {
   animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
   from { transform: translateX(-20px); opacity: 0; }
   to { transform: translateX(0); opacity: 1; }
}

/* Accessibility */
.abd-map-container:focus-within {
   outline: 2px solid #667eea;
   outline-offset: 2px;
}

.abd-map-style-btn:focus,
.abd-directions-btn:focus,
.abd-nearby-btn:focus {
   outline: 2px solid #667eea;
   outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
   .abd-marker-enterprise {
       background: #000;
       box-shadow: 0 0 0 2px #fff, 0 0 0 4px #000;
   }
   
   .abd-marker-business {
       background: #0066cc;
       box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0066cc;
   }
   
   .abd-marker-free {
       background: #666;
       box-shadow: 0 0 0 2px #fff, 0 0 0 4px #666;
   }
   
   .abd-map-style-btn {
       border-width: 2px;
   }
}

/* Leaflet-specific styles */
.abd-leaflet-marker {
    background: transparent !important;
    border: none !important;
}

.abd-leaflet-logo-marker {
    background: transparent !important;
    border: none !important;
}

.abd-leaflet-popup {
    font-family: inherit;
}

.abd-leaflet-popup h4 {
    font-size: 1.1em;
    margin: 0 0 8px 0;
    color: #2c3e50;
}

.abd-leaflet-cluster {
    background: rgba(102, 126, 234, 0.8);
    border: 3px solid white;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.abd-leaflet-cluster:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.abd-leaflet-cluster-icon {
    background: transparent !important;
    border: none !important;
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.leaflet-popup-content {
    margin: 15px;
    line-height: 1.4;
}

.leaflet-popup-tip {
    background: white;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Override Leaflet attribution for better integration */
.leaflet-control-attribution {
    display: none !important; /* Always hide attribution */
}

/* Responsive adjustments for Leaflet */
@media (max-width: 768px) {
    .leaflet-control-zoom {
        margin-left: 5px;
        margin-top: 5px;
    }
}

/* Dark mode support for Leaflet */
@media (prefers-color-scheme: dark) {
    .leaflet-popup-content-wrapper {
        background: #2c3e50;
        color: #ecf0f1;
    }
    
    .leaflet-popup-tip {
        background: #2c3e50;
    }
}

/* Additional fixes for overlapping elements */
.leaflet-control-container {
    pointer-events: none;
}

.leaflet-control-container .leaflet-control {
    pointer-events: auto;
}

.leaflet-control-container .leaflet-top.leaflet-left {
    top: 8px;
    left: 8px;
}

.leaflet-control-zoom a {
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #333;
}

.leaflet-control-zoom a:hover {
    background-color: #fff;
    border-color: #667eea;
    color: #667eea;
}

/* Ensure buttons appear correctly on all devices */
.abd-map-style-btn {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    outline: none;
}

.abd-map-style-btn:active {
    transform: translateY(0);
}