/* ==========================================================================
   GravelFinder - Straatverlichting (Nacht) Kaartlaag Styling
   ========================================================================== */

/* --- Floating HUD Status & Legende --- */
.sl-hud-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    max-width: 320px;
    width: calc(100vw - 48px);
    background: rgba(18, 22, 28, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 16px rgba(245, 158, 11, 0.2);
    color: #f1f5f9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.4;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    user-select: none;
    animation: slSlideUp 0.35s ease-out;
}

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

.sl-hud-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
}

.sl-hud-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 13.5px;
    color: #fef08a;
    letter-spacing: 0.2px;
}

.sl-hud-title .sl-icon {
    font-size: 16px;
    filter: drop-shadow(0 0 6px rgba(250, 204, 21, 0.6));
}

.sl-hud-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sl-hud-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    border-radius: 6px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.sl-hud-btn:hover {
    background: rgba(251, 191, 36, 0.2);
    border-color: rgba(251, 191, 36, 0.5);
    color: #fff;
}

.sl-hud-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: max-height 0.3s ease, opacity 0.25s ease;
}

.sl-hud-container.minimized .sl-hud-body {
    display: none;
}

/* Status Banner */
.sl-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.25);
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 12px;
}

.sl-status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.sl-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #22c55e;
    box-shadow: 0 0 8px #22c55e;
}

.sl-dot.loading {
    background-color: #f59e0b;
    box-shadow: 0 0 8px #f59e0b;
    animation: slPulse 1.2s infinite;
}

.sl-dot.warning {
    background-color: #ef4444;
    box-shadow: 0 0 8px #ef4444;
}

