/**
 * Frontend CSS for GOR Custom Map Plugin
 * Styles for public-facing map display with mobile optimizations
 */

/* Map Container */
.gor-map-container {
    position: relative;
    width: 100%;
    margin: 20px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: #fff;
}

.gor-map-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.gor-map {
    width: 100%;
    height: 1000px;
    border-radius: 8px;
    z-index: 1;
}

/* Map Controls */
.gor-fullscreen-btn,
.gor-location-btn {
    position: absolute;
    top: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gor-fullscreen-btn:hover,
.gor-location-btn:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.gor-fullscreen-btn {
    right: 10px;
}

.gor-location-btn {
    right: 56px;
}

.gor-filter-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gor-filter-btn:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.gor-filter-btn svg {
    width: 16px;
    height: 16px;
    stroke: #333;
}

.gor-fullscreen-btn svg,
.gor-location-btn svg {
    width: 16px;
    height: 16px;
    stroke: #333;
}

/* Loading State */
.gor-map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    border-radius: 8px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

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

.gor-map-loading p {
    color: #666;
    font-size: 14px;
    margin: 0;
}

/* Filter Controls - Compact Design */
.gor-map-filters {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    z-index: 1000;
    max-width: 200px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.gor-map-filters.collapsed {
    width: 36px;
    height: 36px;
    padding: 6px;
    overflow: hidden;
}

.gor-map-filters.collapsed .filter-content {
    display: none;
}

.filter-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.filter-toggle:hover {
    background-color: #f0f0f0;
}

.filter-toggle svg {
    width: 16px;
    height: 16px;
    stroke: #333;
}

.filter-content {
    margin-top: 8px;
}

.filter-group {
    margin-bottom: 10px;
}

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

.filter-group h4 {
    margin: 0 0 6px 0;
    font-size: 11px;
    color: #333;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    cursor: pointer;
    font-size: 11px;
    color: #555;
    transition: color 0.2s ease;
}

.filter-checkbox:hover {
    color: #333;
}

.filter-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkmark {
    position: relative;
    height: 14px;
    width: 14px;
    background-color: #eee;
    border-radius: 2px;
    margin-right: 6px;
    transition: all 0.2s ease;
    border: 1px solid #ccc;
}

.filter-checkbox:hover .checkmark {
    background-color: #e0e0e0;
}

.filter-checkbox input:checked ~ .checkmark {
    background-color: #0073aa;
    border-color: #0073aa;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 3px;
    top: 1px;
    width: 3px;
    height: 6px;
    border: solid white;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

.filter-checkbox input:checked ~ .checkmark:after {
    display: block;
}

/* Search Input - Compact */
.gor-search-input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 11px;
    transition: border-color 0.2s ease;
}

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

/* Filter Actions - Compact */
.filter-actions {
    margin-top: 8px;
    display: flex;
    gap: 4px;
}

.gor-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: all 0.2s ease;
    min-width: 50px;
}

.gor-btn-primary {
    background: #0073aa;
    color: white;
}

.gor-btn-primary:hover {
    background: #005a87;
    transform: translateY(-1px);
}

.gor-btn-secondary {
    background: #6c757d;
    color: white;
}

.gor-btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* Route Badges */
.route-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    color: white;
    margin-right: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.route-4km { background-color: #2ecc71; }
.route-8-5km { background-color: #3498db; }
.route-13km { background-color: #9b59b6; }

/* Fullscreen Mode */
.gor-map-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
}

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

.gor-map-container.fullscreen .gor-map-filters {
    border-radius: 0;
}

/* User Location Indicator */
.user-location-circle {
    background: rgba(0, 115, 170, 0.2);
    border: 2px solid #0073aa;
    border-radius: 50%;
}

.user-location-marker {
    background: #0073aa;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Custom Marker Styles */
.custom-obstacle-icon {
    background: none !important;
    border: none !important;
}

.obstacle-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: white;
    font-weight: bold;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.obstacle-marker:hover {
    transform: scale(1.1);
}

.poi-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    padding: 4px;
    border: 1px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Map Popups */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.leaflet-popup-content h3 {
    margin: 0 0 8px 0;
    font-size: 15px;
    color: #333;
    font-weight: 600;
}

.leaflet-popup-content p {
    margin: 6px 0;
    color: #666;
}

.leaflet-popup-content .popup-meta {
    font-size: 11px;
    color: #999;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}

.popup-images {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    overflow-x: auto;
}

.popup-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.popup-image:hover {
    transform: scale(1.05);
}

/* Route Lines */
.leaflet-interactive {
    cursor: pointer;
}

/* Marker Clustering */
.marker-cluster-small {
    background-color: rgba(181, 226, 140, 0.8);
    border: 2px solid rgba(110, 204, 57, 0.8);
}

.marker-cluster-small div {
    background-color: rgba(110, 204, 57, 0.8);
    border-radius: 15px;
}

.marker-cluster-medium {
    background-color: rgba(241, 211, 87, 0.8);
    border: 2px solid rgba(240, 194, 12, 0.8);
}

.marker-cluster-medium div {
    background-color: rgba(240, 194, 12, 0.8);
    border-radius: 20px;
}

.marker-cluster-large {
    background-color: rgba(253, 156, 115, 0.8);
    border: 2px solid rgba(241, 128, 23, 0.8);
}

.marker-cluster-large div {
    background-color: rgba(241, 128, 23, 0.8);
    border-radius: 25px;
}

.marker-cluster div {
    width: 30px;
    height: 30px;
    margin-left: 5px;
    margin-top: 5px;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    color: white;
    line-height: 30px;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .gor-map-container {
        margin: 10px 0;
        border-radius: 6px;
    }
    
    .gor-map {
        height: 400px;
    }
    
    .gor-map-filters {
        max-width: 180px;
    }
    
    .gor-map-filters.collapsed {
        width: 42px;
        height: 42px;
    }
    
    .filter-toggle {
        width: 30px;
        height: 30px;
    }
    
    .filter-group h4 {
        font-size: 10px;
    }
    
    .filter-checkbox {
        font-size: 10px;
        margin-bottom: 3px;
    }
    
    .checkmark {
        height: 12px;
        width: 12px;
        margin-right: 5px;
    }
    
    .filter-actions {
        flex-direction: column;
    }
    
    .gor-btn {
        width: 100%;
        padding: 6px 8px;
        font-size: 9px;
    }
    
    .gor-fullscreen-btn,
    .gor-location-btn {
        width: 42px;
        height: 42px;
        top: 15px;
    }
    
    .gor-fullscreen-btn {
        right: 15px;
    }
    
    .gor-location-btn {
        right: 67px;
    }
    
    .gor-fullscreen-btn svg,
    .gor-location-btn svg {
        width: 18px;
        height: 18px;
    }
    
    /* Touch-friendly marker sizing */
    .obstacle-marker {
        min-width: 32px;
        min-height: 32px;
    }
    
    .poi-marker {
        min-width: 28px;
        min-height: 28px;
    }
    
    /* Improved popup sizing for mobile */
    .leaflet-popup-content {
        margin: 10px 12px;
        max-width: 250px;
    }
    
    .popup-images {
        gap: 4px;
    }
    
    .popup-image {
        width: 45px;
        height: 45px;
    }
}

@media (max-width: 480px) {
    .gor-map {
        height: 350px;
    }
    
    .gor-map-filters {
        padding: 10px 12px;
    }
    
    .filter-group {
        margin-bottom: 12px;
    }
    
    .gor-search-input {
        font-size: 14px; /* Prevent zoom on iOS */
    }
    
    .leaflet-popup-content {
        max-width: 200px;
    }
    
    /* Collapsible filters for very small screens */
    .gor-map-filters.collapsed {
        max-height: 60px;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .gor-map-filters.expanded {
        max-height: 500px;
        transition: max-height 0.3s ease;
    }
    
    .filter-toggle {
        display: block;
        width: 100%;
        background: none;
        border: none;
        padding: 8px 0;
        font-size: 13px;
        font-weight: 600;
        color: #333;
        cursor: pointer;
        text-align: left;
    }
}

/* High DPI / Retina Display Support */
@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi),
       (min-resolution: 2dppx) {
    .obstacle-marker,
    .poi-marker {
        border-width: 1px;
    }
    
    .gor-fullscreen-btn,
    .gor-location-btn {
        border-width: 0.5px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .gor-map-filters {
        background: #2c2c2c;
        border-bottom-color: #444;
        color: #e0e0e0;
    }
    
    .filter-group h4 {
        color: #f0f0f0;
    }
    
    .filter-checkbox {
        color: #d0d0d0;
    }
    
    .filter-checkbox:hover {
        color: #f0f0f0;
    }
    
    .checkmark {
        background-color: #444;
        border-color: #666;
    }
    
    .filter-checkbox:hover .checkmark {
        background-color: #555;
    }
    
    .gor-search-input {
        background: #444;
        border-color: #666;
        color: #e0e0e0;
    }
    
    .gor-search-input:focus {
        border-color: #0073aa;
    }
    
    .gor-fullscreen-btn,
    .gor-location-btn {
        background: rgba(44, 44, 44, 0.9);
        border-color: #666;
    }
    
    .gor-fullscreen-btn:hover,
    .gor-location-btn:hover {
        background: #2c2c2c;
    }
    
    .gor-fullscreen-btn svg,
    .gor-location-btn svg {
        stroke: #e0e0e0;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    .gor-fullscreen-btn,
    .gor-location-btn,
    .filter-checkbox,
    .checkmark,
    .gor-btn,
    .obstacle-marker,
    .popup-image {
        transition: none;
    }
    
    .loading-spinner {
        animation: none;
        border-top-color: #666;
    }
}

/* Focus States for Accessibility */
.gor-fullscreen-btn:focus,
.gor-location-btn:focus,
.gor-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.filter-checkbox input:focus + .checkmark {
    box-shadow: 0 0 0 2px #0073aa;
}

/* Print Styles */
@media print {
    .gor-map-filters,
    .gor-fullscreen-btn,
    .gor-location-btn,
    .gor-map-loading {
        display: none !important;
    }
    
    .gor-map-container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .gor-map {
        height: 400px !important;
    }
}