/**
 * Play Page Styles
 */

/* Remove default page padding/margins */
body.page-template-template-play {
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Only hide horizontal scroll, allow header to show */
}

/* Map container starts below header */
#play-map-container {
    position: fixed;
    top: 70px; /* Space for header */
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: calc(100vh - 70px);
    z-index: 1; /* Lower than header so header stays on top */
}

/* Account for both admin bar and header */
body.page-template-template-play.admin-bar #play-map-container {
    top: 102px; /* 70px header + 32px admin bar */
    height: calc(100vh - 102px);
}

@media screen and (max-width: 782px) {
    /* Adjust for actual mobile header height */
    #play-map-container {
        top: 60px; /* Mobile header is shorter */
        height: calc(100vh - 60px);
    }

    body.page-template-template-play.admin-bar #play-map-container {
        top: 106px; /* 60px header + 46px mobile admin bar */
        height: calc(100vh - 106px);
    }
}

/* Map fills container */
#play-map {
    width: 100%;
    height: 100%;
}

/* Mapbox canvas */
#play-map .mapboxgl-canvas {
    outline: none;
}

/* Style Mapbox controls */
#play-map .mapboxgl-ctrl-group {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border: none;
}

#play-map .mapboxgl-ctrl-group button {
    width: 36px;
    height: 36px;
    background-color: rgba(0, 0, 0, 0.05); /* Use hover color as base */
    color: #2a0845;
}

#play-map .mapboxgl-ctrl-group button:hover {
    background-color: rgba(0, 0, 0, 0.12);
}

#play-map .mapboxgl-ctrl button.mapboxgl-ctrl-icon {
    filter: invert(11%) sepia(20%) saturate(3964%) hue-rotate(259deg) brightness(87%) contrast(98%); /* Brand purple */
}

/* Keyboard controls hint */
.play-controls-hint {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    z-index: 10;
    backdrop-filter: blur(10px);
    opacity: 0.9;
}

.play-controls-hint h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    font-weight: 600;
}

.play-controls-hint ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.play-controls-hint li {
    margin: 4px 0;
    opacity: 0.9;
}

.play-controls-hint kbd {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    font-family: monospace;
    font-size: 11px;
    margin-right: 6px;
    min-width: 20px;
    text-align: center;
}

/* Mobile: hide keyboard hints */
@media screen and (max-width: 768px) {
    .play-controls-hint {
        display: none;
    }
}

/* Loading state */
#play-map-container.loading::before {
    content: 'Loading map...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 32px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

/* Fullscreen button styling */
.mapboxgl-ctrl-fullscreen {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3'/%3E%3C/svg%3E");
}

/* Smooth transitions */
#play-map,
#play-map .mapboxgl-canvas {
    transition: filter 0.3s ease;
}

/* ============================================
   Modal Styles
   ============================================ */

.listing-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.listing-modal.is-open {
    display: block;
}

.listing-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease;
}

.listing-modal-content {
    position: relative;
    width: 90%;
    max-width: 1200px;
    height: calc(100vh - 150px); /* 100px top + 50px bottom */
    margin: 100px auto 50px auto; /* Fixed margins to avoid header overlap */
    background: white;
    border-radius: 12px;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* Account for WordPress admin bar when logged in */
body.admin-bar .listing-modal-content {
    margin-top: 132px; /* 100px + 32px admin bar */
    height: calc(100vh - 182px); /* Adjust height for admin bar */
}

.listing-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: #a6f208;
    color: #2a0845;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.listing-modal-close:hover {
    background: #2a0845;
    color: #a6f208;
}

.listing-modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.listing-modal-loading .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3B82F6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.listing-modal-loading p {
    margin-top: 20px;
    font-size: 16px;
    color: #666;
}

.listing-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    display: none;
    background: white;
}

.listing-modal-body.is-loaded {
    display: block;
}

/* Ensure Elementor content renders properly in modal */
.listing-modal-body .elementor {
    width: 100% !important;
}

.listing-modal-body .elementor-section {
    width: 100% !important;
    max-width: none !important;
}

.listing-modal-body .elementor-container {
    max-width: none !important;
}

.listing-modal-body .elementor-column-gap-default > .elementor-column > .elementor-element-populated {
    padding: 10px !important;
}

/* Fix Elementor widget spacing in modal */
.listing-modal-body .elementor-widget-wrap {
    width: 100% !important;
}

.listing-modal-body .elementor-section-boxed > .elementor-container {
    max-width: none !important;
}

/* Fix Elementor sections that might have fixed positioning */
.listing-modal-body .elementor-section {
    position: relative !important;
}

/* Ensure images scale properly */
.listing-modal-body img {
    max-width: 100%;
    height: auto;
}

