/**
 * Museum Map Styles
 * 
 * CSS styles for the interactive museum map interface
 * Includes responsive design and brand color integration
 * 
 * @package AutomuseumsCore
 * @version 1.0.0
 * @author  Synergy Marketing info@synergymarketing.mk
 */

/* Museum Map Wrapper - Controls layout ordering */
.museum-map-wrapper {
    display: block;
    width: 100%;
}

/* Map Container Styles */
.museum-map-container {
    position: relative;
    width: 100%;
    height: 500px;
    min-height: 400px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #f9f9f9;
}

.museum-map-container.fullscreen {
    height: 100vh;
    border-radius: 0;
}

/* Map Loading Indicator */
.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: none;
}

.map-loading::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #0073aa;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

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

/* Map Error Styles */
.map-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #f9f9f9;
    color: #666;
    text-align: center;
    padding: 20px;
}

.map-error p {
    margin: 0;
    font-size: 16px;
}

/* Museum Popup Styles */
.museum-popup {
    max-width: 300px;
    padding: 0;
    font-family: inherit;
}

.museum-popup-title {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.museum-popup-title a {
    color: #0073aa;
    text-decoration: none;
}

.museum-popup-title a:hover {
    color: #005177;
    text-decoration: underline;
}

.museum-popup-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 10px;
}

.museum-popup-address {
    margin: 0 0 8px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.4;
}

.museum-popup-categories {
    margin: 0 0 12px 0;
    color: #666;
    font-size: 13px;
    font-style: italic;
}

.museum-popup-actions {
    text-align: center;
    margin-top: 10px;
}

.museum-popup-actions .button-primary {
    background: #0073aa;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 3px;
    font-size: 13px;
    display: inline-block;
    transition: background-color 0.3s ease;
}

.museum-popup-actions .button-primary:hover {
    background: #005177;
}

/* Leaflet Customizations */
.leaflet-container {
    font-family: inherit;
}

/* Custom marker cluster styling */
.marker-cluster {
    background-color: rgba(0, 115, 170, 0.8);
    border: 2px solid rgba(0, 115, 170, 1);
}

.marker-cluster div {
    background-color: rgba(0, 115, 170, 0.9);
    color: white;
    font-weight: bold;
    text-align: center;
    border-radius: 50%;
}

.marker-cluster-small {
    width: 40px;
    height: 40px;
}

.marker-cluster-small div {
    width: 30px;
    height: 30px;
    margin: 5px;
    line-height: 30px;
    font-size: 12px;
}

.marker-cluster-medium {
    width: 50px;
    height: 50px;
}

.marker-cluster-medium div {
    width: 40px;
    height: 40px;
    margin: 5px;
    line-height: 40px;
    font-size: 14px;
}

.marker-cluster-large {
    width: 60px;
    height: 60px;
}

.marker-cluster-large div {
    width: 50px;
    height: 50px;
    margin: 5px;
    line-height: 50px;
    font-size: 16px;
}

/* Museum Search Interface Styles */
.museum-search-interface {
    position: relative;
    z-index: 1100;
    margin-bottom: 15px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
}

.museum-search-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.museum-search-input {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
}

.museum-search-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
    outline: none;
}

.museum-search-button,
.museum-search-clear {
    padding: 8px 16px;
    border: 1px solid #0073aa;
    background: #0073aa;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
    text-decoration: none;
    transition: all 0.2s ease;
}

.museum-search-clear {
    background: #666;
    border-color: #666;
}

.museum-search-button:hover,
.museum-search-button:focus {
    background: #005177;
    border-color: #005177;
}

.museum-search-clear:hover,
.museum-search-clear:focus {
    background: #444;
    border-color: #444;
}

.museum-search-button:disabled {
    background: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
}

/* Search Results Display */
.museum-search-results {
    margin-top: 10px;
}

.search-message {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
}

