/**
 * Amenity Leaflet Map - Frontend Styles
 * Dark theme with gold accents
 */

/* Container */
.alm-map-container {
    --alm-primary: #c9a962;
    --alm-secondary: #3d4f5f;
    --alm-bg-dark: #3F4448;
    --alm-bg-darker: #2d3136;
    --alm-text: #ffffff;
    --alm-text-muted: #9ba8b4;
    --alm-border: #4a5a6a;
    
    display: flex;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--alm-bg-dark);
    border-radius: 8px;
    overflow: visible;
    position: relative;
}

.alm-map-container * {
    box-sizing: border-box;
}

/* Map Wrapper - sets the height for the entire component */
.alm-map-wrapper {
    flex: 1;
    min-width: 0;
    position: relative;
    transition: flex 0.3s ease;
    /* Reserve space for legend */
    margin-right: 340px;
}

.alm-map {
    width: 100%;
    background: #3F4448 !important;
}

/* Leaflet overrides for dark theme */
.alm-map-container .leaflet-container {
    background: #3F4448 !important;
}

/* Lighten the dark tiles to match #3F4448 gray */
.alm-map-container .leaflet-tile-pane {
    filter: brightness(1.6) saturate(0.3);
}

.alm-map-container .leaflet-control-attribution {
    background: rgba(63, 68, 72, 0.95) !important;
    color: var(--alm-text-muted) !important;
    font-size: 10px;
}

.alm-map-container .leaflet-control-attribution a {
    color: var(--alm-primary) !important;
}

.alm-map-container .leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.alm-map-container .leaflet-control-zoom a {
    background: var(--alm-bg-dark) !important;
    color: var(--alm-text) !important;
    border: none !important;
}

.alm-map-container .leaflet-control-zoom a:hover {
    background: var(--alm-secondary) !important;
}

/* Legend - Absolutely positioned to match map height */
.alm-legend {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 340px;
    background: var(--alm-bg-darker);
    border-left: 2px solid var(--alm-primary);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, opacity 0.3s ease;
    overflow: visible;
}

.alm-legend.collapsed {
    width: 0;
    border-left: none;
}

/* When collapsed, remove margin from map wrapper */
.alm-map-container:has(.alm-legend.collapsed) .alm-map-wrapper {
    margin-right: 0;
}

.alm-legend.collapsed .alm-legend-content {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.alm-legend.collapsed .alm-toggle-icon {
    transform: rotate(180deg);
}

/* Legend Toggle - Always visible */
.alm-legend-toggle {
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: var(--alm-primary);
    border: none;
    border-radius: 50%;
    color: var(--alm-bg-darker);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: transform 0.2s ease, left 0.3s ease;
}

.alm-legend-toggle:hover {
    transform: translateY(-50%) scale(1.1);
}

.alm-toggle-icon {
    transition: transform 0.3s ease;
    display: block;
}

/* Legend Content */
.alm-legend-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.alm-legend.collapsed .alm-legend-content {
    overflow: hidden;
}

.alm-legend-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--alm-primary);
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--alm-border);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Legend Header */
.alm-legend-header {
    display: grid;
    grid-template-columns: 30px 1fr 55px 55px 55px;
    gap: 8px;
    padding: 10px 8px;
    border-bottom: 1px solid var(--alm-border);
    margin-bottom: 10px;
    color: var(--alm-text-muted);
    font-size: 12px;
    align-items: center;
}

.alm-legend-col-header {
    display: flex;
    align-items: center;
    justify-content: center;
}

.alm-legend-col-header svg {
    width: 20px;
    height: 20px;
    color: var(--alm-text-muted);
}

/* Legend Items */
.alm-legend-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.alm-legend-item {
    display: grid;
    grid-template-columns: 30px 1fr 55px 55px 55px;
    gap: 8px;
    align-items: center;
    padding: 12px 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
    cursor: default;
}

.alm-legend-item:hover {
    background: rgba(201, 169, 98, 0.1);
}

.alm-legend-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--alm-primary);
}

.alm-legend-icon svg {
    width: 22px;
    height: 22px;
}

.alm-legend-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.alm-legend-name {
    font-size: 14px;
    color: var(--alm-primary);
    font-weight: 500;
    line-height: 1.3;
}

.alm-legend-distance,
.alm-legend-walk,
.alm-legend-drive {
    font-size: 13px;
    color: var(--alm-text);
    text-align: center;
}

/* Legend Positions */
.alm-legend-left {
    flex-direction: row-reverse;
}

.alm-legend-left .alm-legend {
    border-left: none;
    border-right: 2px solid var(--alm-primary);
}

.alm-legend-left .alm-legend.collapsed {
    border-right: none;
}

.alm-legend-left .alm-legend-toggle {
    left: auto;
    right: -20px;
}

.alm-legend-left .alm-toggle-icon {
    transform: rotate(180deg);
}