/* Hide scripts, styles, admin bar, and header/footer elements */
.listing-modal-body > script,
.listing-modal-body > style,
.listing-modal-body > link,
.listing-modal-body #wpadminbar {
    display: none !important;
}

/* Hide header and footer containers */
.listing-modal-body [data-elementor-type="header"],
.listing-modal-body [data-elementor-type="footer"],
.listing-modal-body [data-elementor-location="header"],
.listing-modal-body [data-elementor-location="footer"],
.listing-modal-body .elementor-location-header,
.listing-modal-body .elementor-location-footer {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Show only the main single post content */
.listing-modal-body [data-elementor-type="single"],
.listing-modal-body [data-elementor-type="single-post"],
.listing-modal-body [data-elementor-type="wp-post"],
.listing-modal-body .elementor-location-single {
    display: block !important;
    visibility: visible !important;
}

/* Ensure main content area is visible and full width */
.listing-modal-body main,
.listing-modal-body .site-content,
.listing-modal-body article,
.listing-modal-body .entry-content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

.listing-modal-error {
    padding: 40px;
    text-align: center;
    color: #DC2626;
}

/* Modal Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ========================================
   Individual Listing Popup Styles
   ======================================== */

/* Override default Mapbox popup styles for individual listings */
.mapboxgl-popup-content {
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-family: 'Open Sans', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
}

.mapboxgl-popup-close-button {
    font-size: 18px;
    padding: 8px;
    color: #666;
}

.mapboxgl-popup-close-button:hover {
    background-color: rgba(42, 8, 69, 0.1);
    color: #2a0845;
}

/* Individual listing popup container */
.listing-popup {
    padding: 16px;
    min-width: 200px;
}

.listing-popup-title {
    font-size: 16px;
    font-weight: 700;
    color: #333333;
    margin-bottom: 8px;
    line-height: 1.3;
}

.listing-popup-type {
    display: inline-block;
    background-color: rgba(42, 8, 69, 0.1);
    color: #2a0845;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: capitalize;
}

.listing-popup-author {
    font-size: 13px;
    color: #666;
    margin-bottom: 12px;
}

.listing-popup-view-btn {
    display: block;
    width: 100%;
    padding: 8px 16px;
    background-color: #2a0845;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-transform: lowercase;
}

.listing-popup-view-btn:hover {
    background-color: #3d0c63;
}

/* ========================================
   Cluster List Popup Styles
   ======================================== */

/* Override default Mapbox popup styles */
.cluster-list-popup .mapboxgl-popup-content {
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-family: 'Open Sans', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
}

.cluster-list-popup .mapboxgl-popup-close-button {
    font-size: 18px;
    padding: 8px;
    color: #666;
}

.cluster-list-popup .mapboxgl-popup-close-button:hover {
    background-color: rgba(42, 8, 69, 0.1);
    color: #2a0845;
}

/* Popup container */
.cluster-popup {
    font-family: 'Open Sans', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Header showing count */
.cluster-popup-header {
    padding: 12px 16px;
    background-color: #2a0845;
    color: white;
    font-weight: 700;
    font-size: 14px;
    border-radius: 8px 8px 0 0;
}

/* Scrollable list container */
.cluster-popup-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 0;
}

/* Individual listing item */
.cluster-popup-item {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.cluster-popup-item:last-child {
    border-bottom: none;
}

.cluster-popup-item:hover {
    background-color: #f9fafb;
}

/* Listing title */
.cluster-popup-item-title {
    font-weight: 700;
    font-size: 14px;
    color: #333333;
    margin-bottom: 4px;
}

/* Meta info (post type and author) */
.cluster-popup-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666;
}

/* Post type badge */
.post-type-badge {
    background-color: rgba(42, 8, 69, 0.1);
    color: #2a0845;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

/* Author */
.post-author {
    color: #666;
}

/* Scrollbar styling */
.cluster-popup-list::-webkit-scrollbar {
    width: 6px;
}

.cluster-popup-list::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.cluster-popup-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.cluster-popup-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .cluster-list-popup .mapboxgl-popup-content {
        max-width: 280px !important;
    }

    .cluster-popup-list {
        max-height: 200px;
    }

    .cluster-popup-item-title {
        font-size: 13px;
    }
}

/* Mobile modal styles */
@media (max-width: 768px) {
    .listing-modal-content {
        width: calc(100% - 20px);
        height: calc(100vh - 200px); /* 150px top + 50px bottom */
        margin: 150px 10px 50px 10px; /* 150px top, 10px sides, 50px bottom */
        border-radius: 12px;
        max-width: none;
    }

    .listing-modal-close {
        top: 15px;
        right: 15px;
        z-index: 10002; /* Ensure it's above modal content */
    }
}

/* Disable body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}