.search-message.search-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.search-message.search-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.search-message.search-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Autocomplete Suggestions */
.autocomplete-suggestions {
    position: absolute;
    z-index: 1000;
    background: #fff;
    border: 1px solid #ccd0d4;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    left: 0;
    right: 0;
}

.autocomplete-suggestion {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f1;
    font-size: 14px;
    line-height: 1.4;
}

.autocomplete-suggestion:hover {
    background: #f6f7f7;
}

.autocomplete-suggestion:last-child {
    border-bottom: none;
}

.suggestion-type {
    float: right;
    color: #666;
    font-size: 12px;
    font-style: italic;
}

/* Search Result Markers */
.search-result-marker.highlighted {
    filter: hue-rotate(45deg) brightness(1.2);
    transform: scale(1.1);
    transition: all 0.3s ease;
}

/* Red Search Result Marker Styling */
.search-result-marker-icon {
    filter: drop-shadow(0 2px 4px rgba(214, 54, 56, 0.3));
    transition: all 0.3s ease;
}

.search-result-marker-icon:hover {
    filter: drop-shadow(0 4px 8px rgba(214, 54, 56, 0.5));
    transform: scale(1.05);
}

/* Exact Match Marker with Pulsing Animation */
.exact-match-marker-icon,
.pulsing-exact-match {
    animation: pulseRed 2s infinite;
    filter: drop-shadow(0 3px 6px rgba(214, 54, 56, 0.6));
}

@keyframes pulseRed {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 3px 6px rgba(214, 54, 56, 0.6));
    }
    50% {
        transform: scale(1.1);
        filter: drop-shadow(0 5px 10px rgba(214, 54, 56, 0.8)) brightness(1.2);
    }
    100% {
        transform: scale(1);
        filter: drop-shadow(0 3px 6px rgba(214, 54, 56, 0.6));
    }
}

/* Search Result Popup Styling */
.search-result-popup .search-result-indicator {
    margin-right: 5px;
    font-size: 16px;
}

.search-result-title {
    color: #d63638 !important;
}

/* Exact Match Popup Styling */
.exact-match-popup {
    border: 2px solid #d63638;
    background: #fffef7;
}