.alm-legend-left .alm-legend.collapsed .alm-toggle-icon {
    transform: rotate(0deg);
}

.alm-legend-bottom {
    flex-direction: column;
}

.alm-legend-bottom .alm-legend {
    width: 100%;
    min-width: 100%;
    border-left: none;
    border-top: 2px solid var(--alm-primary);
    max-height: 250px;
    overflow: visible;
}

.alm-legend-bottom .alm-legend.collapsed {
    max-height: 0;
    border-top: none;
}

.alm-legend-bottom .alm-legend-toggle {
    left: 50%;
    top: -20px;
    transform: translateX(-50%);
}

.alm-legend-bottom .alm-toggle-icon {
    transform: rotate(90deg);
}

.alm-legend-bottom .alm-legend.collapsed .alm-toggle-icon {
    transform: rotate(-90deg);
}

/* Map Markers */
.alm-main-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--alm-primary);
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 3px 10px rgba(0,0,0,0.4);
    overflow: hidden;
}

.alm-main-marker img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Image pins - no border radius */
.alm-main-marker-image {
    border-radius: 0;
    background: transparent;
    border: none;
    box-shadow: 0 3px 10px rgba(0,0,0,0.4);
}

.alm-main-marker-image img {
    object-fit: contain;
}

.alm-main-marker svg {
    width: 60%;
    height: 60%;
    color: #fff;
}

.alm-amenity-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--alm-primary);
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    overflow: hidden;
}

.alm-amenity-marker img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.alm-amenity-marker svg {
    width: 55%;
    height: 55%;
    color: #fff;
}

/* Permanent Labels */
.alm-permanent-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--alm-text);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    text-shadow: 
        1px 1px 2px rgba(0,0,0,0.8),
        -1px -1px 2px rgba(0,0,0,0.8),
        1px -1px 2px rgba(0,0,0,0.8),
        -1px 1px 2px rgba(0,0,0,0.8);
}

.alm-permanent-label::before {
    display: none !important;
}

/* Tooltips */
.alm-map-container .leaflet-tooltip {
    background: var(--alm-bg-darker);
    border: 1px solid var(--alm-primary);
    color: var(--alm-text);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.alm-map-container .leaflet-tooltip-top::before {
    border-top-color: var(--alm-primary);
}

.alm-map-container .leaflet-tooltip-bottom::before {
    border-bottom-color: var(--alm-primary);
}

.alm-map-container .leaflet-tooltip-left::before {
    border-left-color: var(--alm-primary);
}

.alm-map-container .leaflet-tooltip-right::before {
    border-right-color: var(--alm-primary);
}

/* Popups */
.alm-map-container .leaflet-popup-content-wrapper {
    background: var(--alm-bg-darker);
    color: var(--alm-text);
    border-radius: 6px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.4);
}

.alm-map-container .leaflet-popup-content {
    margin: 12px 15px;
    font-size: 14px;
}

.alm-map-container .leaflet-popup-tip {
    background: var(--alm-bg-darker);
}

.alm-map-container .leaflet-popup-close-button {
    color: var(--alm-text-muted) !important;
}

.alm-map-container .leaflet-popup-close-button:hover {
    color: var(--alm-primary) !important;
}

/* Responsive */
@media screen and (max-width: 900px) {
    .alm-map-container {
        flex-direction: column;
    }
    
    .alm-map-wrapper {
        margin-right: 0;
    }
    
    .alm-map {
        height: 300px !important;
    }
    
    .alm-legend {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        width: 100%;
        border-left: none;
        border-top: 2px solid var(--alm-primary);
        max-height: 300px;
        overflow: visible;
    }
    
    .alm-legend.collapsed {
        width: 100%;
        max-height: 0;
        border-top: none;
    }
    
    .alm-legend-toggle {
        left: 50%;
        top: -18px;
        transform: translateX(-50%);
        width: 36px;
        height: 36px;
    }
    
    .alm-legend-toggle:hover {
        transform: translateX(-50%) scale(1.1);
    }
    
    .alm-toggle-icon {
        transform: rotate(90deg);
    }
    
    .alm-legend.collapsed .alm-toggle-icon {
        transform: rotate(-90deg);
    }
    
    .alm-legend-left .alm-legend,
    .alm-legend-right .alm-legend {
        border-right: none;
    }
}

@media screen and (max-width: 480px) {
    .alm-map {
        height: 250px !important;
    }
    
    .alm-legend-content {
        padding: 15px;
    }
    
    .alm-legend-item {
        grid-template-columns: 25px 1fr 45px 45px 45px;
        gap: 6px;
        padding: 10px 5px;
    }
    
    .alm-legend-name {
        font-size: 13px;
    }
    
    .alm-legend-distance,
    .alm-legend-walk,
    .alm-legend-drive {
        font-size: 11px;
    }
}

/* Animation for markers */
@keyframes alm-marker-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.alm-marker-hover {
    animation: alm-marker-bounce 0.5s ease;
}
