/* ============================================
   Map Styles - Hawaiian Tropical Theme
   ============================================ */

/* Map Container */
#map {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #e0f2fe 0%, #bae6fd 100%);
}

/* ============================================
   Custom Markers
   ============================================ */

.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 3px solid white;
    box-shadow:
        0 4px 12px rgba(12, 74, 110, 0.25),
        0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s var(--ease-bounce), box-shadow 0.2s;
}

.custom-marker:hover {
    transform: rotate(-45deg) scale(1.15);
    box-shadow:
        0 8px 24px rgba(12, 74, 110, 0.3),
        0 4px 8px rgba(0, 0, 0, 0.15);
}

.custom-marker .marker-icon {
    transform: rotate(45deg);
    font-size: 16px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Category-specific marker colors - Hawaiian palette */
.marker-snorkeling {
    background: linear-gradient(135deg, #0ea5e9, #06b6d4);
}
.marker-spearfishing {
    background: linear-gradient(135deg, #14b8a6, #2dd4bf);
}
.marker-scuba {
    background: linear-gradient(135deg, #06b6d4, #22d3ee);
}
.marker-boat_dives {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
}
.marker-surfing {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
}
.marker-hikes {
    background: linear-gradient(135deg, #22c55e, #4ade80);
}
.marker-restaurants {
    background: linear-gradient(135deg, #f97316, #fb923c);
}
.marker-beaches {
    background: linear-gradient(135deg, #fbbf24, #fcd34d);
}
.marker-events {
    background: linear-gradient(135deg, #ec4899, #f472b6);
}
.marker-hana {
    background: linear-gradient(135deg, #84cc16, #a3e635);
}
.marker-family {
    background: linear-gradient(135deg, #a855f7, #c084fc);
}

/* ============================================
   Cluster Markers
   ============================================ */

.marker-cluster {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s var(--ease-bounce);
}

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

.marker-cluster div {
    border-radius: 50%;
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    color: white;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.marker-cluster-small {
    background: radial-gradient(circle, rgba(34, 197, 94, 0.4) 0%, rgba(34, 197, 94, 0.1) 70%);
}
.marker-cluster-small div {
    background: linear-gradient(135deg, #22c55e, #4ade80);
    width: 34px;
    height: 34px;
    line-height: 34px;
    font-size: 13px;
}

.marker-cluster-medium {
    background: radial-gradient(circle, rgba(251, 191, 36, 0.4) 0%, rgba(251, 191, 36, 0.1) 70%);
}
.marker-cluster-medium div {
    background: linear-gradient(135deg, #fbbf24, #fcd34d);
    width: 44px;
    height: 44px;
    line-height: 44px;
    font-size: 14px;
}

.marker-cluster-large {
    background: radial-gradient(circle, rgba(251, 113, 133, 0.4) 0%, rgba(251, 113, 133, 0.1) 70%);
}
.marker-cluster-large div {
    background: linear-gradient(135deg, #fb7185, #fda4af);
    width: 54px;
    height: 54px;
    line-height: 54px;
    font-size: 15px;
}

/* ============================================
   Map Popup
   ============================================ */

.leaflet-popup-content-wrapper {
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid rgba(251, 191, 36, 0.2);
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0 !important;
    padding: 0 !important;
    min-width: 220px;
    max-width: 300px;
}

.leaflet-popup-tip {
    background: white !important;
    box-shadow: var(--shadow) !important;
}

.popup-content {
    padding: 16px;
    background: linear-gradient(180deg, white 0%, var(--sand-light) 100%);
}

.popup-category {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.75px;
    color: white;
    margin-bottom: 10px;
}

.popup-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1.3;
}

.popup-area {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.popup-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.popup-badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: var(--sand);
    color: var(--text-secondary);
}

.popup-badge.positive {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #065f46;
}

.popup-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--ocean-light), var(--lagoon));
    color: white;
    border: none;
    border-radius: var(--radius);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.25);
}

.popup-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.35);
}

.popup-btn:active {
    transform: scale(0.98);
}

/* ============================================
   Map Controls
   ============================================ */

.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-md) !important;
    border-radius: var(--radius) !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
    font-size: 20px !important;
    color: var(--ocean-deep) !important;
    background: white !important;
    border: none !important;
    transition: all 0.2s !important;
}

.leaflet-control-zoom a:hover {
    background: var(--sand) !important;
    color: var(--ocean) !important;
}

.leaflet-control-zoom a:first-child {
    border-radius: var(--radius) var(--radius) 0 0 !important;
}

.leaflet-control-zoom a:last-child {
    border-radius: 0 0 var(--radius) var(--radius) !important;
}

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
    font-weight: 300 !important;
}

/* Location Button */
.locate-btn {
    width: 44px;
    height: 44px;
    background: white;
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
}

.locate-btn:hover {
    background: var(--sand);
    transform: scale(1.05);
}

.locate-btn:active {
    transform: scale(0.95);
    background: var(--sand-dark);
}

/* Layer Control (Satellite/Terrain Toggle) */
.layer-control {
    position: relative;
}

.layer-toggle-btn {
    width: 44px;
    height: 44px;
    background: white;
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    margin-top: 8px;
}

.layer-toggle-btn:hover {
    background: var(--sand);
    transform: scale(1.05);
}

.layer-options {
    position: absolute;
    top: 0;
    right: 52px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(10px);
    transition: all 0.2s var(--ease-smooth);
    min-width: 150px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.layer-options.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.layer-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: transparent;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    font-family: 'DM Sans', sans-serif;
    text-align: left;
}

.layer-option:hover {
    background: var(--sand-light);
}

.layer-option.active {
    background: linear-gradient(135deg, var(--ocean-light), var(--lagoon));
    color: white;
}

.layer-icon {
    font-size: 1.25rem;
}

.layer-name {
    font-size: 0.875rem;
    font-weight: 600;
}

.leaflet-top.leaflet-right {
    top: 12px;
    right: 12px;
}

/* ============================================
   Fullscreen Map
   ============================================ */

#mapView.fullscreen #map {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3000;
}

/* ============================================
   Map Legend
   ============================================ */

.map-legend {
    position: absolute;
    bottom: 24px;
    left: 12px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 14px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    font-size: 0.8125rem;
    z-index: 500;
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* ============================================
   Attribution
   ============================================ */

.leaflet-control-attribution {
    font-family: 'DM Sans', sans-serif !important;
    font-size: 10px !important;
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    padding: 4px 8px !important;
    border-radius: var(--radius-sm) 0 0 0 !important;
}

.leaflet-control-attribution a {
    color: var(--ocean) !important;
}

/* ============================================
   Accommodation Markers (Condo & Cabins)
   ============================================ */

.accommodation-marker-container {
    background: transparent !important;
    border: none !important;
}

.accommodation-marker {
    width: 44px;
    height: 44px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid white;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.3),
        0 0 0 3px rgba(255, 255, 255, 0.5);
    animation: accommodationPulse 3s ease-in-out infinite;
}

.accommodation-icon {
    transform: rotate(45deg);
    font-size: 20px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

@keyframes accommodationPulse {
    0%, 100% {
        box-shadow:
            0 4px 16px rgba(0, 0, 0, 0.3),
            0 0 0 3px rgba(255, 255, 255, 0.5);
    }
    50% {
        box-shadow:
            0 4px 16px rgba(0, 0, 0, 0.3),
            0 0 0 6px rgba(255, 255, 255, 0.3),
            0 0 20px rgba(220, 38, 38, 0.4);
    }
}

/* ============================================
   User Location Marker
   ============================================ */

.user-location-marker {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow:
        0 0 0 8px rgba(59, 130, 246, 0.2),
        0 4px 12px rgba(59, 130, 246, 0.4);
    animation: locationPulse 2s ease-in-out infinite;
}

@keyframes locationPulse {
    0%, 100% {
        box-shadow:
            0 0 0 8px rgba(59, 130, 246, 0.2),
            0 4px 12px rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow:
            0 0 0 16px rgba(59, 130, 246, 0.1),
            0 4px 12px rgba(59, 130, 246, 0.4);
    }
}

/* ============================================
   Desktop Enhancements
   ============================================ */

@media (min-width: 768px) {
    .custom-marker {
        width: 40px;
        height: 40px;
    }

    .custom-marker .marker-icon {
        font-size: 18px;
    }

    .leaflet-control-zoom a {
        width: 44px !important;
        height: 44px !important;
        line-height: 44px !important;
    }

    .locate-btn {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }

    .popup-content {
        padding: 20px;
    }

    .popup-title {
        font-size: 1.25rem;
    }
}

@media (min-width: 1024px) {
    .custom-marker {
        width: 42px;
        height: 42px;
        border-width: 3px;
    }

    .custom-marker .marker-icon {
        font-size: 19px;
    }

    .marker-cluster-small div {
        width: 38px;
        height: 38px;
        line-height: 38px;
    }

    .marker-cluster-medium div {
        width: 48px;
        height: 48px;
        line-height: 48px;
    }

    .marker-cluster-large div {
        width: 58px;
        height: 58px;
        line-height: 58px;
    }

    .leaflet-popup-content {
        min-width: 260px;
        max-width: 340px;
    }

    .map-legend {
        bottom: 32px;
        left: 16px;
        padding: 16px;
    }
}

/* ============================================
   Map Sidebar - Visible Locations (Desktop Only)
   ============================================ */

.map-sidebar {
    display: none;
}

@media (min-width: 1024px) {
    /* Only show sidebar when Map view is active */
    #mapView.active .map-sidebar {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: calc(var(--header-height) + var(--filter-height) + var(--category-height));
        left: 0;
        width: var(--split-position);
        min-width: 280px;
        bottom: calc(var(--nav-height) + var(--safe-bottom));
        background: var(--bg-primary);
        overflow: hidden;
        z-index: 50;
    }

    .map-sidebar-header {
        padding: 16px 20px;
        background: var(--bg-elevated);
        border-bottom: 1px solid var(--sand-dark);
        font-family: 'Outfit', sans-serif;
        font-weight: 600;
        font-size: 0.95rem;
        color: var(--text-secondary);
    }

    .sidebar-count {
        color: var(--ocean);
        font-weight: 700;
        font-size: 1.1rem;
    }

    .map-sidebar-list {
        flex: 1;
        overflow-y: auto;
        padding: 12px;
    }

    .sidebar-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        background: var(--bg-card);
        border-radius: var(--radius-md);
        margin-bottom: 8px;
        cursor: pointer;
        transition: all 0.2s var(--ease-smooth);
        border: 1px solid transparent;
    }

    .sidebar-item:hover {
        background: var(--sand-light);
        border-color: var(--ocean-light);
        transform: translateX(4px);
    }

    .sidebar-item-icon {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1rem;
        color: white;
        flex-shrink: 0;
    }

    .sidebar-item-content {
        flex: 1;
        min-width: 0;
    }

    .sidebar-item-name {
        font-weight: 600;
        font-size: 0.9rem;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sidebar-item-area {
        font-size: 0.8rem;
        color: var(--text-muted);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sidebar-item-badges {
        display: flex;
        gap: 4px;
        flex-shrink: 0;
    }

    .sidebar-badge {
        font-size: 0.75rem;
        opacity: 0.8;
    }

    .sidebar-empty {
        text-align: center;
        padding: 40px 20px;
        color: var(--text-muted);
        font-size: 0.9rem;
    }

    .sidebar-empty-icon {
        font-size: 2.5rem;
        margin-bottom: 12px;
        opacity: 0.5;
    }
}

/* ============================================
   Floating Map Controls
   ============================================ */

.map-floating-controls {
    position: absolute;
    top: 80px;
    right: 12px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-control-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.map-control-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.map-control-btn:active {
    transform: scale(0.95);
}

.map-control-btn.active {
    background: var(--ocean);
    color: white;
}

/* Hide search on desktop - they have the sidebar */
@media (min-width: 769px) {
    #mapSearchBtn {
        display: none;
    }
}

/* ============================================
   Map Labels (Tooltips)
   ============================================ */

.leaflet-tooltip.map-label {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--sand-dark);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaflet-tooltip.map-label::before {
    display: none;
}

/* Search Overlay */
.map-search-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    background: rgba(12, 74, 110, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    flex-direction: column;
    padding: 12px;
}

.map-search-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.map-search-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.map-search-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--sand-light);
}

.map-search-header input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--sand-light);
    border-radius: 12px;
    font-size: 1rem;
    background: var(--sand-light);
    transition: all 0.2s ease;
}

.map-search-header input:focus {
    outline: none;
    border-color: var(--ocean);
    background: white;
}

.map-search-close {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--sand-light);
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.map-search-close:hover {
    background: var(--coral);
    color: white;
}

.map-search-results {
    flex: 1;
    overflow-y: auto;
    max-height: 60vh;
}

.map-search-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--sand-light);
    cursor: pointer;
    transition: background 0.15s ease;
}

.map-search-result:hover {
    background: var(--sand-light);
}

.map-search-result:active {
    background: var(--sand);
}

.map-search-result-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.map-search-result-info {
    flex: 1;
    min-width: 0;
}

.map-search-result-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-search-result-area {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.map-search-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.map-search-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.5;
}
