/**
 * ACE Live Map - Stylesheet
 * 
 * Styles for the interactive Dereth map with live player positions.
 */

/* Container - Full viewport map */
.livemap-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 120px);
    min-height: 500px;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.livemap-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bs-body-bg, #fff);
    border-right: 1px solid var(--bs-border-color, #dee2e6);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.3s ease, min-width 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

.livemap-sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}

/* Floating toggle button on map (visible when sidebar collapsed on desktop) */
.livemap-sidebar-float {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1001;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 4px;
    background: var(--bs-body-bg, #fff);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--bs-body-color, #333);
}

.livemap-sidebar-float:hover {
    background: var(--bs-tertiary-bg, #e9ecef);
}

/* Show float button when sidebar is collapsed (desktop only) */
@media (min-width: 768px) {
    .livemap-container.sidebar-collapsed .livemap-sidebar-float {
        display: flex;
    }
}

/* Reset view button - styled like Leaflet controls */
.livemap-reset-view {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1001;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 4px;
    background: var(--bs-body-bg, #fff);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--bs-body-color, #333);
    transition: background-color 0.2s ease;
}

.livemap-reset-view:hover {
    background: var(--bs-tertiary-bg, #e9ecef);
}

/* Follow indicator - shown when tracking a player */
.livemap-follow-indicator {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: rgba(74, 144, 217, 0.95);
    color: #fff;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    font-size: 0.85rem;
    backdrop-filter: blur(4px);
}

.livemap-follow-indicator .follow-status {
    display: flex;
    align-items: center;
}

.livemap-follow-indicator .btn {
    padding: 0.15rem 0.35rem;
    font-size: 0.75rem;
    line-height: 1;
}

/* Player trail styling */
.player-trail {
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* When sidebar collapsed, adjust follow indicator position */
.sidebar-collapsed .livemap-follow-indicator {
    left: 50%;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    background: var(--bs-tertiary-bg, #f8f9fa);
}

.sidebar-search {
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.layer-group {
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: var(--bs-tertiary-bg, #f8f9fa);
    border-radius: 0.375rem;
}

.layer-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--bs-secondary-color, #6c757d);
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.layer-group .form-check {
    margin-bottom: 0.25rem;
}

.layer-group .form-check-label {
    font-size: 0.875rem;
}

/* Mobile sidebar toggle */
.livemap-sidebar-toggle {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1001;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 0.375rem;
    background: var(--bs-body-bg, #fff);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* Map */
.livemap-map {
    flex: 1;
    background: #1a1a2e;
    z-index: 1;
}

/* Status bar */
.livemap-status-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 32px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    font-size: 0.75rem;
    gap: 1rem;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.livemap-status-bar > span {
    white-space: nowrap;
}

.status-separator {
    color: rgba(255, 255, 255, 0.3);
    font-weight: 300;
}

.status-players {
    color: #6495ED;
}

.status-players i {
    color: #88d4ff;
}

.status-coords {
    font-family: 'Consolas', 'Monaco', monospace;
    color: #fff;
}

.status-coords i {
    color: #ffcc88;
}

.status-landblock {
    font-family: 'Consolas', 'Monaco', monospace;
    color: #88d4ff;
}

.status-cell {
    font-size: 0.65rem;
    color: #88ffcc !important;
}

.status-zoom {
    color: rgba(255, 255, 255, 0.7);
}

.status-zoom i {
    color: rgba(255, 255, 255, 0.5);
}

.status-update {
    color: rgba(255, 255, 255, 0.7);
}

.status-update i {
    color: rgba(255, 255, 255, 0.5);
}

.status-offline {
    font-weight: 500;
}

/* Loading overlay */
.livemap-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 46, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    color: #fff;
}

/* Player markers with level-gradient coloring */
.player-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Inner element for opacity control (level gradient) */
.player-marker-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #6495ED; /* Cornflower blue base color */
}

/* Level-based colors - intensity increases with level */
.player-marker.level-low { background: rgba(100, 149, 237, 0.6); }
.player-marker.level-low .player-marker-inner { background: #6495ED; }

.player-marker.level-mid { background: rgba(30, 144, 255, 0.8); }
.player-marker.level-mid .player-marker-inner { background: #1E90FF; }

.player-marker.level-high { background: rgba(0, 105, 255, 1); }
.player-marker.level-high .player-marker-inner { background: #0069FF; }

/* Combat pulse animation for PK combat awareness */
@keyframes combat-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.7), 0 2px 4px rgba(0,0,0,0.3); }
    50% { box-shadow: 0 0 0 10px rgba(255, 0, 0, 0), 0 2px 4px rgba(0,0,0,0.3); }
}

.player-marker.combat-pulse {
    animation: combat-pulse 1s infinite;
    border-color: #ff4444;
}

.player-marker.combat-pulse .player-marker-inner {
    background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
}

/* Damage pulse animation for PvE combat awareness (orange/amber) */
@keyframes damage-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 165, 0, 0.7), 0 2px 4px rgba(0,0,0,0.3); }
    50% { box-shadow: 0 0 0 8px rgba(255, 165, 0, 0), 0 2px 4px rgba(0,0,0,0.3); }
}

.player-marker.damage-pulse {
    animation: damage-pulse 1.5s infinite;
    border-color: #ff9800;
}

.player-marker.damage-pulse .player-marker-inner {
    background: linear-gradient(135deg, #ffb347 0%, #ff9800 100%);
}

/* Combat pulse takes priority over damage pulse when both active */
.player-marker.combat-pulse.damage-pulse {
    animation: combat-pulse 1s infinite;
    border-color: #ff4444;
}

.player-marker.combat-pulse.damage-pulse .player-marker-inner {
    background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
}

/* Player popup - Rich display with health bars, combat status, armory link */
.player-popup {
    min-width: 220px;
    max-width: 280px;
    color: var(--bs-body-color);
}

.player-popup .popup-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--bs-border-color, rgba(0,0,0,0.1));
    color: var(--bs-body-color);
}

.player-popup .player-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--bs-body-color);
}

.player-popup .player-level {
    flex-shrink: 0;
    font-size: 0.75rem;
}

.player-popup .popup-stat {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: var(--bs-body-color);
}

.player-popup .popup-stat-small {
    font-size: 0.75rem;
    opacity: 0.8;
}

.player-popup .popup-stat-label {
    color: var(--bs-secondary-color, #6c757d);
}

.player-popup .popup-stat span:not(.popup-stat-label) {
    color: var(--bs-body-color);
}

/* Vital bars (health, stamina, mana) */
.player-popup .popup-vitals {
    background: var(--bs-tertiary-bg, rgba(0,0,0,0.05));
    border-radius: 0.25rem;
    padding: 0.5rem;
    margin: 0.5rem 0;
}

.player-popup .vital-bar {
    margin-bottom: 0.375rem;
}

.player-popup .vital-bar:last-child {
    margin-bottom: 0;
}

.player-popup .vital-bar-label {
    font-size: 0.7rem;
    color: var(--bs-secondary-color, #6c757d);
    margin-bottom: 0.125rem;
}

.player-popup .vital-bar .progress {
    background-color: var(--bs-secondary-bg, rgba(0,0,0,0.1));
    height: 0.5rem;
}

/* Combat status indicator */
.player-popup .popup-combat-status {
    padding: 0.5rem;
    background: rgba(220, 53, 69, 0.15);
    border-radius: 0.25rem;
    font-size: 0.8rem;
    text-align: center;
}

[data-bs-theme="dark"] .player-popup .popup-combat-status,
.dark .player-popup .popup-combat-status {
    background: rgba(220, 53, 69, 0.25);
}

.player-popup .popup-combat-status span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0 0.25rem;
}

/* Legacy combat display (fallback) */
.player-popup .popup-combat {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--bs-danger, #dc3545);
    font-weight: 500;
}

.player-popup .popup-actions {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--bs-border-color, rgba(0,0,0,0.1));
}

.player-popup .popup-actions .btn {
    font-size: 0.8rem;
}

/* ==========================================================================
   Leaflet Popup Theming - Bootstrap 5 Light/Dark Support
   ========================================================================== */

/* Base popup styling - inherits from Bootstrap theme */
.leaflet-popup-content-wrapper {
    background-color: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #212529);
    border-radius: var(--bs-border-radius, 0.375rem);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.leaflet-popup-tip {
    background-color: var(--bs-body-bg, #fff);
}

/* Close button theming */
.leaflet-popup-close-button {
    color: var(--bs-body-color, #212529) !important;
    opacity: 0.5;
}

.leaflet-popup-close-button:hover {
    color: var(--bs-body-color, #212529) !important;
    opacity: 1;
}

/* Dark theme specific overrides */
[data-bs-theme="dark"] .leaflet-popup-content-wrapper,
.dark .leaflet-popup-content-wrapper,
[data-theme="dark"] .leaflet-popup-content-wrapper {
    background-color: var(--bs-body-bg, #212529);
    color: var(--bs-body-color, #dee2e6);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .leaflet-popup-tip,
.dark .leaflet-popup-tip,
[data-theme="dark"] .leaflet-popup-tip {
    background-color: var(--bs-body-bg, #212529);
}

/* Player popup wrapper specific styling */
.player-popup-wrapper .leaflet-popup-content-wrapper {
    padding: 0;
}

.player-popup-wrapper .leaflet-popup-content {
    margin: 0.75rem;
}

/* Town/POI markers */
.town-marker {
    width: 24px;
    height: 24px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
}

.town-marker.aluvian { background-image: url('../img/icons/Map_Point_Aluv_Town.png'); }
.town-marker.gharundim { background-image: url('../img/icons/Map_Point_Gharu_Town.png'); }
.town-marker.sho { background-image: url('../img/icons/Map_Point_Sho_Town.png'); }
.town-marker.viamontian { background-image: url('../img/icons/Map_Point_Via_Town.png'); }
.town-marker.outpost { background-image: url('../img/icons/Map_Point_Town.png'); }

.poi-marker {
    width: 20px;
    height: 20px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
}

.poi-marker.portal { background-image: url('../img/icons/Map_Point_Portal_2.png'); }
.poi-marker.lifestone { background-image: url('../img/icons/Map_Point_Lifestone_2.png'); }
.poi-marker.dungeon { background-image: url('../img/icons/Map_Point_Dungeon.png'); }
.poi-marker.npc { background-image: url('../img/icons/Map_Point_NPC.png'); }

/* POI Cluster Markers */
.poi-cluster {
    text-align: center;
}

.poi-cluster div {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    border: 3px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.poi-cluster-portal div {
    background-color: rgba(138, 43, 226, 0.8); /* Purple for portals */
}

.poi-cluster-lifestone div {
    background-color: rgba(76, 175, 80, 0.8); /* Green for lifestones */
}

.poi-cluster-dungeon div {
    background-color: rgba(244, 67, 54, 0.8); /* Red for dungeons */
}

.poi-cluster-npc div {
    background-color: rgba(33, 150, 243, 0.8); /* Blue for NPCs */
}

/* POI Cluster size variations */
.poi-cluster-small div {
    width: 32px;
    height: 32px;
    font-size: 11px;
}

.poi-cluster-medium div {
    width: 40px;
    height: 40px;
    font-size: 13px;
}

.poi-cluster-large div {
    width: 48px;
    height: 48px;
    font-size: 15px;
}

/* Cluster markers - sized based on player count */
.player-cluster-icon {
    background: rgba(100, 149, 237, 0.9);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    color: #fff;
    font-weight: 600;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-cluster {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Size variants for clusters */
.player-cluster-small {
    width: 40px;
    height: 40px;
    font-size: 12px;
    line-height: 36px;
}

.player-cluster-medium {
    width: 50px;
    height: 50px;
    font-size: 14px;
    line-height: 46px;
    background: rgba(30, 144, 255, 0.9);
}

.player-cluster-large {
    width: 60px;
    height: 60px;
    font-size: 16px;
    line-height: 56px;
    background: rgba(0, 105, 255, 0.95);
}

/* Ensure cluster spans are centered */
.player-cluster span {
    display: block;
}

/* Selected location highlight */
.selected-marker {
    outline: 3px solid #28a745;
    outline-offset: 2px;
}

/* Grid overlay styling */
.landblock-grid {
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 1;
}

.cell-grid {
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 0.5;
}

/* Stale data indicator - Grey out effect with timestamp */
.stale-marker {
    opacity: 0.5 !important;
    filter: grayscale(0.6);
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.stale-marker .player-marker-inner {
    background: #888 !important;
}

.stale-marker.player-marker {
    border-color: #999 !important;
}

/* Stale status indicator in status bar */
.status-stale {
    color: #ffc107 !important;
    animation: stale-pulse 2s infinite;
}

@keyframes stale-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Dungeon entrance marker container */
.dungeon-entrance-marker {
    position: relative;
    display: inline-block;
}

.dungeon-entrance-icon {
    position: relative;
    display: inline-block;
}

/* Dungeon entrance badge - shows player count */
.dungeon-entrance-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: linear-gradient(135deg, #dc3545 0%, #a71d2a 100%);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.3);
    z-index: 10;
}

/* Badge size variants based on player count */
.dungeon-entrance-badge.badge-medium {
    min-width: 20px;
    height: 20px;
    font-size: 0.7rem;
    border-radius: 10px;
    top: -8px;
    right: -8px;
}

.dungeon-entrance-badge.badge-large {
    min-width: 24px;
    height: 24px;
    font-size: 0.75rem;
    border-radius: 12px;
    top: -10px;
    right: -10px;
    background: linear-gradient(135deg, #ff4444 0%, #dc3545 100%);
    animation: badge-pulse 2s infinite;
}

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

/* Dungeon player list in popup */
.dungeon-player-item {
    font-size: 0.8rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.dungeon-player-item:last-child {
    border-bottom: none;
}

.dungeon-player-item .player-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
}

/* Settlement markers - same pattern as towns for consistent scaling */
.settlement-marker {
    width: 24px;
    height: 24px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
}

.settlement-marker.cottage { background-image: url('../img/icons/Map_Point_Cottage.png'); }
.settlement-marker.villa { background-image: url('../img/icons/Map_Point_Villa.png'); }
.settlement-marker.mansion { background-image: url('../img/icons/Map_Point_Mansion.png'); }

.settlement-marker .availability-badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background: #28a745;
    color: #fff;
    font-size: 0.5rem;
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Hover highlight - Landblock level */
.hover-landblock {
    stroke: #ffcc00;
    stroke-width: 2;
    fill: rgba(255, 204, 0, 0.08);
    pointer-events: none;
}

/* Hover highlight - Cell level (appears at high zoom) */
.hover-cell {
    stroke: #00ff88;
    stroke-width: 2;
    fill: rgba(0, 255, 136, 0.15);
    pointer-events: none;
}

/* Search result highlight */
.search-result-marker {
    stroke: #28a745;
    stroke-width: 3;
    fill: rgba(40, 167, 69, 0.2);
}

/* Selection highlight - for clicked locations */
.selection-highlight {
    pointer-events: none;
}

/* Selection pulse animation ring */
.selection-pulse {
    pointer-events: none;
    animation: selection-ring-pulse 2s ease-out infinite;
}

@keyframes selection-ring-pulse {
    0% {
        stroke-opacity: 0.8;
        transform: scale(1);
    }
    100% {
        stroke-opacity: 0;
        transform: scale(1.5);
    }
}

/* Selected marker styling */
.selected-marker {
    z-index: 1000 !important;
}

.leaflet-marker-icon.selected-marker {
    filter: drop-shadow(0 0 6px #28a745);
}

/* Selected town/poi markers get green border */
.town-marker.selected-marker,
.poi-marker.selected-marker {
    outline: 3px solid #28a745;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Selected player marker */
.player-marker.selected-marker {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.4), 0 2px 4px rgba(0,0,0,0.3);
}

/* ===== RESPONSIVE & MOBILE ADJUSTMENTS ===== */
@media (max-width: 768px) {
    .livemap-container {
        height: calc(100vh - 60px);
    }

    /* Mobile sidebar - slide drawer with overlay */
    .livemap-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
        z-index: 1100;
        transform: translateX(0);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .livemap-sidebar.collapsed {
        transform: translateX(-100%);
        /* Reset desktop collapse styles for mobile - keep full width for slide-out */
        width: 280px;
        min-width: 280px;
        border-right: 1px solid var(--bs-border-color, #dee2e6);
    }

    /* Overlay backdrop when sidebar is open */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1099;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Mobile status bar */
    .livemap-status-bar {
        font-size: 0.625rem;
        gap: 0.5rem;
        padding: 0 0.5rem;
        height: 28px;
    }

    .livemap-status-bar .status-separator {
        display: none;
    }

    .livemap-status-bar .status-zoom {
        display: none;
    }

    .livemap-status-bar .status-cell {
        display: none;
    }

    .livemap-status-bar i {
        display: none;
    }

    /* Mobile toggle button - more prominent */
    .livemap-sidebar-toggle {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
        top: 8px;
        left: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    /* Swipe hint indicator */
    .swipe-hint {
        position: fixed;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 6px;
        height: 80px;
        background: linear-gradient(to right, rgba(var(--bs-primary-rgb), 0.3), transparent);
        border-radius: 0 6px 6px 0;
        z-index: 1050;
        pointer-events: none;
        opacity: 0.6;
        transition: opacity 0.3s ease;
    }

    .swipe-hint.hidden {
        opacity: 0;
    }

    /* Mobile location info panel */
    .location-info-panel {
        left: 10px !important;
        right: 10px !important;
        top: auto !important;
        bottom: 50px !important;
        width: auto !important;
        max-height: 200px;
        border-radius: 0.75rem 0.75rem 0 0 !important;
    }

    /* Mobile teleport button - larger touch target */
    .teleport-mobile-button .btn {
        padding: 1rem 2rem;
        font-size: 1.1rem;
        min-width: 200px;
    }

    /* Mobile player markers - larger touch targets */
    .player-marker {
        width: 16px;
        height: 16px;
    }

    /* Mobile cluster icons - larger for touch */
    .player-cluster-icon {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Very small screens (phones in portrait) */
@media (max-width: 480px) {
    .livemap-sidebar {
        width: 100%;
        max-width: 100%;
    }

    .sidebar-header h5 {
        font-size: 1rem;
    }

    .layer-group-title {
        font-size: 0.7rem;
    }

    .layer-group .form-check-label {
        font-size: 0.8rem;
    }

    .livemap-status-bar {
        font-size: 0.55rem;
        height: 24px;
    }
}

/* Touch-friendly hover states */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .player-marker:hover {
        transform: none;
    }

    /* Larger touch targets for checkboxes */
    .form-check {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .form-check-input {
        width: 1.25em;
        height: 1.25em;
    }

    /* Make buttons more tappable */
    .btn-sm {
        padding: 0.5rem 0.75rem;
        min-height: 38px;
    }

    /* Search results - larger touch targets */
    .search-result-item {
        padding: 0.75rem 1rem !important;
        min-height: 48px;
    }
}

/* Loot tier colors (path/polygon styles) */
.loot-tier-1 { fill: rgba(150, 150, 150, 0.25); stroke: #969696; stroke-width: 1; }
.loot-tier-2 { fill: rgba(50, 200, 50, 0.25); stroke: #32c832; stroke-width: 1; }
.loot-tier-3 { fill: rgba(50, 150, 255, 0.25); stroke: #3296ff; stroke-width: 1; }
.loot-tier-4 { fill: rgba(180, 100, 255, 0.25); stroke: #b464ff; stroke-width: 1; }
.loot-tier-5 { fill: rgba(255, 200, 50, 0.25); stroke: #ffc832; stroke-width: 1; }
.loot-tier-6 { fill: rgba(255, 100, 50, 0.25); stroke: #ff6432; stroke-width: 1; }
.loot-tier-7 { fill: rgba(255, 50, 50, 0.25); stroke: #ff3232; stroke-width: 1; }
.loot-tier-8 { fill: rgba(255, 0, 100, 0.25); stroke: #ff0064; stroke-width: 1; }

/* Loot tier popup */
.loot-tier-popup {
    color: var(--bs-body-color);
}

.loot-tier-popup .popup-header {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--bs-border-color, rgba(0,0,0,0.1));
    color: var(--bs-body-color);
}

/* ==========================================================================
   Location Popups - Consistent Bootstrap 5 Theming
   ========================================================================== */

/* Common popup styles */
.town-popup,
.settlement-popup,
.poi-popup,
.dungeon-popup {
    min-width: 180px;
    color: var(--bs-body-color);
}

.settlement-popup {
    min-width: 200px;
}

.town-popup .popup-header,
.settlement-popup .popup-header,
.poi-popup .popup-header,
.dungeon-popup .popup-header {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--bs-border-color, rgba(0,0,0,0.1));
    color: var(--bs-body-color);
}

.town-popup .popup-stat,
.settlement-popup .popup-stat,
.poi-popup .popup-stat,
.dungeon-popup .popup-stat {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: var(--bs-body-color);
}

.town-popup .popup-stat-label,
.settlement-popup .popup-stat-label,
.poi-popup .popup-stat-label,
.dungeon-popup .popup-stat-label {
    color: var(--bs-secondary-color, #6c757d);
}

.town-popup .popup-stat span:not(.popup-stat-label),
.settlement-popup .popup-stat span:not(.popup-stat-label),
.poi-popup .popup-stat span:not(.popup-stat-label),
.dungeon-popup .popup-stat span:not(.popup-stat-label) {
    color: var(--bs-body-color);
}

.dungeon-popup .popup-players {
    max-height: 100px;
    overflow-y: auto;
    font-size: 0.75rem;
    color: var(--bs-secondary-color, #6c757d);
}

/* Impassable terrain overlays */
.impassable-overlay {
    pointer-events: none;
}

/* Map image overlay (fallback mode) */
.map-image-overlay {
    image-rendering: auto;
}

/* Active landblock colors */
.active-landblock-low {
    fill: rgba(50, 150, 255, 0.3);
    stroke: rgba(50, 150, 255, 0.5);
}

.active-landblock-medium {
    fill: rgba(255, 200, 50, 0.4);
    stroke: rgba(255, 200, 50, 0.6);
}

.active-landblock-high {
    fill: rgba(255, 100, 50, 0.5);
    stroke: rgba(255, 100, 50, 0.7);
}

.active-landblock-players {
    fill: rgba(100, 255, 100, 0.4);
    stroke: rgba(100, 255, 100, 0.6);
}

/* Context menu styling (Desktop teleport) */
.teleport-context-menu {
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 0.5rem;
    overflow: hidden;
}

.teleport-context-menu .fw-bold {
    font-size: 0.9rem;
    color: var(--bs-body-color);
}

/* Mobile teleport button (legacy) */
.teleport-mobile-button {
    z-index: 1050;
    padding-bottom: 40px; /* Space above status bar */
}

.teleport-mobile-button .btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ===== MOBILE ACTION BAR ===== */
.teleport-mobile-bar {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.teleport-mobile-bar .btn {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.teleport-mobile-bar .btn-primary {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
}

/* Ensure buttons have proper touch targets */
@media (max-width: 768px) {
    .teleport-mobile-bar {
        padding: 0.75rem 0.5rem !important;
    }
    
    .teleport-mobile-bar .d-flex.gap-2 {
        gap: 0.5rem !important;
    }
}

/* Teleport modal enhancements */
#teleportModal .modal-content {
    border-radius: 0.75rem;
}

#teleportModal .form-select {
    font-size: 0.95rem;
}

/* Teleport success animation */
@keyframes teleport-success {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.teleport-success {
    animation: teleport-success 0.3s ease-out;
}

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

/* Move zoom controls up to account for status bar (32px + margin) */
.leaflet-control-zoom {
    margin-bottom: 45px !important;
}

/* Also move attribution up */
.leaflet-control-attribution {
    margin-bottom: 35px !important;
    font-size: 0.65rem;
    opacity: 0.7;
}

.leaflet-popup-content-wrapper {
    border-radius: 0.5rem;
}

.leaflet-popup-content {
    margin: 1rem;
}

/* Alert within sidebar */
.alert-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
}

/* Location info panel */
.location-info-panel {
    backdrop-filter: blur(8px);
    background: rgba(var(--bs-body-bg-rgb), 0.95) !important;
}

.location-info-panel .location-details {
    color: var(--bs-body-color);
}

.location-info-panel .border-bottom {
    border-color: var(--bs-border-color) !important;
}

/* Responsive - hide info panel on very small screens */
@media (max-width: 576px) {
    .location-info-panel {
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-height: 250px;
    }
}

/* ===== OFFLINE NOTIFICATION ===== */
.offline-notification {
    font-size: 0.8rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    z-index: 1100;
    border-left: 3px solid #856404;
}

.offline-notification i {
    font-size: 1.1rem;
    animation: warning-pulse 2s ease-in-out infinite;
}

@keyframes warning-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Mobile: position offline notification above status bar */
@media (max-width: 768px) {
    .offline-notification {
        bottom: 60px !important;
        left: 5px !important;
        right: 5px !important;
        max-width: none !important;
    }
}

/* Adjust map area when offline banner is shown - no longer needed */
.livemap-container.offline-mode .livemap-map {
    margin-top: 40px;
}

/* Dim live data controls when offline */
.livemap-sidebar .layer-group.live-data-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.livemap-sidebar .layer-group.live-data-disabled::after {
    content: "Unavailable when offline";
    display: block;
    font-size: 0.7rem;
    color: var(--bs-danger);
    margin-top: 0.25rem;
}

/* Stale update indicator styling */
.status-update.text-warning {
    animation: stale-blink 2s ease-in-out infinite;
}

@keyframes stale-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Cell info in status bar */
.status-cell {
    font-size: 0.65rem;
}

/* Dungeon popup wrapper */
.dungeon-popup-wrapper .leaflet-popup-content {
    margin: 0.75rem;
}

/* Enhanced dungeon popup */
.dungeon-popup .dungeon-player-list {
    background: var(--bs-tertiary-bg, #f8f9fa);
    border-radius: 0.25rem;
    padding: 0.5rem;
}

/* Static dungeon entrance popup */
.dungeon-popup h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--bs-body-color);
}

.dungeon-popup .portal-name {
    margin: 0 0 0.25rem 0;
    font-size: 0.85rem;
    color: var(--bs-secondary-color, #6c757d);
}

.dungeon-popup .coordinates {
    margin: 0 0 0.25rem 0;
    font-size: 0.9rem;
    font-family: monospace;
    color: var(--bs-body-color);
}

.dungeon-popup .landblock {
    margin: 0 0 0.25rem 0;
    font-size: 0.75rem;
    color: var(--bs-secondary-color, #6c757d);
    font-family: monospace;
}

.dungeon-popup .entrance-count {
    margin: 0;
    font-size: 0.75rem;
    color: var(--bs-info, #0dcaf0);
    font-style: italic;
}

/* ===== INDOOR PLAYER MARKERS ===== */
.player-marker.indoor-player {
    border-style: dashed;
    border-width: 2px;
}

.player-marker.indoor-player .player-marker-inner {
    background: #9370DB; /* Medium purple for indoor */
}

.player-marker.indoor-player.level-low .player-marker-inner {
    background: rgba(147, 112, 219, 0.7);
}

.player-marker.indoor-player.level-mid .player-marker-inner {
    background: rgba(138, 43, 226, 0.85);
}

.player-marker.indoor-player.level-high .player-marker-inner {
    background: #8A2BE2; /* BlueViolet for high level indoor */
}

/* ===== PLAYER FILTER OPTIONS ===== */
.player-filter-options {
    padding: 0.25rem 0;
    border-left: 2px solid var(--bs-border-color);
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

.player-filter-options .form-check-sm {
    min-height: 1.25rem;
    margin-bottom: 0.125rem;
}

.player-filter-options .form-check-sm .form-check-input {
    width: 0.875em;
    height: 0.875em;
    margin-top: 0.2em;
}

.player-filter-options .form-check-label {
    font-size: 0.8rem;
}

.player-filter-options .badge {
    font-size: 0.6rem;
    padding: 0.15em 0.4em;
}

/* ===== ACTIVE LANDBLOCK HEATMAP ===== */
.active-landblock {
    transition: fill-opacity 0.3s ease;
}

.active-landblock:hover {
    fill-opacity: 0.6 !important;
}

/* Activity level colors */
.active-landblock.activity-low {
    fill: rgba(51, 153, 255, 0.25);
    stroke: rgba(51, 153, 255, 0.5);
}

.active-landblock.activity-light {
    fill: rgba(51, 204, 255, 0.35);
    stroke: rgba(51, 204, 255, 0.6);
}

.active-landblock.activity-medium {
    fill: rgba(255, 204, 51, 0.4);
    stroke: rgba(255, 204, 51, 0.7);
}

.active-landblock.activity-high {
    fill: rgba(255, 136, 51, 0.45);
    stroke: rgba(255, 136, 51, 0.75);
}

.active-landblock.activity-very-high {
    fill: rgba(255, 51, 51, 0.5);
    stroke: rgba(255, 51, 51, 0.8);
}

.active-landblock.activity-players-medium {
    fill: rgba(102, 255, 102, 0.35);
    stroke: rgba(102, 255, 102, 0.6);
}

.active-landblock.activity-players-high {
    fill: rgba(0, 255, 102, 0.45);
    stroke: rgba(0, 255, 102, 0.7);
    animation: player-hotspot-pulse 3s infinite;
}

@keyframes player-hotspot-pulse {
    0%, 100% { fill-opacity: 0.35; }
    50% { fill-opacity: 0.5; }
}

/* Landblock activity tooltip */
.landblock-tooltip {
    background: rgba(0, 0, 0, 0.9) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 4px !important;
    padding: 0 !important;
}

.landblock-tooltip .leaflet-tooltip-content {
    padding: 0.5rem;
}

.landblock-activity-tooltip {
    font-size: 0.75rem;
    line-height: 1.4;
}

.landblock-activity-tooltip .fw-bold {
    font-family: 'Consolas', 'Monaco', monospace;
    color: #88d4ff;
}

/* ===== ENHANCED SEARCH RESULTS ===== */
.search-results {
    left: 0;
    right: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.search-result-item {
    transition: background-color 0.15s ease;
}

.search-result-item:hover {
    background-color: var(--bs-tertiary-bg, #f8f9fa);
}

.search-result-item:last-child {
    border-bottom: none !important;
}

.search-result-item .badge {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.search-result-item .text-truncate {
    max-width: 180px;
}

/* Search type-specific badge colors */
.search-result-item .badge.bg-info {
    background-color: #17a2b8 !important;
}

.search-result-item .badge.bg-warning {
    background-color: #ffc107 !important;
}

/* ===== COLLAPSE ANIMATION (Alpine.js x-collapse) ===== */
[x-cloak] { display: none !important; }

/* Smooth collapse for player filter options */
.player-filter-options {
    overflow: hidden;
    transition: max-height 0.2s ease-out, opacity 0.2s ease-out;
}

/* ===== HOUSING FILTERS ===== */
.housing-filter-options {
    padding: 0.25rem 0;
    border-left: 2px solid var(--bs-border-color);
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
    overflow: hidden;
    transition: max-height 0.2s ease-out, opacity 0.2s ease-out;
}

.housing-filter-options .form-check-sm {
    min-height: 1.25rem;
    margin-bottom: 0.125rem;
}

.housing-filter-options .form-check-sm .form-check-input {
    width: 0.875em;
    height: 0.875em;
    margin-top: 0.2em;
}

.housing-filter-options .form-check-label {
    font-size: 0.8rem;
}

.housing-filter-options hr {
    border-color: var(--bs-border-color);
    opacity: 0.5;
}

/* ===== DISTANCE CALCULATOR ===== */

/* Distance calculator point markers */
.distance-calc-point {
    background: transparent;
}

.distance-calc-point-inner {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    border: 2px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.distance-calc-point-inner:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}

.distance-calc-point:active .distance-calc-point-inner,
.leaflet-dragging .distance-calc-point-inner {
    cursor: grabbing;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Distance line styling */
.distance-calc-line {
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Distance calculator sidebar tool group */
.distance-calc-tool {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--bs-tertiary-bg, #f8f9fa);
    border-radius: 0.375rem;
}

.distance-calc-tool.active {
    background: rgba(255, 107, 53, 0.15);
    border: 1px solid rgba(255, 107, 53, 0.4);
}

.distance-calc-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.distance-calc-toggle-btn i {
    font-size: 1rem;
}

/* Distance results display */
.distance-calc-results {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
}

.distance-calc-total {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ff6b35;
}

/* Distance breakdown row (landblocks, cells) */
.distance-calc-breakdown {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--bs-secondary-color, #6c757d);
    padding: 0.25rem 0.5rem;
    background: var(--bs-tertiary-bg, rgba(0,0,0,0.03));
    border-radius: 0.25rem;
}

.distance-calc-detail-item {
    display: inline-flex;
    align-items: center;
}

.distance-calc-detail-item i {
    font-size: 0.65rem;
    opacity: 0.7;
}

.distance-calc-separator {
    color: var(--bs-border-color, #dee2e6);
    margin: 0 0.25rem;
}

.distance-calc-detail {
    font-size: 0.75rem;
    color: var(--bs-secondary-color, #6c757d);
}

.distance-calc-segment {
    font-size: 0.7rem;
    padding: 0.25rem 0;
    border-bottom: 1px dashed var(--bs-border-color, #dee2e6);
}

.distance-calc-segment:last-child {
    border-bottom: none;
}

.distance-calc-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.distance-calc-actions .btn {
    flex: 1;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Distance calculator hint */
.distance-calc-hint {
    font-size: 0.7rem;
    color: var(--bs-secondary-color, #6c757d);
    font-style: italic;
    margin-top: 0.25rem;
}

/* Crosshair cursor when distance calculator is active */
.livemap-map.distance-calc-active {
    cursor: crosshair !important;
}

/* Mobile adjustments for distance calculator */
@media (max-width: 768px) {
    .distance-calc-point-inner {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }
    
    .distance-calc-results {
        font-size: 0.9rem;
    }
}