@keyframes slPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.sl-counter-badge {
    background: rgba(251, 191, 36, 0.15);
    color: #fef08a;
    border: 1px solid rgba(251, 191, 36, 0.3);
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

/* Zoom In Notice Banner */
.sl-zoom-notice {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    padding: 9px 11px;
    border-radius: 8px;
    font-size: 11.5px;
    color: #fef08a;
}

.sl-zoom-btn {
    background: #f59e0b;
    color: #0f172a;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-weight: 700;
    font-size: 11.5px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.sl-zoom-btn:hover {
    background: #fbbf24;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

/* Legend Items */
.sl-legend {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding-top: 2px;
}

.sl-legend-item {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12px;
    color: #e2e8f0;
}

.sl-legend-line {
    width: 24px;
    height: 6px;
    border-radius: 3px;
    flex-shrink: 0;
}

.sl-legend-line.lit {
    background: #fde047;
    box-shadow: 0 0 8px #f59e0b, 0 0 2px #fff;
    border: 1px solid #f59e0b;
}

.sl-legend-line.interval {
    background: repeating-linear-gradient(90deg, #fb923c, #fb923c 4px, transparent 4px, transparent 8px);
    box-shadow: 0 0 6px #ea580c;
}

.sl-legend-line.unlit {
    background: repeating-linear-gradient(90deg, #64748b, #64748b 4px, transparent 4px, transparent 8px);
    border: 1px dashed #94a3b8;
}

/* Toggle Option Row */
.sl-filter-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11.5px;
    color: #94a3b8;
}

.sl-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.sl-checkbox-label input[type="checkbox"] {
    accent-color: #f59e0b;
    cursor: pointer;
}

/* Zoom Prompt Toast */
.sl-zoom-toast {
    position: fixed;
    top: 75px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(251, 191, 36, 0.5);
    color: #fef08a;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 12px rgba(245, 158, 11, 0.25);
    z-index: 1000;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slFadeIn 0.3s ease;
    transition: opacity 0.3s;
}

@keyframes slFadeIn {
    from { opacity: 0; transform: translate(-50%, -10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* --- Leaflet Popup Overrides for Street Lighting --- */
.leaflet-popup.sl-custom-popup .leaflet-popup-content-wrapper {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(251, 191, 36, 0.4);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 16px rgba(245, 158, 11, 0.25);
    color: #f8fafc;
    padding: 0;
}

.leaflet-popup.sl-custom-popup .leaflet-popup-tip {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(251, 191, 36, 0.4);
}

.leaflet-popup.sl-custom-popup .leaflet-popup-content {
    margin: 14px 16px;
    line-height: 1.45;
}

.sl-popup-card {
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-width: 220px;
    max-width: 280px;
}

.sl-popup-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sl-popup-icon {
    font-size: 18px;
    filter: drop-shadow(0 0 8px rgba(250, 204, 21, 0.8));
}

.sl-popup-title {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    word-break: break-word;
}

.sl-popup-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    width: fit-content;
}

.sl-popup-badge.lit {
    background: rgba(34, 197, 94, 0.18);
    border: 1px solid rgba(34, 197, 94, 0.45);
    color: #4ade80;
}

.sl-popup-badge.interval {
    background: rgba(249, 115, 22, 0.18);
    border: 1px solid rgba(249, 115, 22, 0.45);
    color: #fb923c;
}

.sl-popup-badge.unlit {
    background: rgba(148, 163, 184, 0.15);
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: #cbd5e1;
}

.sl-popup-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 255, 255, 0.04);
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 12px;
}

.sl-popup-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.sl-popup-label {
    color: #94a3b8;
    font-size: 11.5px;
}

.sl-popup-value {
    color: #f1f5f9;
    font-weight: 500;
    text-align: right;
}

.sl-popup-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

.sl-popup-link {
    color: #fbbf24;
    text-decoration: none;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}

.sl-popup-link:hover {
    color: #fef08a;
    text-decoration: underline;
}

/* Bullet glow indicator and popup indicator (clean replacement for 💡 emoji) */
.sl-glow-bullet {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #fbbf24;
    box-shadow: 0 0 8px #fbbf24, 0 0 14px rgba(251, 191, 36, 0.6);
    flex-shrink: 0;
}

.sl-popup-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #fbbf24;
    box-shadow: 0 0 8px #fbbf24;
    flex-shrink: 0;
    margin-right: 6px;
}

/* ==========================================================================
   Mobile Lite HUD Styling
   ========================================================================== */
.sl-hud-lite {
    display: none;
    background: rgba(18, 22, 28, 0.90);
    backdrop-filter: blur(14px) saturate(180%);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    border: 1px solid rgba(251, 191, 36, 0.45);
    border-radius: clamp(5px, 1.25vw, 8px);
    padding: clamp(4px, 1.2vw, 6px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.25), 0 0 10px rgba(245, 158, 11, 0.15);
    color: #f1f5f9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 11px;
    box-sizing: border-box;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: auto;
    user-select: none;
    min-height: 70px;
}

.sl-lite-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: clamp(2px, 0.75vw, 4px);
    gap: 4px;
}

.sl-lite-title-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.sl-lite-title {
    font-size: clamp(9px, 2.25vw, 12px);
    font-weight: 700;
    color: #fef08a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sl-lite-badge {
    background: rgba(251, 191, 36, 0.18);
    color: #fef08a;
    border: 1px solid rgba(251, 191, 36, 0.35);
    padding: 1px 5px;
    border-radius: 8px;
    font-size: 9.5px;
    font-weight: 700;
    white-space: nowrap;
}

.sl-lite-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 44px;
    justify-content: center;
}

/* Zoom in view */
.sl-lite-zoom-view {
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
    align-items: stretch;
    padding: 2px 0;
}

.sl-lite-zoom-txt {
    font-size: 10px;
    color: #fef08a;
    text-align: center;
    font-weight: 600;
}

.sl-lite-zoom-btn {
    background: #f59e0b;
    color: #0f172a;
    border: none;
    border-radius: 4px;
    padding: 4px 6px;
    font-weight: 700;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.sl-lite-zoom-btn:active {
    background: #fbbf24;
    transform: scale(0.97);
}

/* Stats 2x2 grid */
.sl-lite-stats-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: center;
}

.sl-lite-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3px;
}

.sl-lite-item {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    color: #f1f5f9;
    min-height: 22px;
    height: 22px;
    box-sizing: border-box;
    line-height: 1.1;
    text-align: left;
    margin: 0;
}