.exact-match-popup .museum-popup-title {
    background: linear-gradient(45deg, #d63638, #ff4444);
    color: white !important;
    padding: 8px 12px;
    margin: -12px -12px 12px -12px;
    border-radius: 4px 4px 0 0;
}

.exact-match-popup .museum-popup-title a {
    color: white !important;
}

.exact-match-indicator {
    margin-right: 5px;
    font-size: 18px;
    animation: sparkle 1.5s infinite;
}

.exact-match-label {
    font-size: 10px;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 10px;
    margin-right: 5px;
    text-shadow: none;
}

.match-reason {
    background: #e8f5e8;
    color: #2d5a2d;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    margin: 8px 0;
    border-left: 3px solid #d63638;
}

@keyframes sparkle {
    0%, 100% { 
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    25% { 
        transform: scale(1.2) rotate(90deg);
        opacity: 0.8;
    }
    50% { 
        transform: scale(1) rotate(180deg);
        opacity: 1;
    }
    75% { 
        transform: scale(1.2) rotate(270deg);
        opacity: 0.8;
    }
}

/* Enhanced Search Result Visibility */
.search-result-marker-icon,
.exact-match-marker-icon {
    z-index: 1000 !important;
    position: relative;
}

/* Ensure search results are above regular markers */
.leaflet-marker-pane .search-result-marker-icon,
.leaflet-marker-pane .exact-match-marker-icon {
    z-index: 1000 !important;
}

/* CSS Fallback for when custom icons don't load */
.leaflet-marker-icon.red-marker-fallback {
    filter: hue-rotate(220deg) saturate(2) brightness(0.8) !important;
    border: 3px solid #d63638 !important;
    border-radius: 50% 50% 50% 0 !important;
    transform: rotate(-45deg) scale(1.2) !important;
    box-shadow: 0 3px 6px rgba(214, 54, 56, 0.4) !important;
    animation: redMarkerPulse 2s infinite !important;
}

.leaflet-marker-icon.exact-match-marker.red-marker-fallback {
    transform: rotate(-45deg) scale(1.4) !important;
    animation: redMarkerPulse 1s infinite, exactMatchBounce 3s infinite !important;
    border-width: 4px !important;
}

@keyframes redMarkerPulse {
    0%, 100% { 
        box-shadow: 0 3px 6px rgba(214, 54, 56, 0.4);
        transform: rotate(-45deg) scale(1.2);
    }
    50% { 
        box-shadow: 0 5px 10px rgba(214, 54, 56, 0.8);
        transform: rotate(-45deg) scale(1.3);
    }
}

@keyframes exactMatchBounce {
    0%, 100% { 
        transform: rotate(-45deg) scale(1.4) translateY(0);
    }
    50% { 
        transform: rotate(-45deg) scale(1.5) translateY(-5px);
    }
}

/* Loading States */
.museum-map-container.searching {
    opacity: 0.8;
}

.museum-map-container.searching::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 999;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .museum-search-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .museum-search-input {
        min-width: auto;
        width: 100%;
    }
    
    .museum-search-button,
    .museum-search-clear {
        width: 100%;
        justify-content: center;
    }
    
    .autocomplete-suggestions {
        position: fixed;
        left: 10px;
        right: 10px;
        max-height: 150px;
    }
}

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

.leaflet-popup-content {
    margin: 12px;
    line-height: 1.4;
}

/* Responsive Design */
@media (max-width: 768px) {
    .museum-map-container {
        height: 400px;
        min-height: 300px;
    }
    
    .museum-popup {
        max-width: 250px;
    }
    
    .museum-popup-image {
        height: 120px;
    }
    
    .museum-popup-title {
        font-size: 15px;
    }
    
    /* Ensure map controls are touch-friendly */
    .leaflet-control-zoom a {
        width: 36px;
        height: 36px;
        line-height: 36px;
        font-size: 18px;
    }
    
    .leaflet-control-attribution {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .museum-map-container {
        height: 350px;
        min-height: 250px;
    }
    
    .museum-popup {
        max-width: 200px;
    }
    
    .museum-popup-image {
        height: 100px;
    }
    
    .map-loading {
        padding: 15px;
        font-size: 14px;
    }
}

/* Museum Filters Interface Styles */
.museum-filters-container {
    position: relative;
    z-index: 1100;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.filters-header {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filters-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.clear-filters-button {
    background: #dc3545;
    color: white;
    border: 1px solid #dc3545;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-filters-button:hover {
    background: #c82333;
    border-color: #c82333;
}

/* Filter Sections */
.filter-sections {
    padding: 0;
}

.filter-section {
    border-bottom: 1px solid #e9ecef;
    padding: 20px;
}

.filter-section:last-child {
    border-bottom: none;
}

.filter-section h5 {
    margin: 0 0 15px 0;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Distance Filter Styles */
.distance-section {
    background: #f8f9ff;
}

.location-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.location-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out;
}

.location-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.25);
    outline: none;
}

.location-input.required-input {
    border-color: #dc3545;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25);
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

.use-location-button {
    background: #28a745;
    color: white;
    border: 1px solid #28a745;
    border-radius: 4px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.use-location-button:hover {
    background: #218838;
    border-color: #218838;
    transform: scale(1.05);
}

.radius-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.radius-selector label {
    font-weight: 500;
    color: #495057;
    white-space: nowrap;
}

.radius-select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.radius-select:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.25);
    outline: none;
}

/* Taxonomy Filter Styles */
.taxonomy-section {
    background: #fff8f5;
}

.taxonomy-group {
    margin-bottom: 15px;
}

.taxonomy-group:last-child {
    margin-bottom: 0;
}

.taxonomy-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
    font-size: 13px;
}

.taxonomy-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    transition: border-color 0.15s ease-in-out;
}

