/**
 * Club Map Styles
 * 
 * @package JP_Google_Sheet_API
 * @subpackage Clubs_Map
 */

/* Enhanced map tiles - Reduce brightness for OpenStreetMap, less labels on zoom */
.map-tiles-enhanced {
    filter: contrast(1.05) saturate(1.1) brightness(0.92);
}

/* Back to Home Button - TOP RIGHT */
.jp-map-back-home {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    z-index: 10000 !important;
    background: white !important;
    color: #333 !important;
    padding: 10px 16px !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    text-decoration: none !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
}

.jp-map-back-home:hover {
    background: #f0f0f0;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
    transform: translateY(-1px);
    color: #000;
}

.jp-map-back-home svg {
    width: 20px;
    height: 20px;
    color: #d4af37;
}

.jp-map-back-home span {
    color: inherit;
}

/* Mobile: Smaller button */
@media (max-width: 768px) {
    .jp-map-back-home {
        margin: 4px 5px 0px 0px;!important;
        right: 10px !important;
        padding: 10px !important;
        font-size: 12px !important;
        gap: 0 !important;
        min-width: 40px !important;
        min-height: 40px !important;
        justify-content: center !important;
    }
    
    .jp-map-back-home svg {
        width: 20px !important;
        height: 20px !important;
        margin: 0 !important;
    }
    
    .jp-map-back-home span {
        display: none !important; /* Hide text on mobile, show only icon */
    }
}

/* Map Container */
.jp-clubs-map-container {
    position: relative;
    width: 100%;
    margin: 0;
    height: 100vh;
}

/* Full height for map wrapper */
.jp-clubs-map-container .jp-map-wrapper {
    height: 100% !important;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Adjust for WordPress admin bar */
.admin-bar .jp-clubs-map-container {
    height: calc(100vh - 32px);
    margin-top: 32px;
}

@media (max-width: 782px) {
    .admin-bar .jp-clubs-map-container {
        height: calc(100vh - 46px);
        margin-top: 46px;
    }
}

/* VBM Search Box - TOP LEFT */
.jp-map-search-container {
    position: absolute !important;
    top: 10px !important;
    left: 10px !important; /* Force left alignment */
    transform: none !important; /* Remove any transform */
    z-index: 1000 !important;
    width: 90% !important;
    max-width: 400px !important;
}

.jp-map-search-box-google {
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    background: #ffffff !important;
    border: none !important;
    border-radius: 2px !important; /* Squared design like VBM */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 0 16px !important;
    margin: 0 !important;
    transition: box-shadow 0.2s ease;
    box-sizing: border-box !important;
    vertical-align: middle !important;
}

.jp-map-search-box-google:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

.jp-map-search-box-google:focus-within {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5) !important;
    border: none !important;
    outline: none !important;
}

.jp-map-search-icon {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    flex-shrink: 0 !important;
    margin-right: 12px !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: default !important;
    align-self: center !important;
}

.jp-map-search-icon svg {
    width: 20px !important;
    height: 20px !important;
    fill: #666 !important;
    vertical-align: middle !important;
    display: block !important;
}

.jp-map-search-input-google {
    flex: 1 !important;
    border: none !important;
    outline: none !important;
    font-size: 16px !important;
    line-height: 48px !important;
    color: #333 !important;
    background: transparent !important;
    font-family: 'Roboto', Arial, sans-serif !important;
    padding: 0 !important;
    margin: 0 !important;
    height: 48px !important;
    align-self: center !important;
    vertical-align: middle !important;
}

.jp-map-search-input-google::placeholder {
    color: #999 !important;
}