.sl-lite-item.unlit {
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.sl-lite-item.unlit:not(.active) {
    opacity: 0.45;
    text-decoration: line-through;
    border-color: rgba(255, 255, 255, 0.05);
}

.sl-lite-item.unlit.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
}

.sl-lite-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.sl-lite-swatch.lit {
    background: #fbbf24;
    box-shadow: 0 0 5px rgba(251, 191, 36, 0.8);
}

.sl-lite-swatch.interval {
    background: #f97316;
    box-shadow: 0 0 4px rgba(249, 115, 22, 0.6);
}

.sl-lite-swatch.unlit {
    background: #64748b;
    border: 1px dashed #94a3b8;
}

.sl-lite-label {
    flex-shrink: 0;
}

.sl-lite-num {
    margin-left: auto;
    font-weight: 700;
    color: #ffffff;
    font-size: 9.5px;
}

.sl-lite-item.status {
    justify-content: center;
    background: none;
    border: none;
}

.sl-lite-status-txt {
    font-size: 9px;
    color: #cbd5e1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    width: 100%;
}

/* ==========================================================================
   Desktop vs Mobile Responsive Rules
   ========================================================================== */

/* Desktop: Never show lite HUD */
@media (min-width: 769px) {
    .sl-hud-lite {
        display: none !important;
    }
}

/* Mobile: Hide bottom floating HUD & toast; Dock lite HUD in top-legend-row */
@media (max-width: 768px) {
    .sl-hud-container {
        display: none !important;
    }

    .sl-zoom-toast {
        display: none !important;
    }

    .top-overlays-bar {
        left: 6px !important;
        right: 6px !important;
        width: auto !important;
    }

    .map-controls-left {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .top-legend-row {
        display: flex !important;
        flex-direction: row !important;
        align-items: stretch !important;
        gap: 6px !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        pointer-events: none !important;
    }

    .top-legend-row > * {
        pointer-events: auto !important;
    }

    /* Balanced equal size pairing when street lighting is active */
    .top-legend-row.has-lighting-hud {
        width: 100% !important;
        max-width: 100% !important;
    }

    .top-legend-row.has-lighting-hud .legend-overlay {
        flex: 1 1 0 !important;
        width: calc(50% - 3px) !important;
        min-width: 0 !important;
        max-width: calc(50% - 3px) !important;
        box-sizing: border-box !important;
        margin: 0 !important;
    }

    .top-legend-row.has-lighting-hud .sl-hud-lite {
        flex: 1 1 0 !important;
        width: calc(50% - 3px) !important;
        min-width: 0 !important;
        max-width: calc(50% - 3px) !important;
        display: flex !important;
        box-sizing: border-box !important;
        margin: 0 !important;
    }

    /* Compact legend overlay items when paired side-by-side with lite HUD */
    .top-legend-row.has-lighting-hud .legend-content-row {
        gap: 3px !important;
    }
    .top-legend-row.has-lighting-hud .legend-overlay .legend-items {
        gap: 2px !important;
    }
    .top-legend-row.has-lighting-hud .legend-item-toggle {
        padding: 1px 3px !important;
        font-size: 9px !important;
        gap: 3px !important;
        height: 20px !important;
        min-height: 20px !important;
    }
    .top-legend-row.has-lighting-hud .legend-square {
        width: 10px !important;
        height: 10px !important;
    }
    .top-legend-row.has-lighting-hud .weather-toggle {
        padding-left: 2px !important;
        gap: 2px !important;
    }
    .top-legend-row.has-lighting-hud .switch-text {
        font-size: 8.5px !important;
    }
    .top-legend-row.has-lighting-hud .switch-slider {
        width: 22px !important;
        height: 12px !important;
    }
    .top-legend-row.has-lighting-hud .switch-slider:before {
        width: 8px !important;
        height: 8px !important;
        left: 2px !important;
        bottom: 2px !important;
    }
    .top-legend-row.has-lighting-hud input:checked + .switch-slider:before {
        transform: translateX(10px) !important;
    }
    .top-legend-row.has-lighting-hud .clear-btn-legend {
        font-size: 8.5px !important;
        height: 16px !important;
        min-height: 16px !important;
        padding: 1px 3px !important;
    }
}