.taxonomy-select:focus {
    border-color: #fd7e14;
    box-shadow: 0 0 0 2px rgba(253, 126, 20, 0.25);
    outline: none;
}

/* Map Filter Styles */
.map-section {
    background: #f0f8f0;
}

.enable-map-selection,
.disable-map-selection {
    background: #17a2b8;
    color: white;
    border: 1px solid #17a2b8;
    border-radius: 4px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    width: 100%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.enable-map-selection:hover,
.disable-map-selection:hover {
    background: #138496;
    border-color: #138496;
}

.map-selection-info {
    text-align: center;
    color: #495057;
    font-size: 14px;
    line-height: 1.5;
}

.map-selection-info p {
    margin: 10px 0;
}

.disable-map-selection {
    background: #6c757d;
    border-color: #6c757d;
    font-size: 13px;
    padding: 8px 12px;
    margin-top: 10px;
}

.disable-map-selection:hover {
    background: #545b62;
    border-color: #545b62;
}

/* Active Filters Display */
.active-filters-section {
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 15px 20px;
}

.active-filters-display {
    margin-bottom: 10px;
}

.active-filters-label {
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.active-filter-tag {
    display: inline-block;
    background: #0073aa;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    margin-right: 6px;
    margin-bottom: 4px;
    font-weight: 500;
}

.filter-results-count {
    text-align: center;
    font-size: 14px;
    color: #495057;
    font-weight: 500;
}

.results-count {
    color: #28a745;
}

.filtering-indicator {
    color: #ffc107;
}

.filter-error {
    color: #dc3545;
}

/* Filtered Museum Markers */
.filtered-museum-marker {
    filter: hue-rotate(120deg) saturate(1.5) brightness(1.1);
    z-index: 800;
}

.filtered-popup {
    border: 2px solid #28a745;
}

.filtered-popup .museum-popup-title {
    color: #28a745 !important;
}

.filter-indicator {
    color: #28a745;
    margin-right: 5px;
    font-size: 16px;
}

/* Loading State for Filtering */
.museum-map-container.filtering {
    opacity: 0.7;
    pointer-events: none;
}

.museum-map-container.filtering::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1001;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 50%;
}

/* Mobile Responsive for Filters */
@media (max-width: 768px) {
    .filters-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
        text-align: center;
    }
    
    .clear-filters-button {
        width: 100%;
    }
    
    .filter-section {
        padding: 15px;
    }
    
    .location-input-group {
        flex-direction: column;
    }
    
    .use-location-button {
        order: -1;
        padding: 12px;
        font-size: 14px;
    }
    
    .radius-selector {
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
    }
    
    .radius-selector label {
        font-size: 14px;
    }
    
    .active-filters-section {
        padding: 12px 15px;
    }
    
    .active-filter-tag {
        display: block;
        text-align: center;
        margin: 0 0 8px 0;
        padding: 8px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .filter-section h5 {
        font-size: 13px;
    }
    
    .location-input,
    .radius-select,
    .taxonomy-select {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px;
    }
    
    .enable-map-selection,
    .disable-map-selection {
        padding: 12px 16px;
        font-size: 13px;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .museum-filters-container {
        border: 2px solid #000;
    }
    
    .filter-section {
        border-bottom: 2px solid #000;
    }
    
    .active-filter-tag {
        background: #000;
        color: #fff;
        border: 1px solid #fff;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .location-input.required-input {
        animation: none;
        border-color: #dc3545;
    }
    
    .use-location-button:hover {
        transform: none;
    }
    
    .museum-map-container.filtering::after {
        animation: none;
    }
}

/* Print Styles */
@media print {
    .museum-map-container {
        height: 400px;
        border: 1px solid #000;
    }
    
    .leaflet-control-container {
        display: none;
    }
    
    .museum-filters-container {
        display: none;
    }
}