.jp-map-search-input-google:focus {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

.jp-map-search-clear {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    border: none !important;
    background: transparent !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    align-self: center !important;
    border-radius: 50% !important;
    transition: background 0.2s ease;
    flex-shrink: 0 !important;
}

.jp-map-search-clear:hover {
    background: #f0f0f0 !important;
}

.jp-map-search-clear.active {
    display: flex !important;
}

.jp-map-search-clear svg {
    width: 16px !important;
    height: 16px !important;
    fill: #666 !important;
    vertical-align: middle !important;
    display: block !important;
}

/* Map Controls - VBM Design */
.jp-map-controls-google {
    position: absolute;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Bottom right - stack all controls vertically */
.jp-map-controls-bottom {
    bottom: 20px;
    right: 10px;
}

/* Separator between control groups - HIDDEN */
.jp-map-controls-separator {
    display: none; /* Hidden pe:hoverr user request */
}

/* Button Base Style - VBM Design (LARGE) */
.jp-map-control-btn {
    width: 45px;
    height: 45px;
    background: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    position: relative;
    overflow: visible;
}

.jp-map-control-btn:hover {
    background: #f5f5f5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.jp-map-control-btn:active {
    background: #e8e8e8;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transform: scale(0.98);
}

/* Ripple Effect */
.jp-map-control-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.jp-map-control-btn:active::before {
    width: 100%;
    height: 100%;
}

/* SVG Icons - Optimal size (reduced 45% total) */
.jp-map-control-btn svg {
    width: 21px !important;
    height: 21px !important;
    min-width: 21px !important;
    min-height: 21px !important;
    max-width: 21px !important;
    max-height: 21px !important;
    fill: #666 !important;
    position: relative;
    z-index: 1;
    pointer-events: none;
}

.jp-map-control-btn:hover svg {
    fill: #333 !important;
}

/* Tooltip - DISABLED (per user request) */
.jp-map-control-btn[title]::after {
    display: none !important; /* Hide tooltip completely */
}

.jp-map-control-btn:hover::after {
    display: none !important; /* Hide tooltip on hover */
}

/* Loading State */
.jp-map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1001;
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.jp-map-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 215, 0, 0.3);
    border-top-color: #FFD700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

/* Map Wrapper */
.jp-map-wrapper {
    position: relative;
    width: 100%;
    background: #f0f0f0;
    overflow: hidden;
}

.jp-leaflet-map {
    width: 100%;
    height: 100%;
}

/* Hide Leaflet default controls (we use custom controls) */
.jp-leaflet-map .leaflet-control-zoom,
.jp-leaflet-map .leaflet-control-attribution {
    display: none !important;
}

/* Fullscreen mode */
.jp-clubs-map-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    z-index: 99999 !important;
    margin: 0 !important;
}

.jp-clubs-map-fullscreen .jp-map-wrapper {
    height: 100vh !important;
}

/* Fullscreen mode body styles */
body.map-fullscreen-active {
    overflow: hidden !important;
}

/* Ensure map controls are visible in fullscreen */
.jp-clubs-map-fullscreen .jp-map-search-container,
.jp-clubs-map-fullscreen .jp-map-controls-bottom {
    z-index: 100000;
}

/* Custom Markers */
.jp-map-marker {
    background: none !important;
    border: none !important;
}

.jp-map-marker-icon {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: white;
    border: 0.5px solid rgb(216, 216, 216);
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
    position: relative;
}

.jp-map-marker-icon.nationwide {
    border-color: #FF6B6B;
    box-shadow: 0 3px 10px rgba(255, 107, 107, 0.4);
}

.jp-map-marker-icon.nationwide::after {
    content: '🌟';
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 12px;
}

/* Default runner logo styling */
.jp-map-marker-icon img[src^="data:image/svg+xml"] {
    filter: drop-shadow(0 1px 2px rgba(255, 165, 0, 0.2));
    transform: scale(1.1);
}

.jp-map-marker-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.jp-map-marker-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    font-weight: bold;
    font-size: 18px;
}

/* Cluster Icons */
.jp-map-cluster {
    background: none !important;
}

.jp-map-cluster-icon {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border-radius: 50%;
    color: white;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(255, 215, 0, 0.4);
}

.jp-map-cluster-icon.small {
    width: 35px;
    height: 35px;
    font-size: 12px;
}

.jp-map-cluster-icon.medium {
    width: 45px;
    height: 45px;
    font-size: 14px;
}

.jp-map-cluster-icon.large {
    width: 55px;
    height: 55px;
    font-size: 16px;
}

/* Popup Styles */
.jp-map-popup-wrapper {
    border-radius: 10px !important;
    overflow: hidden;
}

.jp-map-popup {
    padding: 0;
    min-width: 250px;
}

.jp-map-popup-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
}

.jp-map-popup-logo {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
}

.jp-map-popup-title h4 {
    margin: 0;
    color: white;
    font-size: 16px;
    font-weight: 700;
}

.jp-map-popup-stars {
    color: white;
    font-size: 14px;
    margin-top: 3px;
}

.jp-map-popup-content {
    padding: 15px;
    background: white;
}

.jp-map-popup-location {
    margin: 0 0 15px 0;
    color: #666;
    font-size: 13px;
}

.jp-map-popup-actions {
    display: flex;
    gap: 10px;
}

.jp-map-popup-detail-btn,
.jp-map-popup-link-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

.jp-map-popup-detail-btn {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    border: none;
}

.jp-map-popup-detail-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(255, 215, 0, 0.4);
}

.jp-map-popup-link-btn {
    background: white;
    color: #FFD700;
    border: 2px solid #FFD700;
    display: inline-block;
}

.jp-map-popup-link-btn:hover {
    background: #FFD700;
    color: white;
}

/* Sidebar */
.jp-map-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: 350px;
    height: 100%;
    background: white;
    box-shadow: -3px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1002;
    display: flex;
    flex-direction: column;
}

.jp-map-sidebar-header {
    padding: 15px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.jp-map-sidebar-header h3 {
    margin: 0;
    font-size: 18px;
}

.jp-map-sidebar-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.jp-map-sidebar-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.jp-map-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.jp-map-club-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.jp-map-club-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.jp-map-club-list-item:hover {
    background: #FFD700;
    transform: translateX(-5px);
}

.jp-map-club-list-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #FFD700;
}

.jp-map-club-list-info h5 {
    margin: 0 0 3px 0;
    font-size: 14px;
    font-weight: 600;
}

.jp-map-club-list-info p {
    margin: 0;
    font-size: 12px;
    color: #666;
}

/* Legend removed - not needed */

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Full height on mobile */
    .jp-clubs-map-container {
        height: 100vh !important;
        height: -webkit-fill-available !important; /* iOS Safari fix */
    }
    
    .jp-map-search-container {
        width: calc(100% - 20px) !important;
        left: 10px !important;
        transform: none !important;
        max-width: none !important; /* Full width on mobile */
    }
    
    .jp-map-search-box-google {
        height: 44px;
    }
    
    .jp-map-search-input-google {
        font-size: 14px;
    }
    
    /* All controls in bottom right - smaller and closer to edge on mobile */
    .jp-map-controls-bottom {
        bottom: 15px;
        right: 5px; /* Sát lề hơn */
        gap: 6px;
    }
    
    .jp-map-control-btn {
        width: 38px !important; /* Giảm 10% từ 42px */
        height: 38px !important;
    }
    
    .jp-map-control-btn svg {
        width: 18px !important; /* Giảm 10% từ 20px */
        height: 18px !important;
        min-width: 18px !important;
        min-height: 18px !important;
        max-width: 18px !important;
        max-height: 18px !important;
    }
    
    .jp-map-controls-separator {
        margin: 2px 0;
    }
    
    /* Hide tooltip on mobile - use native title instead */
    .jp-map-control-btn[title]::after {
        display: none;
    }
    
    .jp-map-sidebar {
        width: 100%;
        height: 50%;
        top: auto;
        bottom: 0;
    }
    
    .jp-map-popup {
        min-width: 200px;
    }
    
    .jp-map-popup-actions {
        flex-direction: column;
    }
}

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

.leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: 10px;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0;
    padding: 0;
}

.leaflet-popup-tip {
    background: white;
}

/* Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Apply spin animation */
.jp-map-control-btn svg[style*="spin"] {
    animation: spin 0.5s linear;
}

/* Locate button loading state */
.jp-map-locate.jp-map-locating {
    background: #E8F0FE !important;
}

.jp-map-locate.jp-map-locating svg {
    animation: pulse 1s infinite;
    fill: #4285F4 !important;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

/* User location marker */
.jp-map-user-marker-wrapper {
    background: none !important;
    border: none !important;
}

.jp-map-user-marker {
    font-size: 30px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    animation: bounce 0.5s;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Fullscreen button style */
.leaflet-control-fullscreen a {
    background: white;
    border: 2px solid #FFD700;
    border-radius: 4px;
}

.leaflet-control-fullscreen a:hover {
    background: #FFD700;
}

/* ==========================================
   LOADING OVERLAYS
   ========================================== */

/* Leaflet Map Loading (reuse existing .jp-map-loading) */
.jp-map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.jp-map-loading .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    animation: spin-loading 1s linear infinite;
    margin: 0 auto 15px;
}

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

.jp-map-loading p {
    margin: 10px 0 0;
    color: #333;
    font-size: 14px;
    font-weight: 500;
}

/* Google Maps Loading Overlay */
.jp-gmap-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.jp-gmap-loading-content {
    text-align: center;
    padding: 30px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.jp-gmap-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    animation: spin-loading 1s linear infinite;
    margin: 0 auto 15px;
}

.jp-gmap-loading-content p {
    margin: 10px 0 0;
    color: #333;
    font-size: 14px;
    font-weight: 500;
}

.jp-gmap-loading-detail {
    font-size: 12px !important;
    color: #666 !important;
    font-weight: 400 !important;
    margin-top: 5px !important;
}
